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) ],
52 paths => [ qw(l4/pkg/hello),
53 map { "l4/pkg/examples/$_" }
78 doc => { paths => [ qw(l4/doc/Makefile l4/doc/source) ], },
81 paths => [ map { "l4/pkg/$_" }
142 modules => [ qw(l4re examples doc toolbin) ] },
144 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
145 modules => [ qw(l4re_snapshot) ] },
148 paths => [ qw(tools/preprocess) ]
153 paths => [ qw(kernel/fiasco/BENCHMARKING
154 kernel/fiasco/COPYING
155 kernel/fiasco/MAINTAINER
156 kernel/fiasco/Makefile
161 modules => [ qw(preprocess) ],
165 paths => [ qw(kernel/Makefile) ],
169 paths => [ qw(grub) ],
172 remote_repo_l4re => {
173 modules => [ qw(l4re_snapshot) ],
176 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ], },
179 modules => [ qw(remote_repo) ],
187 my $o = `svn info --xml .`;
188 die "Failed 'svn info'." if $?;
189 $o =~ /<root>(.+)<\/root>/m;
199 my $pathsref = shift;
202 die "Possible looping in modules structure detected!" unless $count;
206 die "Unknown module '$m' referenced!" unless defined $modules{$m};
207 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
208 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
212 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
222 $command = $commands{$command}{alias}
223 if defined $command and defined $commands{$command}{alias};
225 if (!defined $command or $command eq 'help')
227 print "$0 command [option]\n";
229 print "Available commands, use '$0 help command' for help on the command:\n";
230 foreach (sort keys %commands)
232 print " $_\n" if defined $commands{$_}{public};
235 elsif ($command eq 'update')
237 print " 'update' will update in the following way:\n".
238 " update itself and re-exec if necessary\n".
239 " call 'make update' in l4/pkg\n".
240 " call 'svn update' every directory in kernel\n";
242 elsif ($command eq 'checkout')
244 print " 'checkout' will check out the given modules.\n";
245 print "Available modules:\n";
246 foreach (sort keys %modules)
248 print " $_\n" if $modules{$_}{pub_module};
253 print " No such command '$command'.\n";
257 sub check_module_structure()
259 # make sure the paths look ok
260 foreach (merge_modules())
262 die "Trailing /'s in modules structure" if /\/$/;
263 die "Double // detected in modules structure" if /\/\//;
281 die "Need to give URL" unless defined $url and defined $dirname;
282 system("svn co $url --depth empty $dirname");
287 my $config_blob = shift;
288 $config_blob = '{}' unless defined $config_blob;
290 unless ($c = eval($config_blob))
292 die "Couldn't parse config file: $@" if $@;
293 die "Couldn't do config file: $!" if $!;
294 die "Couldn't run config file";
299 $a{base} = "trunk" unless defined $a{base};
304 sub convert_path($$%)
307 my $partmatch = shift;
312 foreach my $key (keys %path_roots)
315 $r .= '/' unless $r =~ /\/$/;
318 # for partly matches we also need to return the modified path
319 # because otherwise we can't really know
320 if ($p =~ /^($r)(.*)$/)
322 my $s = $path_roots{$key}.'/'.$2;
323 # strip off last / again, it's just used for matching
324 return substr($s, 0, length($s) - 1);
329 return $path_roots{$key} if $p =~ /^$r$/;
338 unless (defined ${$args{mods}}[0])
340 print "Supply module to check out.\n";
345 die "Current directory is no SVN WC" unless -d ".svn";
347 my $root_url = get_root_url();
349 my $rev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
351 my @paths = merge_modules(@{$args{mods}});
353 foreach my $paths (@paths)
355 my @path_elems = split /\/+/, $paths;
356 my $last_elem = pop @path_elems;
359 foreach my $pe (@path_elems)
361 if (! -d "$path/$pe/.svn")
363 # if we find something from path_roots then switch to that
364 my $changed_path = convert_path("$path/$pe", 0,
365 %{$args{conf}{path_roots}});
367 print "Creating $path/$pe\n";
368 print " from $changed_path\n" if defined $changed_path;
370 # there's some other little problem with the 'depth' thing
371 # when we do checkout some specific list of files (and dirs),
372 # we need to use depth=empty so that we only get those
373 # specific files out of the directory, on the other side we'd
374 # (probably) like to have updates on the directory contents
375 # when we do 'svn up' which would would with depth=files (or
377 # As the first thing is merely only needed when doing a
378 # checkout for another repo... let's have a config option.
380 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
382 if (defined $changed_path)
384 my $cmd = "cd $path && svn co -r $rev --depth empty $root_url/$changed_path $pe";
385 #print "cmd: $cmd\n";
387 die "svn co failed" if $?;
391 my $cmd = "cd $path && svn update -r $rev --depth empty $pe";
392 #print "cmd: $cmd\n";
394 die "svn update failed" if $?;
401 print "Getting sources\n";
402 my $c = "svn update -r $rev --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
405 die "svn update failed" if $?;
411 return undef unless defined $fn;
413 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
415 $blob = `svn cat $fn`;
429 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
430 do_checkout(conf => { %conf }, mods => [ @_ ]);
433 sub fix_repomgr_path(%)
436 # fix the path to the repomgr...
437 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
438 if defined $conf{repomgr_prefix};
443 my $repo_root = shift;
445 my $localdir = 'src';
447 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
454 elsif ($_[0] eq '-l')
461 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
462 if not defined $repo_root or not defined $repo_conf
463 or not defined $localdir;
465 # for absolute path we assume a local config file, good for testing
467 if ($repo_conf ne '')
469 if ($repo_conf =~ /^\//)
471 $confblob = read_file($repo_conf);
472 die "Cannot open '$repo_conf': $!" unless defined $confblob;
476 my $cmd = "svn cat $repo_root\/$repo_conf";
478 die "Command '$cmd' failed" if $?;
482 my %conf = init_config($confblob);
484 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
485 print "localdir: $localdir\n";
487 my $cmd = "svn co --depth empty $repo_root/$conf{base} $localdir";
489 die "Command '$cmd' failed" if $?;
492 fix_repomgr_path(%conf);
493 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
498 foreach (sort keys %modules)
500 print "$_\n" if defined $modules{$_}{pub_module};
506 print "$_\n" foreach merge_modules(@_);
509 sub command_listmapped
511 my $blob = read_file(shift);
512 die "Need config" unless defined $blob;
513 my %conf = init_config($blob);
514 fix_repomgr_path(%conf);
515 print join("\n", map {
516 my $p = convert_path($_, 1, %{$conf{path_roots}});
517 defined $p ? $p : $_;
518 } merge_modules(@_));
524 help => { func => \&command_help, },
525 init => { func => \&command_init, },
526 update => { func => \&command_update, },
527 up => { func => \&command_update, alias => 'update' },
528 checkout => { func => \&command_checkout, public => 1},
529 co => { func => \&command_checkout, alias => 'checkout'},
530 modules => { func => \&command_modules, public => 1},
531 list => { func => \&command_list, },
532 listmapped=> { func => \&command_listmapped, },
533 root => { func => \&command_root, },
536 # ----------------------------------------------------------------
538 check_module_structure();
542 unless (defined $command)
548 if (defined $commands{$command})
550 &{$commands{$command}{func}}(@ARGV);
554 print "Unknown command '$command'.\n";