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 crtn cxx cxx_libc_io cxx_thread
38 l4re l4re_c l4re_kernel l4re_vfs l4sys l4util
40 libc_backends libkproxy libloader
42 libstdc++-headers libstdc++-v3 libstdc++-v3_r
44 libvbus loader log lua moe ned sigma0
48 modules => [ qw(bid toolbin) ],
51 # ./mk/pkgdeps -A mk/aliases.d pkgdeps pkg rtc shmc libvcpu stdlibs log
54 => { paths => [ map { "l4/pkg/$_" } qw(
55 crtn cxx cxx_libc_io l4re l4re_c l4re_vfs l4sys l4util
56 ldscripts libc_backends libio-io libstdc++-headers
57 libstdc++-v3 libsupc++ libvbus libvcpu log lxfuxlibc rtc
61 modules => [ qw(l4re) ],
66 paths => [ qw(l4/pkg/hello),
67 map { "l4/pkg/examples/$_" }
92 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
95 paths => [ map { "l4/pkg/$_" }
156 modules => [ qw(l4re examples doc toolbin) ] },
158 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
159 modules => [ qw(l4re_snapshot) ] },
162 paths => [ qw(tools/preprocess) ]
167 paths => [ qw(kernel/fiasco/BENCHMARKING
168 kernel/fiasco/COPYING
169 kernel/fiasco/MAINTAINER
170 kernel/fiasco/Makefile
175 modules => [ qw(preprocess) ],
179 paths => [ qw(kernel/Makefile) ],
183 paths => [ qw(grub) ],
186 remote_repo_l4re => {
187 modules => [ qw(l4re_snapshot) ],
190 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ], },
193 modules => [ qw(remote_repo) ],
201 my $o = `svn info --xml .`;
202 die "Failed 'svn info'." if $?;
203 $o =~ /<root>(.+)<\/root>/m;
213 my $pathsref = shift;
216 die "Possible looping in modules structure detected!" unless $count;
220 die "Unknown module '$m' referenced!" unless defined $modules{$m};
221 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
222 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
226 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
231 sub show_pub_modules()
233 print "Available modules:\n";
234 foreach (sort keys %modules)
236 print " $_\n" if $modules{$_}{pub_module};
245 $command = $commands{$command}{alias}
246 if defined $command and defined $commands{$command}{alias};
248 if (!defined $command or $command eq 'help')
250 print "$0 command [option]\n";
252 print "Available commands, use '$0 help command' for help on the command:\n";
253 foreach (sort keys %commands)
255 print " $_\n" if defined $commands{$_}{public};
258 elsif ($command eq 'update')
260 print " 'update' will update in the following way:\n".
261 " update itself and re-exec if necessary\n".
262 " call 'make update' in l4/pkg\n".
263 " call 'svn update' every directory in kernel\n";
265 elsif ($command eq 'checkout')
267 print " 'checkout' will check out the given modules.\n";
270 elsif ($command eq 'modules')
276 print " No such command '$command'.\n";
280 sub check_module_structure()
282 # make sure the paths look ok
283 foreach (merge_modules())
285 die "Trailing /'s in modules structure" if /\/$/;
286 die "Double // detected in modules structure" if /\/\//;
304 die "Need to give URL" unless defined $url and defined $dirname;
305 system("svn co $url --depth empty $dirname");
310 my $config_blob = shift;
311 $config_blob = '{}' unless defined $config_blob;
313 unless ($c = eval($config_blob))
315 die "Couldn't parse config file: $@" if $@;
316 die "Couldn't do config file: $!" if $!;
317 die "Couldn't run config file";
322 $a{base} = "trunk" unless defined $a{base};
327 sub convert_path($$%)
330 my $partmatch = shift;
335 foreach my $key (keys %path_roots)
338 $r .= '/' unless $r =~ /\/$/;
341 # for partly matches we also need to return the modified path
342 # because otherwise we can't really know
343 if ($p =~ /^($r)(.*)$/)
345 my $s = $path_roots{$key}.'/'.$2;
346 # strip off last / again, it's just used for matching
347 return substr($s, 0, length($s) - 1);
352 return $path_roots{$key} if $p =~ /^$r$/;
361 unless (defined ${$args{mods}}[0])
363 print "Supply module to check out.\n";
368 die "Current directory is no SVN WC" unless -d ".svn";
370 my $root_url = get_root_url();
372 my $rev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
374 my @paths = merge_modules(@{$args{mods}});
376 foreach my $paths (@paths)
378 my @path_elems = split /\/+/, $paths;
379 my $last_elem = pop @path_elems;
382 foreach my $pe (@path_elems)
384 if (! -d "$path/$pe/.svn")
386 # if we find something from path_roots then switch to that
387 my $changed_path = convert_path("$path/$pe", 0,
388 %{$args{conf}{path_roots}});
390 print "Creating $path/$pe\n";
391 print " from $changed_path\n" if defined $changed_path;
393 # there's some other little problem with the 'depth' thing
394 # when we do checkout some specific list of files (and dirs),
395 # we need to use depth=empty so that we only get those
396 # specific files out of the directory, on the other side we'd
397 # (probably) like to have updates on the directory contents
398 # when we do 'svn up' which would would with depth=files (or
400 # As the first thing is merely only needed when doing a
401 # checkout for another repo... let's have a config option.
403 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
405 if (defined $changed_path)
407 my $cmd = "cd $path && svn co -r $rev --depth empty $root_url/$changed_path $pe";
408 #print "cmd: $cmd\n";
410 die "svn co failed" if $?;
414 my $cmd = "cd $path && svn update -r $rev --depth empty $pe";
415 #print "cmd: $cmd\n";
417 die "svn update failed" if $?;
424 print "Getting sources\n";
425 my $c = "svn update -r $rev --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
428 die "svn update failed" if $?;
434 return undef unless defined $fn;
436 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
438 $blob = `svn cat $fn`;
452 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
453 do_checkout(conf => { %conf }, mods => [ @_ ]);
456 sub fix_repomgr_path(%)
459 # fix the path to the repomgr...
460 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
461 if defined $conf{repomgr_prefix};
466 my $repo_root = shift;
468 my $localdir = 'src';
470 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
477 elsif ($_[0] eq '-l')
484 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
485 if not defined $repo_root or not defined $repo_conf
486 or not defined $localdir;
488 # for absolute path we assume a local config file, good for testing
490 if ($repo_conf ne '')
492 if ($repo_conf =~ /^\//)
494 $confblob = read_file($repo_conf);
495 die "Cannot open '$repo_conf': $!" unless defined $confblob;
499 my $cmd = "svn cat $repo_root\/$repo_conf";
501 die "Command '$cmd' failed" if $?;
505 my %conf = init_config($confblob);
507 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
508 print "localdir: $localdir\n";
510 my $cmd = "svn co --depth empty $repo_root/$conf{base} $localdir";
512 die "Command '$cmd' failed" if $?;
515 fix_repomgr_path(%conf);
516 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
521 foreach (sort keys %modules)
523 print "$_\n" if defined $modules{$_}{pub_module};
529 print "$_\n" foreach merge_modules(@_);
532 sub command_listmapped
534 my $blob = read_file(shift);
535 die "Need config" unless defined $blob;
536 my %conf = init_config($blob);
537 fix_repomgr_path(%conf);
538 print join("\n", map {
539 my $p = convert_path($_, 1, %{$conf{path_roots}});
540 defined $p ? $p : $_;
541 } merge_modules(@_));
547 help => { func => \&command_help, },
548 init => { func => \&command_init, },
549 update => { func => \&command_update, },
550 up => { func => \&command_update, alias => 'update' },
551 checkout => { func => \&command_checkout, public => 1},
552 co => { func => \&command_checkout, alias => 'checkout'},
553 modules => { func => \&command_modules, public => 1},
554 list => { func => \&command_list, },
555 listmapped=> { func => \&command_listmapped, },
556 root => { func => \&command_root, },
559 # ----------------------------------------------------------------
561 check_module_structure();
565 unless (defined $command)
571 if (defined $commands{$command})
573 &{$commands{$command}{func}}(@ARGV);
577 print "Unknown command '$command'.\n";