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-minimal
43 libsupc++ libsupc++-minimal
44 libvbus 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-io libvcpu lxfuxlibc rtc shmc
57 modules => [ qw(l4re) ],
62 paths => [ qw(l4/pkg/hello),
63 map { "l4/pkg/examples/$_" }
88 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
91 paths => [ map { "l4/pkg/$_" }
152 modules => [ qw(l4re examples doc toolbin) ] },
154 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
155 modules => [ qw(l4re_snapshot) ] },
158 paths => [ qw(tools/preprocess) ]
163 paths => [ qw(kernel/fiasco/BENCHMARKING
164 kernel/fiasco/COPYING
165 kernel/fiasco/MAINTAINER
166 kernel/fiasco/Makefile
171 modules => [ qw(preprocess) ],
175 paths => [ qw(kernel/Makefile) ],
179 paths => [ qw(grub) ],
182 remote_repo_l4re => {
183 modules => [ qw(l4re_snapshot) ],
186 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ],
187 # those are going away, we need to keep them to get the
188 # dirs updated and thus removed
189 paths => [ qw(l4/pkg/libstdc++-v3_r
195 modules => [ qw(remote_repo) ],
203 my $o = `svn info --xml .`;
204 die "Failed 'svn info'." if $?;
205 $o =~ /<root>(.+)<\/root>/m;
215 my $pathsref = shift;
218 die "Possible looping in modules structure detected!" unless $count;
222 die "Unknown module '$m' referenced!" unless defined $modules{$m};
223 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
224 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
228 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
233 sub show_pub_modules()
235 print "Available modules:\n";
236 foreach (sort keys %modules)
238 print " $_\n" if $modules{$_}{pub_module};
247 $command = $commands{$command}{alias}
248 if defined $command and defined $commands{$command}{alias};
250 if (!defined $command or $command eq 'help')
252 print "$0 command [option]\n";
254 print "Available commands, use '$0 help command' for help on the command:\n";
255 foreach (sort keys %commands)
257 print " $_\n" if defined $commands{$_}{public};
260 elsif ($command eq 'update')
262 print " 'update' will update in the following way:\n".
263 " update itself and re-exec if necessary\n".
264 " call 'make update' in l4/pkg\n".
265 " call 'svn update' every directory in kernel\n";
267 elsif ($command eq 'checkout')
269 print " 'checkout' will check out the given modules.\n";
272 elsif ($command eq 'modules')
278 print " No such command '$command'.\n";
282 sub check_module_structure()
284 # make sure the paths look ok
285 foreach (merge_modules())
287 die "Trailing /'s in modules structure" if /\/$/;
288 die "Double // detected in modules structure" if /\/\//;
306 die "Need to give URL" unless defined $url and defined $dirname;
307 system("svn co $url --depth empty $dirname");
312 my $config_blob = shift;
313 $config_blob = '{}' unless defined $config_blob;
315 unless ($c = eval($config_blob))
317 die "Couldn't parse config file: $@" if $@;
318 die "Couldn't do config file: $!" if $!;
319 die "Couldn't run config file";
324 $a{base} = "trunk" unless defined $a{base};
329 sub convert_path($$%)
332 my $partmatch = shift;
337 foreach my $key (keys %path_roots)
340 $r .= '/' unless $r =~ /\/$/;
343 # for partly matches we also need to return the modified path
344 # because otherwise we can't really know
345 if ($p =~ /^($r)(.*)$/)
347 my $s = $path_roots{$key}.'/'.$2;
348 # strip off last / again, it's just used for matching
349 return substr($s, 0, length($s) - 1);
354 return $path_roots{$key} if $p =~ /^$r$/;
363 unless (defined ${$args{mods}}[0])
365 print "Supply module to check out.\n";
370 die "Current directory is no SVN WC" unless -d ".svn";
372 my $root_url = get_root_url();
374 my $rev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
376 my @paths = merge_modules(@{$args{mods}});
378 foreach my $paths (@paths)
380 my @path_elems = split /\/+/, $paths;
381 my $last_elem = pop @path_elems;
384 foreach my $pe (@path_elems)
386 if (! -d "$path/$pe/.svn")
388 # if we find something from path_roots then switch to that
389 my $changed_path = convert_path("$path/$pe", 0,
390 %{$args{conf}{path_roots}});
392 print "Creating $path/$pe\n";
393 print " from $changed_path\n" if defined $changed_path;
395 # there's some other little problem with the 'depth' thing
396 # when we do checkout some specific list of files (and dirs),
397 # we need to use depth=empty so that we only get those
398 # specific files out of the directory, on the other side we'd
399 # (probably) like to have updates on the directory contents
400 # when we do 'svn up' which would would with depth=files (or
402 # As the first thing is merely only needed when doing a
403 # checkout for another repo... let's have a config option.
405 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
407 if (defined $changed_path)
409 my $cmd = "cd $path && svn co -r $rev --depth empty $root_url/$changed_path $pe";
410 #print "cmd: $cmd\n";
412 die "svn co failed" if $?;
416 my $cmd = "cd $path && svn update -r $rev --depth empty $pe";
417 #print "cmd: $cmd\n";
419 die "svn update failed" if $?;
426 print "Getting sources\n";
427 my $c = "svn update -r $rev --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
430 die "svn update failed" if $?;
436 return undef unless defined $fn;
438 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
440 $blob = `svn cat $fn`;
454 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
455 do_checkout(conf => { %conf }, mods => [ @_ ]);
458 sub fix_repomgr_path(%)
461 # fix the path to the repomgr...
462 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
463 if defined $conf{repomgr_prefix};
468 my $repo_root = shift;
470 my $localdir = 'src';
472 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
479 elsif ($_[0] eq '-l')
486 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
487 if not defined $repo_root or not defined $repo_conf
488 or not defined $localdir;
490 # for absolute path we assume a local config file, good for testing
492 if ($repo_conf ne '')
494 if ($repo_conf =~ /^\//)
496 $confblob = read_file($repo_conf);
497 die "Cannot open '$repo_conf': $!" unless defined $confblob;
501 my $cmd = "svn cat $repo_root\/$repo_conf";
503 die "Command '$cmd' failed" if $?;
507 my %conf = init_config($confblob);
509 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
510 print "localdir: $localdir\n";
512 my $cmd = "svn co --depth empty $repo_root/$conf{base} $localdir";
514 die "Command '$cmd' failed" if $?;
517 fix_repomgr_path(%conf);
518 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
523 foreach (sort keys %modules)
525 print "$_\n" if defined $modules{$_}{pub_module};
531 print "$_\n" foreach merge_modules(@_);
534 sub command_listmapped
536 my $blob = read_file(shift);
537 die "Need config" unless defined $blob;
538 my %conf = init_config($blob);
539 fix_repomgr_path(%conf);
540 print join("\n", map {
541 my $p = convert_path($_, 1, %{$conf{path_roots}});
542 defined $p ? $p : $_;
543 } merge_modules(@_));
549 help => { func => \&command_help, },
550 init => { func => \&command_init, },
551 update => { func => \&command_update, },
552 up => { func => \&command_update, alias => 'update' },
553 checkout => { func => \&command_checkout, public => 1},
554 co => { func => \&command_checkout, alias => 'checkout'},
555 modules => { func => \&command_modules, public => 1},
556 list => { func => \&command_list, },
557 listmapped=> { func => \&command_listmapped, },
558 root => { func => \&command_root, },
561 # ----------------------------------------------------------------
563 check_module_structure();
567 unless (defined $command)
573 if (defined $commands{$command})
575 &{$commands{$command}{func}}(@ARGV);
579 print "Unknown command '$command'.\n";