7 repomgr => { paths => [ qw(repomgr) ] },
9 bid => { paths => [ qw(l4/Makefile
28 toolbin => { paths => [ map { "l4/tool/bin/$_" }
29 qw(isocreator qemu-x86-launch ux-launch
30 gengrub1iso gengrub2iso entry-selector
31 mkspafs genexportpack gen_kconfig
35 l4re => { paths => [ map { "l4/pkg/$_" } qw(
36 bootstrap l4re-core/libgcc
38 l4re-core/crtn l4re-core/cxx l4re-core/cxx_libc_io
40 l4re-core/l4re/ l4re-core/l4re_c/
41 l4re-core/l4re_kernel/ l4re-core/l4re_vfs/
42 l4re-core/l4sys/ l4re-core/l4util/
44 l4re-core/libc_backends l4re-core/libkproxy/
47 l4re-core/libstdc++-headers/ l4re-core/libstdc++-v3/
48 l4re-core/libstdc++-v3-minimal
49 l4re-core/libsupc++ l4re-core/libsupc++-minimal
51 l4re-core/moe l4re-core/ned/ l4re-core/sigma0/
52 l4re-core/uclibc l4re-core/uclibc-minimal/
53 l4re-core/uclibc-headers/
56 cxx_thread drivers-frst hello
57 acpica libvcpu loader log
60 modules => [ qw(bid toolbin) ],
64 # ./mk/pkgdeps -A mk/aliases.d pkgdeps pkg ...
66 => { paths => [ map { "l4/pkg/$_" } qw(
67 libedid lxfuxlibc rtc shmc
68 drivers fb-drv x86emu input libirq
71 modules => [ qw(l4re) ],
75 paths => [ qw(l4/pkg/hello),
76 map { "l4/pkg/examples/$_" }
91 modules => [ qw(examples_core) ],
92 paths => [ qw(l4/pkg/hello),
93 map { "l4/pkg/examples/$_" }
101 libs/libc_thread_safe
111 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
114 paths => [ map { "l4/pkg/$_" }
178 modules => [ qw(l4re examples_all doc toolbin) ] },
180 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
181 modules => [ qw(l4re_snapshot) ] },
185 paths => [ qw(kernel/fiasco/BENCHMARKING
186 kernel/fiasco/COPYING
187 kernel/fiasco/MAINTAINER
188 kernel/fiasco/Makefile
196 paths => [ qw(kernel/Makefile) ],
200 paths => [ qw(grub) ],
203 remote_repo_l4re => {
204 modules => [ qw(l4re_snapshot) ],
207 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ] },
210 modules => [ qw(remote_repo) ],
214 # those are going away, we need to keep them to get the
215 # dirs updated and thus removed
217 paths => [ map { "l4/pkg/$_" }
218 qw(ferret io libio libio-io libio-direct ocaml_toys
219 libstdc++-v3_r libsupc++_r uclibc_r
221 boehm_gc libgcc libgcc-pure libbsd-full
222 crtn cxx cxx_libc_io cxx_thread
224 l4re/ l4re_c l4re_kernel l4re_vfs l4sys l4util
226 libc_backends libkproxy libloader
228 libstdc++-headers libstdc++-v3 libstdc++-v3-minimal
229 libsupc++ libsupc++-minimal
230 libvbus lua moe ned sigma0
231 uclibc uclibc-minimal uclibc-headers
238 my $svnrev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
242 my $o = `svn info -r '$svnrev' --xml .`;
243 die "Failed 'svn info'." if $?;
244 $o =~ /<root>(.+)<\/root>/m;
254 my $pathsref = shift;
257 die "Possible looping in modules structure detected!" unless $count;
261 die "Unknown module '$m' referenced!" unless defined $modules{$m};
262 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
263 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
267 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
272 sub show_pub_modules()
274 print "Available modules:\n";
275 foreach (sort keys %modules)
277 print " $_\n" if $modules{$_}{pub_module};
286 $command = $commands{$command}{alias}
287 if defined $command and defined $commands{$command}{alias};
289 if (!defined $command or $command eq 'help')
291 print "$0 command [option]\n";
293 print "Available commands, use '$0 help command' for help on the command:\n";
294 foreach (sort keys %commands)
296 print " $_\n" if defined $commands{$_}{public};
299 elsif ($command eq 'update')
301 print " 'update' will update in the following way:\n".
302 " update itself and re-exec if necessary\n".
303 " call 'make update' in l4/pkg\n".
304 " call 'svn update' every directory in kernel\n";
306 elsif ($command eq 'checkout')
308 print " 'checkout' will check out the given modules.\n";
311 elsif ($command eq 'modules')
317 print " No such command '$command'.\n";
321 sub check_module_structure()
323 # make sure the paths look ok
324 foreach (merge_modules())
326 #die "Trailing /'s in modules structure" if /\/$/;
327 die "Double // detected in modules structure" if /\/\//;
345 die "Need to give URL" unless defined $url and defined $dirname;
346 system("svn co -r '$svnrev' $url --depth empty $dirname");
351 my $config_blob = shift;
352 $config_blob = '{}' unless defined $config_blob;
354 unless ($c = eval($config_blob))
356 die "Couldn't parse config file: $@" if $@;
357 die "Couldn't do config file: $!" if $!;
358 die "Couldn't run config file";
363 $a{base} = "trunk" unless defined $a{base};
368 sub convert_path($$%)
371 my $partmatch = shift;
376 foreach my $key (keys %path_roots)
379 $r .= '/' unless $r =~ /\/$/;
382 # for partly matches we also need to return the modified path
383 # because otherwise we can't really know
384 if ($p =~ /^($r)(.*)$/)
386 my $s = $path_roots{$key}.'/'.$2;
387 # strip off last / again, it's just used for matching
388 return substr($s, 0, length($s) - 1);
393 return $path_roots{$key} if $p =~ /^$r$/;
402 unless (defined ${$args{mods}}[0])
404 print "Supply module to check out.\n";
409 die "Current directory is no SVN WC" unless -d ".svn";
411 my $root_url = get_root_url();
413 my @paths = merge_modules(@{$args{mods}});
415 foreach my $paths (@paths)
417 my @path_elems = split /\/+/, $paths;
418 my $last_elem = pop @path_elems;
421 foreach my $pe (@path_elems)
423 if (! -d "$path/$pe")
425 # if we find something from path_roots then switch to that
426 my $changed_path = convert_path("$path/$pe", 0,
427 %{$args{conf}{path_roots}});
429 print "Creating $path/$pe\n";
430 print " from $changed_path\n" if defined $changed_path;
432 # there's some other little problem with the 'depth' thing
433 # when we do checkout some specific list of files (and dirs),
434 # we need to use depth=empty so that we only get those
435 # specific files out of the directory, on the other side we'd
436 # (probably) like to have updates on the directory contents
437 # when we do 'svn up' which would would with depth=files (or
439 # As the first thing is merely only needed when doing a
440 # checkout for another repo... let's have a config option.
442 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
444 if (defined $changed_path)
446 my $cmd = "cd $path && svn co -r '$svnrev' --depth empty $root_url/$changed_path $pe";
447 #print "cmd: $cmd\n";
449 die "svn co failed" if $?;
453 my $cmd = "cd $path && svn update -q -r '$svnrev' --depth empty $pe";
454 #print "cmd: $cmd\n";
456 die "svn update failed" if $?;
463 print "Getting sources\n";
464 my $c = "svn update -r '$svnrev' --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
467 die "svn update failed" if $?;
473 return undef unless defined $fn;
475 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
477 $blob = `svn -r '$svnrev' cat $fn`;
491 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
492 do_checkout(conf => { %conf }, mods => [ @_ ]);
495 sub fix_repomgr_path(%)
498 # fix the path to the repomgr...
499 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
500 if defined $conf{repomgr_prefix};
505 my $repo_root = shift;
507 my $localdir = 'src';
509 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
516 elsif ($_[0] eq '-l')
523 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
524 if not defined $repo_root or not defined $repo_conf
525 or not defined $localdir;
527 # for absolute path we assume a local config file, good for testing
529 if ($repo_conf ne '')
531 if ($repo_conf =~ /^\//)
533 $confblob = read_file($repo_conf);
534 die "Cannot open '$repo_conf': $!" unless defined $confblob;
538 my $cmd = "svn cat -r '$svnrev' $repo_root\/$repo_conf";
540 die "Command '$cmd' failed" if $?;
544 my %conf = init_config($confblob);
546 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
547 print "localdir: $localdir\n";
549 my $cmd = "svn co -r '$svnrev' --depth empty $repo_root/$conf{base} $localdir";
551 die "Command '$cmd' failed" if $?;
554 fix_repomgr_path(%conf);
555 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
560 foreach (sort keys %modules)
562 print "$_\n" if defined $modules{$_}{pub_module};
568 print "$_\n" foreach merge_modules(@_);
571 sub command_listmapped
573 my $blob = read_file(shift);
574 die "Need config" unless defined $blob;
575 my %conf = init_config($blob);
576 fix_repomgr_path(%conf);
577 print join("\n", map {
578 my $p = convert_path($_, 1, %{$conf{path_roots}});
579 defined $p ? $p : $_;
580 } merge_modules(@_));
586 help => { func => \&command_help, },
587 init => { func => \&command_init, },
588 update => { func => \&command_update, },
589 up => { func => \&command_update, alias => 'update' },
590 checkout => { func => \&command_checkout, public => 1},
591 co => { func => \&command_checkout, alias => 'checkout'},
592 modules => { func => \&command_modules, public => 1},
593 list => { func => \&command_list, },
594 listmapped=> { func => \&command_listmapped, },
595 root => { func => \&command_root, },
598 # ----------------------------------------------------------------
600 check_module_structure();
604 unless (defined $command)
610 if (defined $commands{$command})
612 &{$commands{$command}{func}}(@ARGV);
616 print "Unknown command '$command'.\n";