7 repomgr => { paths => [ qw(repomgr) ] },
9 bid => { paths => [ qw(l4/Makefile
27 toolbin => { paths => [ map { "l4/tool/bin/$_" }
28 qw(isocreator qemu-x86-launch ux-launch
29 gengrub1iso gengrub2iso entry-selector
34 l4re => { paths => [ map { "l4/pkg/$_" } qw(
35 boehm_gc bootstrap libgcc libgcc-pure
36 crtn cxx cxx_libc_io cxx_thread drivers-frst hello
38 l4re l4re_c l4re_kernel l4re_vfs l4sys l4util
40 libc_backends libkproxy libloader
42 libstdc++-headers libstdc++-v3 libstdc++-v3-minimal
43 libsupc++ libsupc++-minimal
44 libvbus libvcpu loader log lua moe ned sigma0
45 uclibc uclibc-minimal uclibc-headers
48 modules => [ qw(bid toolbin) ],
51 # ./mk/pkgdeps -A mk/aliases.d pkgdeps pkg ...
53 => { paths => [ map { "l4/pkg/$_" } qw(
54 libio libio-io lxfuxlibc rtc shmc
55 acpica io drivers fb-drv x86emu input libirq
58 modules => [ qw(l4re) ],
62 paths => [ qw(l4/pkg/hello),
63 map { "l4/pkg/examples/$_" }
78 modules => [ qw(examples_core) ],
79 paths => [ qw(l4/pkg/hello),
80 map { "l4/pkg/examples/$_" }
96 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
99 paths => [ map { "l4/pkg/$_" }
160 modules => [ qw(l4re examples_all doc toolbin) ] },
162 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
163 modules => [ qw(l4re_snapshot) ] },
167 paths => [ qw(kernel/fiasco/BENCHMARKING
168 kernel/fiasco/COPYING
169 kernel/fiasco/MAINTAINER
170 kernel/fiasco/Makefile
178 paths => [ qw(kernel/Makefile) ],
182 paths => [ qw(grub) ],
185 remote_repo_l4re => {
186 modules => [ qw(l4re_snapshot) ],
189 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ],
190 # those are going away, we need to keep them to get the
191 # dirs updated and thus removed
192 paths => [ qw(l4/pkg/libstdc++-v3_r
198 modules => [ qw(remote_repo) ],
203 my $svnrev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
207 my $o = `svn info -r '$svnrev' --xml .`;
208 die "Failed 'svn info'." if $?;
209 $o =~ /<root>(.+)<\/root>/m;
219 my $pathsref = shift;
222 die "Possible looping in modules structure detected!" unless $count;
226 die "Unknown module '$m' referenced!" unless defined $modules{$m};
227 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
228 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
232 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
237 sub show_pub_modules()
239 print "Available modules:\n";
240 foreach (sort keys %modules)
242 print " $_\n" if $modules{$_}{pub_module};
251 $command = $commands{$command}{alias}
252 if defined $command and defined $commands{$command}{alias};
254 if (!defined $command or $command eq 'help')
256 print "$0 command [option]\n";
258 print "Available commands, use '$0 help command' for help on the command:\n";
259 foreach (sort keys %commands)
261 print " $_\n" if defined $commands{$_}{public};
264 elsif ($command eq 'update')
266 print " 'update' will update in the following way:\n".
267 " update itself and re-exec if necessary\n".
268 " call 'make update' in l4/pkg\n".
269 " call 'svn update' every directory in kernel\n";
271 elsif ($command eq 'checkout')
273 print " 'checkout' will check out the given modules.\n";
276 elsif ($command eq 'modules')
282 print " No such command '$command'.\n";
286 sub check_module_structure()
288 # make sure the paths look ok
289 foreach (merge_modules())
291 die "Trailing /'s in modules structure" if /\/$/;
292 die "Double // detected in modules structure" if /\/\//;
310 die "Need to give URL" unless defined $url and defined $dirname;
311 system("svn co -r '$svnrev' $url --depth empty $dirname");
316 my $config_blob = shift;
317 $config_blob = '{}' unless defined $config_blob;
319 unless ($c = eval($config_blob))
321 die "Couldn't parse config file: $@" if $@;
322 die "Couldn't do config file: $!" if $!;
323 die "Couldn't run config file";
328 $a{base} = "trunk" unless defined $a{base};
333 sub convert_path($$%)
336 my $partmatch = shift;
341 foreach my $key (keys %path_roots)
344 $r .= '/' unless $r =~ /\/$/;
347 # for partly matches we also need to return the modified path
348 # because otherwise we can't really know
349 if ($p =~ /^($r)(.*)$/)
351 my $s = $path_roots{$key}.'/'.$2;
352 # strip off last / again, it's just used for matching
353 return substr($s, 0, length($s) - 1);
358 return $path_roots{$key} if $p =~ /^$r$/;
367 unless (defined ${$args{mods}}[0])
369 print "Supply module to check out.\n";
374 die "Current directory is no SVN WC" unless -d ".svn";
376 my $root_url = get_root_url();
378 my @paths = merge_modules(@{$args{mods}});
380 foreach my $paths (@paths)
382 my @path_elems = split /\/+/, $paths;
383 my $last_elem = pop @path_elems;
386 foreach my $pe (@path_elems)
388 if (! -d "$path/$pe/.svn")
390 # if we find something from path_roots then switch to that
391 my $changed_path = convert_path("$path/$pe", 0,
392 %{$args{conf}{path_roots}});
394 print "Creating $path/$pe\n";
395 print " from $changed_path\n" if defined $changed_path;
397 # there's some other little problem with the 'depth' thing
398 # when we do checkout some specific list of files (and dirs),
399 # we need to use depth=empty so that we only get those
400 # specific files out of the directory, on the other side we'd
401 # (probably) like to have updates on the directory contents
402 # when we do 'svn up' which would would with depth=files (or
404 # As the first thing is merely only needed when doing a
405 # checkout for another repo... let's have a config option.
407 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
409 if (defined $changed_path)
411 my $cmd = "cd $path && svn co -r '$svnrev' --depth empty $root_url/$changed_path $pe";
412 #print "cmd: $cmd\n";
414 die "svn co failed" if $?;
418 my $cmd = "cd $path && svn update -r '$svnrev' --depth empty $pe";
419 #print "cmd: $cmd\n";
421 die "svn update failed" if $?;
428 print "Getting sources\n";
429 my $c = "svn update -r '$svnrev' --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
432 die "svn update failed" if $?;
438 return undef unless defined $fn;
440 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
442 $blob = `svn -r '$svnrev' cat $fn`;
456 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
457 do_checkout(conf => { %conf }, mods => [ @_ ]);
460 sub fix_repomgr_path(%)
463 # fix the path to the repomgr...
464 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
465 if defined $conf{repomgr_prefix};
470 my $repo_root = shift;
472 my $localdir = 'src';
474 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
481 elsif ($_[0] eq '-l')
488 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
489 if not defined $repo_root or not defined $repo_conf
490 or not defined $localdir;
492 # for absolute path we assume a local config file, good for testing
494 if ($repo_conf ne '')
496 if ($repo_conf =~ /^\//)
498 $confblob = read_file($repo_conf);
499 die "Cannot open '$repo_conf': $!" unless defined $confblob;
503 my $cmd = "svn cat -r '$svnrev' $repo_root\/$repo_conf";
505 die "Command '$cmd' failed" if $?;
509 my %conf = init_config($confblob);
511 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
512 print "localdir: $localdir\n";
514 my $cmd = "svn co -r '$svnrev' --depth empty $repo_root/$conf{base} $localdir";
516 die "Command '$cmd' failed" if $?;
519 fix_repomgr_path(%conf);
520 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
525 foreach (sort keys %modules)
527 print "$_\n" if defined $modules{$_}{pub_module};
533 print "$_\n" foreach merge_modules(@_);
536 sub command_listmapped
538 my $blob = read_file(shift);
539 die "Need config" unless defined $blob;
540 my %conf = init_config($blob);
541 fix_repomgr_path(%conf);
542 print join("\n", map {
543 my $p = convert_path($_, 1, %{$conf{path_roots}});
544 defined $p ? $p : $_;
545 } merge_modules(@_));
551 help => { func => \&command_help, },
552 init => { func => \&command_init, },
553 update => { func => \&command_update, },
554 up => { func => \&command_update, alias => 'update' },
555 checkout => { func => \&command_checkout, public => 1},
556 co => { func => \&command_checkout, alias => 'checkout'},
557 modules => { func => \&command_modules, public => 1},
558 list => { func => \&command_list, },
559 listmapped=> { func => \&command_listmapped, },
560 root => { func => \&command_root, },
563 # ----------------------------------------------------------------
565 check_module_structure();
569 unless (defined $command)
575 if (defined $commands{$command})
577 &{$commands{$command}{func}}(@ARGV);
581 print "Unknown command '$command'.\n";