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/$_" }
97 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
100 paths => [ map { "l4/pkg/$_" }
162 modules => [ qw(l4re examples_all doc toolbin) ] },
164 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
165 modules => [ qw(l4re_snapshot) ] },
169 paths => [ qw(kernel/fiasco/BENCHMARKING
170 kernel/fiasco/COPYING
171 kernel/fiasco/MAINTAINER
172 kernel/fiasco/Makefile
180 paths => [ qw(kernel/Makefile) ],
184 paths => [ qw(grub) ],
187 remote_repo_l4re => {
188 modules => [ qw(l4re_snapshot) ],
191 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ],
192 # those are going away, we need to keep them to get the
193 # dirs updated and thus removed
194 paths => [ qw(l4/pkg/libstdc++-v3_r
200 modules => [ qw(remote_repo) ],
205 my $svnrev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
209 my $o = `svn info -r '$svnrev' --xml .`;
210 die "Failed 'svn info'." if $?;
211 $o =~ /<root>(.+)<\/root>/m;
221 my $pathsref = shift;
224 die "Possible looping in modules structure detected!" unless $count;
228 die "Unknown module '$m' referenced!" unless defined $modules{$m};
229 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
230 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
234 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
239 sub show_pub_modules()
241 print "Available modules:\n";
242 foreach (sort keys %modules)
244 print " $_\n" if $modules{$_}{pub_module};
253 $command = $commands{$command}{alias}
254 if defined $command and defined $commands{$command}{alias};
256 if (!defined $command or $command eq 'help')
258 print "$0 command [option]\n";
260 print "Available commands, use '$0 help command' for help on the command:\n";
261 foreach (sort keys %commands)
263 print " $_\n" if defined $commands{$_}{public};
266 elsif ($command eq 'update')
268 print " 'update' will update in the following way:\n".
269 " update itself and re-exec if necessary\n".
270 " call 'make update' in l4/pkg\n".
271 " call 'svn update' every directory in kernel\n";
273 elsif ($command eq 'checkout')
275 print " 'checkout' will check out the given modules.\n";
278 elsif ($command eq 'modules')
284 print " No such command '$command'.\n";
288 sub check_module_structure()
290 # make sure the paths look ok
291 foreach (merge_modules())
293 die "Trailing /'s in modules structure" if /\/$/;
294 die "Double // detected in modules structure" if /\/\//;
312 die "Need to give URL" unless defined $url and defined $dirname;
313 system("svn co -r '$svnrev' $url --depth empty $dirname");
318 my $config_blob = shift;
319 $config_blob = '{}' unless defined $config_blob;
321 unless ($c = eval($config_blob))
323 die "Couldn't parse config file: $@" if $@;
324 die "Couldn't do config file: $!" if $!;
325 die "Couldn't run config file";
330 $a{base} = "trunk" unless defined $a{base};
335 sub convert_path($$%)
338 my $partmatch = shift;
343 foreach my $key (keys %path_roots)
346 $r .= '/' unless $r =~ /\/$/;
349 # for partly matches we also need to return the modified path
350 # because otherwise we can't really know
351 if ($p =~ /^($r)(.*)$/)
353 my $s = $path_roots{$key}.'/'.$2;
354 # strip off last / again, it's just used for matching
355 return substr($s, 0, length($s) - 1);
360 return $path_roots{$key} if $p =~ /^$r$/;
369 unless (defined ${$args{mods}}[0])
371 print "Supply module to check out.\n";
376 die "Current directory is no SVN WC" unless -d ".svn";
378 my $root_url = get_root_url();
380 my @paths = merge_modules(@{$args{mods}});
382 foreach my $paths (@paths)
384 my @path_elems = split /\/+/, $paths;
385 my $last_elem = pop @path_elems;
388 foreach my $pe (@path_elems)
390 if (! -d "$path/$pe")
392 # if we find something from path_roots then switch to that
393 my $changed_path = convert_path("$path/$pe", 0,
394 %{$args{conf}{path_roots}});
396 print "Creating $path/$pe\n";
397 print " from $changed_path\n" if defined $changed_path;
399 # there's some other little problem with the 'depth' thing
400 # when we do checkout some specific list of files (and dirs),
401 # we need to use depth=empty so that we only get those
402 # specific files out of the directory, on the other side we'd
403 # (probably) like to have updates on the directory contents
404 # when we do 'svn up' which would would with depth=files (or
406 # As the first thing is merely only needed when doing a
407 # checkout for another repo... let's have a config option.
409 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
411 if (defined $changed_path)
413 my $cmd = "cd $path && svn co -r '$svnrev' --depth empty $root_url/$changed_path $pe";
414 #print "cmd: $cmd\n";
416 die "svn co failed" if $?;
420 my $cmd = "cd $path && svn update -q -r '$svnrev' --depth empty $pe";
421 #print "cmd: $cmd\n";
423 die "svn update failed" if $?;
430 print "Getting sources\n";
431 my $c = "svn update -r '$svnrev' --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
434 die "svn update failed" if $?;
440 return undef unless defined $fn;
442 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
444 $blob = `svn -r '$svnrev' cat $fn`;
458 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
459 do_checkout(conf => { %conf }, mods => [ @_ ]);
462 sub fix_repomgr_path(%)
465 # fix the path to the repomgr...
466 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
467 if defined $conf{repomgr_prefix};
472 my $repo_root = shift;
474 my $localdir = 'src';
476 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
483 elsif ($_[0] eq '-l')
490 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
491 if not defined $repo_root or not defined $repo_conf
492 or not defined $localdir;
494 # for absolute path we assume a local config file, good for testing
496 if ($repo_conf ne '')
498 if ($repo_conf =~ /^\//)
500 $confblob = read_file($repo_conf);
501 die "Cannot open '$repo_conf': $!" unless defined $confblob;
505 my $cmd = "svn cat -r '$svnrev' $repo_root\/$repo_conf";
507 die "Command '$cmd' failed" if $?;
511 my %conf = init_config($confblob);
513 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
514 print "localdir: $localdir\n";
516 my $cmd = "svn co -r '$svnrev' --depth empty $repo_root/$conf{base} $localdir";
518 die "Command '$cmd' failed" if $?;
521 fix_repomgr_path(%conf);
522 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
527 foreach (sort keys %modules)
529 print "$_\n" if defined $modules{$_}{pub_module};
535 print "$_\n" foreach merge_modules(@_);
538 sub command_listmapped
540 my $blob = read_file(shift);
541 die "Need config" unless defined $blob;
542 my %conf = init_config($blob);
543 fix_repomgr_path(%conf);
544 print join("\n", map {
545 my $p = convert_path($_, 1, %{$conf{path_roots}});
546 defined $p ? $p : $_;
547 } merge_modules(@_));
553 help => { func => \&command_help, },
554 init => { func => \&command_init, },
555 update => { func => \&command_update, },
556 up => { func => \&command_update, alias => 'update' },
557 checkout => { func => \&command_checkout, public => 1},
558 co => { func => \&command_checkout, alias => 'checkout'},
559 modules => { func => \&command_modules, public => 1},
560 list => { func => \&command_list, },
561 listmapped=> { func => \&command_listmapped, },
562 root => { func => \&command_root, },
565 # ----------------------------------------------------------------
567 check_module_structure();
571 unless (defined $command)
577 if (defined $commands{$command})
579 &{$commands{$command}{func}}(@ARGV);
583 print "Unknown command '$command'.\n";