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/$_" }
140 modules => [ qw(l4re examples doc toolbin) ] },
142 l4re_all => { paths => [ qw(l4/pkg l4/tool) ],
143 modules => [ qw(l4re_snapshot) ] },
146 paths => [ qw(tools/preprocess) ]
151 paths => [ qw(kernel/fiasco/BENCHMARKING
152 kernel/fiasco/COPYING
153 kernel/fiasco/MAINTAINER
154 kernel/fiasco/Makefile
159 modules => [ qw(preprocess) ],
163 paths => [ qw(kernel/Makefile) ],
167 paths => [ qw(grub) ],
170 remote_repo_l4re => {
171 modules => [ qw(l4re_snapshot) ],
174 remote_repo => { modules => [ qw(fiasco remote_repo_l4re) ], },
177 modules => [ qw(remote_repo) ],
185 my $o = `svn info --xml .`;
186 die "Failed 'svn info'." if $?;
187 $o =~ /<root>(.+)<\/root>/m;
197 my $pathsref = shift;
200 die "Possible looping in modules structure detected!" unless $count;
204 die "Unknown module '$m' referenced!" unless defined $modules{$m};
205 $$pathsref{$_} = 1 foreach @{$modules{$m}{paths}};
206 do_merge($pathsref, $count - 1, @{$modules{$m}{modules}});
210 do_merge(\%paths, 20, scalar @_ ? @_ : 'all');
220 $command = $commands{$command}{alias}
221 if defined $command and defined $commands{$command}{alias};
223 if (!defined $command or $command eq 'help')
225 print "$0 command [option]\n";
227 print "Available commands, use '$0 help command' for help on the command:\n";
228 foreach (sort keys %commands)
230 print " $_\n" if defined $commands{$_}{public};
233 elsif ($command eq 'update')
235 print " 'update' will update in the following way:\n".
236 " update itself and re-exec if necessary\n".
237 " call 'make update' in l4/pkg\n".
238 " call 'svn update' every directory in kernel\n";
240 elsif ($command eq 'checkout')
242 print " 'checkout' will check out the given modules.\n";
243 print "Available modules:\n";
244 foreach (sort keys %modules)
246 print " $_\n" if $modules{$_}{pub_module};
251 print " No such command '$command'.\n";
255 sub check_module_structure()
257 # make sure the paths look ok
258 foreach (merge_modules())
260 die "Trailing /'s in modules structure" if /\/$/;
261 die "Double // detected in modules structure" if /\/\//;
279 die "Need to give URL" unless defined $url and defined $dirname;
280 system("svn co $url --depth empty $dirname");
285 my $config_blob = shift;
286 $config_blob = '{}' unless defined $config_blob;
288 unless ($c = eval($config_blob))
290 die "Couldn't parse config file: $@" if $@;
291 die "Couldn't do config file: $!" if $!;
292 die "Couldn't run config file";
297 $a{base} = "trunk" unless defined $a{base};
302 sub convert_path($$%)
305 my $partmatch = shift;
310 foreach my $key (keys %path_roots)
313 $r .= '/' unless $r =~ /\/$/;
316 # for partly matches we also need to return the modified path
317 # because otherwise we can't really know
318 if ($p =~ /^($r)(.*)$/)
320 my $s = $path_roots{$key}.'/'.$2;
321 # strip off last / again, it's just used for matching
322 return substr($s, 0, length($s) - 1);
327 return $path_roots{$key} if $p =~ /^$r$/;
336 unless (defined ${$args{mods}}[0])
338 print "Supply module to check out.\n";
343 die "Current directory is no SVN WC" unless -d ".svn";
345 my $root_url = get_root_url();
347 my $rev = $ENV{REPOMGR_SVN_REV} || 'HEAD';
349 my @paths = merge_modules(@{$args{mods}});
351 foreach my $paths (@paths)
353 my @path_elems = split /\/+/, $paths;
354 my $last_elem = pop @path_elems;
357 foreach my $pe (@path_elems)
359 if (! -d "$path/$pe/.svn")
361 # if we find something from path_roots then switch to that
362 my $changed_path = convert_path("$path/$pe", 0,
363 %{$args{conf}{path_roots}});
365 print "Creating $path/$pe\n";
366 print " from $changed_path\n" if defined $changed_path;
368 # there's some other little problem with the 'depth' thing
369 # when we do checkout some specific list of files (and dirs),
370 # we need to use depth=empty so that we only get those
371 # specific files out of the directory, on the other side we'd
372 # (probably) like to have updates on the directory contents
373 # when we do 'svn up' which would would with depth=files (or
375 # As the first thing is merely only needed when doing a
376 # checkout for another repo... let's have a config option.
378 $depth = 'empty' if defined $ENV{REPOMGR_EXACT_CHECKOUT};
380 if (defined $changed_path)
382 my $cmd = "cd $path && svn co -r $rev --depth empty $root_url/$changed_path $pe";
383 #print "cmd: $cmd\n";
385 die "svn co failed" if $?;
389 my $cmd = "cd $path && svn update -r $rev --depth empty $pe";
390 #print "cmd: $cmd\n";
392 die "svn update failed" if $?;
399 print "Getting sources\n";
400 my $c = "svn update -r $rev --set-depth infinity ".join(' ', map { s/^\/+//; $_; } @paths);
403 die "svn update failed" if $?;
409 return undef unless defined $fn;
411 if ($fn =~ /^(file|svn|ssh\+svn):\/\//)
413 $blob = `svn cat $fn`;
427 my %conf = init_config(read_file("l4/conf/repomgr.conf"));
428 do_checkout(conf => { %conf }, mods => [ @_ ]);
431 sub fix_repomgr_path(%)
434 # fix the path to the repomgr...
435 @{$modules{repomgr}{paths}} = map { "$conf{repomgr_prefix}/$_" } @{$modules{repomgr}{paths}}
436 if defined $conf{repomgr_prefix};
441 my $repo_root = shift;
443 my $localdir = 'src';
445 while (defined $_[0] && ($_[0] eq '-c' or $_[0] eq '-l'))
452 elsif ($_[0] eq '-l')
459 die "Usage: $0 init <REPOROOTURL> [-c <REPOCONFPATH>] [-l <LOCALDIR>] modules..."
460 if not defined $repo_root or not defined $repo_conf
461 or not defined $localdir;
463 # for absolute path we assume a local config file, good for testing
465 if ($repo_conf ne '')
467 if ($repo_conf =~ /^\//)
469 $confblob = read_file($repo_conf);
470 die "Cannot open '$repo_conf': $!" unless defined $confblob;
474 my $cmd = "svn cat $repo_root\/$repo_conf";
476 die "Command '$cmd' failed" if $?;
480 my %conf = init_config($confblob);
482 ($localdir = $conf{base}) =~ s/.*\/// unless defined $localdir;
483 print "localdir: $localdir\n";
485 my $cmd = "svn co --depth empty $repo_root/$conf{base} $localdir";
487 die "Command '$cmd' failed" if $?;
490 fix_repomgr_path(%conf);
491 do_checkout(conf => { %conf }, mods => [ "repomgr", @_ ]);
496 foreach (sort keys %modules)
498 print "$_\n" if defined $modules{$_}{pub_module};
504 print "$_\n" foreach merge_modules(@_);
507 sub command_listmapped
509 my $blob = read_file(shift);
510 die "Need config" unless defined $blob;
511 my %conf = init_config($blob);
512 fix_repomgr_path(%conf);
513 print join("\n", map {
514 my $p = convert_path($_, 1, %{$conf{path_roots}});
515 defined $p ? $p : $_;
516 } merge_modules(@_));
522 help => { func => \&command_help, },
523 init => { func => \&command_init, },
524 update => { func => \&command_update, },
525 up => { func => \&command_update, alias => 'update' },
526 checkout => { func => \&command_checkout, public => 1},
527 co => { func => \&command_checkout, alias => 'checkout'},
528 modules => { func => \&command_modules, public => 1},
529 list => { func => \&command_list, },
530 listmapped=> { func => \&command_listmapped, },
531 root => { func => \&command_root, },
534 # ----------------------------------------------------------------
536 check_module_structure();
540 unless (defined $command)
546 if (defined $commands{$command})
548 &{$commands{$command}{func}}(@ARGV);
552 print "Unknown command '$command'.\n";