7 repomgr => { paths => [ qw(repomgr conf/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) ],
52 paths => [ qw(l4/pkg/hello),
53 map { "l4/pkg/examples/$_" }
76 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
79 paths => [ map { "l4/pkg/$_" }
137 modules => [ qw(l4re examples doc toolbin) ] },
139 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
140 modules => [ qw(l4re_snapshot) ] },
143 paths => [ qw(tools/preprocess) ]
148 paths => [ qw(kernel/fiasco/BENCHMARKING
149 kernel/fiasco/COPYING
150 kernel/fiasco/MAINTAINER
151 kernel/fiasco/Makefile
156 modules => [ qw(preprocess) ],
160 paths => [ qw(kernel/Makefile) ],
164 paths => [ qw(grub) ],
167 remote_repo_l4re => {
168 modules => [ qw(l4re_snapshot) ],
171 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ], },
174 modules => [ qw(remote_repo) ],
182 my $o = `svn info --xml .`;
183 die "Failed 'svn info'." if $?;
184 $o =~ /<root>(.+)<\/root>/m;
194 my $pathsref = shift;
197 die "Possible looping in modules structure detected!" unless $count;
201 die "Unknown module '$m' referenced!" unless defined $modules{$m};
202 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
203 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
207 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
217 $command = $commands{$command}{alias}
218 if defined $command and defined $commands{$command}{alias};
220 if (!defined $command or $command eq 'help')
222 print "$0 command [option]\n";
224 print "Available commands, use '$0 help command' for help on the command:\n";
225 foreach (sort keys %commands)
227 print " $_\n" if defined $commands{$_}{public};
230 elsif ($command eq 'update')
232 print " 'update' will update in the following way:\n".
233 " update itself and re-exec if necessary\n".
234 " call 'make update' in l4/pkg\n".
235 " call 'svn update' every directory in kernel\n";
237 elsif ($command eq 'checkout')
239 print " 'checkout' will check out the given modules.\n";
240 print "Available modules:\n";
241 foreach (sort keys %modules)
243 print " $_\n" if $modules{$_}{pub_module};
248 print " No such command '$command'.\n";
252 sub check_module_structure()
254 # make sure the paths look ok
255 foreach (merge_modules())
257 die "Trailing /'s in modules structure" if /\/$/;
258 die "Double // detected in modules structure" if /\/\//;
276 die "Need to give URL" unless defined $url and defined $dirname;
277 system("svn co $url --depth empty $dirname");
282 my $config_blob = shift;
283 $config_blob = '{}' unless defined $config_blob;
285 unless ($c = eval($config_blob))
287 die "Couldn't parse config file: $@" if $@;
288 die "Couldn't do config file: $!" if $!;
289 die "Couldn't run config file";
294 $a{base} = "trunk" unless defined $a{base};
299 sub convert_path($$%)
302 my $partmatch = shift;
307 foreach my $key (keys %path_roots)
310 $r .= '/' unless $r =~ /\/$/;
313 # for partly matches we also need to return the modified path
314 # because otherwise we can't really know
315 if ($p =~ /^($r)(.*)$/)
317 my $s = $path_roots{$key}.'/'.$2;
318 # strip off last / again, it's just used for matching
319 return substr($s, 0, length($s) - 1);
324 return $path_roots{$key} if $p =~ /^$r$/;
333 unless (defined ${$args{mods}}[0])
335 print "Supply module to check out.\n";
340 die "Current directory is no SVN WC" unless -d ".svn";
342 my $root_url = get_root_url();
344 my $rev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
346 my @paths = merge_modules(@{$args{mods}});
348 foreach my $paths (@paths)
350 my @path_elems = split /\/+/, $paths;
351 my $last_elem = pop @path_elems;
354 foreach my $pe (@path_elems)
356 if (! -d "$path/$pe/.svn")
358 # if we find something from path_roots then switch to that
359 my $changed_path = convert_path("$path/$pe", 0,
360 %{$args{conf}{path_roots}});
362 print "Creating $path/$pe\n";
363 print " from $changed_path\n" if defined $changed_path;
365 # there's some other little problem with the 'depth' thing
366 # when we do checkout some specific list of files (and dirs),
367 # we need to use depth=empty so that we only get those
368 # specific files out of the directory, on the other side we'd
369 # (probably) like to have updates on the directory contents
370 # when we do 'svn up' which would would with depth=files (or
372 # As the first thing is merely only needed when doing a
373 # checkout for another repo... let's have a config option.
375 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
377 if (defined $changed_path)
379 my $cmd = "cd $path && svn co -r $rev --depth empty $root_url/$changed_path $pe";
380 #print "cmd: $cmd\n";
382 die "svn co failed" if $?;
386 my $cmd = "cd $path && svn update -r $rev --depth empty $pe";
387 #print "cmd: $cmd\n";
389 die "svn update failed" if $?;
396 print "Getting sources\n";
397 my $c = "svn update -r $rev --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
400 die "svn update failed" if $?;
406 return undef unless defined $fn;
408 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
410 $blob = `svn cat $fn`;
424 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
425 do_checkout(conf => { %conf }, mods => [ @_ ]);
428 sub fix_repomgr_path(%)
431 # fix the path to the repomgr...
432 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
433 if defined $conf{repomgr_prefix};
438 my $repo_root = shift;
440 my $localdir = 'src';
442 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
449 elsif ($_[0] eq '-l')
456 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
457 if not defined $repo_root or not defined $repo_conf
458 or not defined $localdir;
460 # for absolute path we assume a local config file, good for testing
462 if ($repo_conf ne '')
464 if ($repo_conf =~ /^\//)
466 $confblob = read_file($repo_conf);
467 die "Cannot open '$repo_conf': $!" unless defined $confblob;
471 my $cmd = "svn cat $repo_root\/$repo_conf";
473 die "Command '$cmd' failed" if $?;
477 my %conf = init_config($confblob);
479 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
480 print "localdir: $localdir\n";
482 my $cmd = "svn co --depth empty $repo_root/$conf{base} $localdir";
484 die "Command '$cmd' failed" if $?;
487 fix_repomgr_path(%conf);
488 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
493 foreach (sort keys %modules)
495 print "$_\n" if defined $modules{$_}{pub_module};
501 print "$_\n" foreach merge_modules(@_);
504 sub command_listmapped
506 my $blob = read_file(shift);
507 die "Need config" unless defined $blob;
508 my %conf = init_config($blob);
509 fix_repomgr_path(%conf);
510 print join("\n", map {
511 my $p = convert_path($_, 1, %{$conf{path_roots}});
512 defined $p ? $p : $_;
513 } merge_modules(@_));
519 help => { func => \&command_help, },
520 init => { func => \&command_init, },
521 update => { func => \&command_update, },
522 up => { func => \&command_update, alias => 'update' },
523 checkout => { func => \&command_checkout, public => 1},
524 co => { func => \&command_checkout, alias => 'checkout'},
525 modules => { func => \&command_modules, public => 1},
526 list => { func => \&command_list, },
527 listmapped=> { func => \&command_listmapped, },
528 root => { func => \&command_root, },
531 # ----------------------------------------------------------------
533 check_module_structure();
537 unless (defined $command)
543 if (defined $commands{$command})
545 &{$commands{$command}{func}}(@ARGV);
549 print "Unknown command '$command'.\n";