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 libedid 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/$_" }
168 modules => [ qw(l4re examples_all doc toolbin) ] },
170 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
171 modules => [ qw(l4re_snapshot) ] },
175 paths => [ qw(kernel/fiasco/BENCHMARKING
176 kernel/fiasco/COPYING
177 kernel/fiasco/MAINTAINER
178 kernel/fiasco/Makefile
186 paths => [ qw(kernel/Makefile) ],
190 paths => [ qw(grub) ],
193 remote_repo_l4re => {
194 modules => [ qw(l4re_snapshot) ],
197 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ],
198 # those are going away, we need to keep them to get the
199 # dirs updated and thus removed
200 paths => [ qw(l4/pkg/libstdc++-v3_r
206 modules => [ qw(remote_repo) ],
211 my $svnrev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
215 my $o = `svn info -r '$svnrev' --xml .`;
216 die "Failed 'svn info'." if $?;
217 $o =~ /<root>(.+)<\/root>/m;
227 my $pathsref = shift;
230 die "Possible looping in modules structure detected!" unless $count;
234 die "Unknown module '$m' referenced!" unless defined $modules{$m};
235 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
236 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
240 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
245 sub show_pub_modules()
247 print "Available modules:\n";
248 foreach (sort keys %modules)
250 print " $_\n" if $modules{$_}{pub_module};
259 $command = $commands{$command}{alias}
260 if defined $command and defined $commands{$command}{alias};
262 if (!defined $command or $command eq 'help')
264 print "$0 command [option]\n";
266 print "Available commands, use '$0 help command' for help on the command:\n";
267 foreach (sort keys %commands)
269 print " $_\n" if defined $commands{$_}{public};
272 elsif ($command eq 'update')
274 print " 'update' will update in the following way:\n".
275 " update itself and re-exec if necessary\n".
276 " call 'make update' in l4/pkg\n".
277 " call 'svn update' every directory in kernel\n";
279 elsif ($command eq 'checkout')
281 print " 'checkout' will check out the given modules.\n";
284 elsif ($command eq 'modules')
290 print " No such command '$command'.\n";
294 sub check_module_structure()
296 # make sure the paths look ok
297 foreach (merge_modules())
299 die "Trailing /'s in modules structure" if /\/$/;
300 die "Double // detected in modules structure" if /\/\//;
318 die "Need to give URL" unless defined $url and defined $dirname;
319 system("svn co -r '$svnrev' $url --depth empty $dirname");
324 my $config_blob = shift;
325 $config_blob = '{}' unless defined $config_blob;
327 unless ($c = eval($config_blob))
329 die "Couldn't parse config file: $@" if $@;
330 die "Couldn't do config file: $!" if $!;
331 die "Couldn't run config file";
336 $a{base} = "trunk" unless defined $a{base};
341 sub convert_path($$%)
344 my $partmatch = shift;
349 foreach my $key (keys %path_roots)
352 $r .= '/' unless $r =~ /\/$/;
355 # for partly matches we also need to return the modified path
356 # because otherwise we can't really know
357 if ($p =~ /^($r)(.*)$/)
359 my $s = $path_roots{$key}.'/'.$2;
360 # strip off last / again, it's just used for matching
361 return substr($s, 0, length($s) - 1);
366 return $path_roots{$key} if $p =~ /^$r$/;
375 unless (defined ${$args{mods}}[0])
377 print "Supply module to check out.\n";
382 die "Current directory is no SVN WC" unless -d ".svn";
384 my $root_url = get_root_url();
386 my @paths = merge_modules(@{$args{mods}});
388 foreach my $paths (@paths)
390 my @path_elems = split /\/+/, $paths;
391 my $last_elem = pop @path_elems;
394 foreach my $pe (@path_elems)
396 if (! -d "$path/$pe")
398 # if we find something from path_roots then switch to that
399 my $changed_path = convert_path("$path/$pe", 0,
400 %{$args{conf}{path_roots}});
402 print "Creating $path/$pe\n";
403 print " from $changed_path\n" if defined $changed_path;
405 # there's some other little problem with the 'depth' thing
406 # when we do checkout some specific list of files (and dirs),
407 # we need to use depth=empty so that we only get those
408 # specific files out of the directory, on the other side we'd
409 # (probably) like to have updates on the directory contents
410 # when we do 'svn up' which would would with depth=files (or
412 # As the first thing is merely only needed when doing a
413 # checkout for another repo... let's have a config option.
415 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
417 if (defined $changed_path)
419 my $cmd = "cd $path && svn co -r '$svnrev' --depth empty $root_url/$changed_path $pe";
420 #print "cmd: $cmd\n";
422 die "svn co failed" if $?;
426 my $cmd = "cd $path && svn update -q -r '$svnrev' --depth empty $pe";
427 #print "cmd: $cmd\n";
429 die "svn update failed" if $?;
436 print "Getting sources\n";
437 my $c = "svn update -r '$svnrev' --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
440 die "svn update failed" if $?;
446 return undef unless defined $fn;
448 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
450 $blob = `svn -r '$svnrev' cat $fn`;
464 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
465 do_checkout(conf => { %conf }, mods => [ @_ ]);
468 sub fix_repomgr_path(%)
471 # fix the path to the repomgr...
472 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
473 if defined $conf{repomgr_prefix};
478 my $repo_root = shift;
480 my $localdir = 'src';
482 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
489 elsif ($_[0] eq '-l')
496 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
497 if not defined $repo_root or not defined $repo_conf
498 or not defined $localdir;
500 # for absolute path we assume a local config file, good for testing
502 if ($repo_conf ne '')
504 if ($repo_conf =~ /^\//)
506 $confblob = read_file($repo_conf);
507 die "Cannot open '$repo_conf': $!" unless defined $confblob;
511 my $cmd = "svn cat -r '$svnrev' $repo_root\/$repo_conf";
513 die "Command '$cmd' failed" if $?;
517 my %conf = init_config($confblob);
519 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
520 print "localdir: $localdir\n";
522 my $cmd = "svn co -r '$svnrev' --depth empty $repo_root/$conf{base} $localdir";
524 die "Command '$cmd' failed" if $?;
527 fix_repomgr_path(%conf);
528 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
533 foreach (sort keys %modules)
535 print "$_\n" if defined $modules{$_}{pub_module};
541 print "$_\n" foreach merge_modules(@_);
544 sub command_listmapped
546 my $blob = read_file(shift);
547 die "Need config" unless defined $blob;
548 my %conf = init_config($blob);
549 fix_repomgr_path(%conf);
550 print join("\n", map {
551 my $p = convert_path($_, 1, %{$conf{path_roots}});
552 defined $p ? $p : $_;
553 } merge_modules(@_));
559 help => { func => \&command_help, },
560 init => { func => \&command_init, },
561 update => { func => \&command_update, },
562 up => { func => \&command_update, alias => 'update' },
563 checkout => { func => \&command_checkout, public => 1},
564 co => { func => \&command_checkout, alias => 'checkout'},
565 modules => { func => \&command_modules, public => 1},
566 list => { func => \&command_list, },
567 listmapped=> { func => \&command_listmapped, },
568 root => { func => \&command_root, },
571 # ----------------------------------------------------------------
573 check_module_structure();
577 unless (defined $command)
583 if (defined $commands{$command})
585 &{$commands{$command}{func}}(@ARGV);
589 print "Unknown command '$command'.\n";