7 # ./darcs-all [-q] [-s] [-i] [-r repo]
8 # [--nofib] [--testsuite] [--checked-out] cmd [darcs flags]
10 # Applies the darcs command "cmd" to each repository in the tree.
13 # ./darcs-all -r http://darcs.haskell.org/ghc get
14 # To get any repos which do not exist in the local tree
16 # ./darcs-all -r ~/ghc-validate push
17 # To push all your repos to the ~/ghc-validate tree
20 # To pull everything from the default repos
22 # ./darc-all push --dry-run
23 # To see what local patches you have relative to the main repos
25 # -------------- Flags -------------------
26 # -q says to be quite, and -s to be silent.
28 # -i says to ignore darcs errors and move on to the next repository
30 # -r repo says to use repo as the location of package repositories
32 # --checked-out says that the remote repo is in checked-out layout, as
33 # opposed to the layout used for the main repo. By default a repo on
34 # the local filesystem is assumed to be checked-out, and repos accessed
35 # via HTTP or SSH are assumed to be in the main repo layout; use
36 # --checked-out to override the latter.
38 # --nofib, --testsuite also get the nofib and testsuite repos respectively
40 # The darcs get flag you are most likely to want is --complete. By
41 # default we pass darcs the --partial flag.
43 # ------------ Which repos to use -------------
44 # darcs-all uses the following algorithm to decide which remote repos to use
46 # It always computes the remote repos from a single base, $repo_base
47 # How is $repo_base set?
48 # If you say "-r repo", then that's $repo_base
49 # othewise $repo_base is set thus:
50 # look in _darcs/prefs/defaultrepo,
51 # and remove the trailing 'ghc'
53 # Then darcs-all iterates over the package found in the file
54 # ./packages, which has entries like:
55 # libraries/array packages/array darcs
57 # <local-path> <remote-path> <vcs>
59 # If $repo_base looks like a local filesystem path, or if you give
60 # the --checked-out flag, darcs-all works on repos of form
61 # $repo_base/<local-path>
62 # otherwise darcs-all works on repos of form
63 # $repo_base/<remote-path>
64 # This logic lets you say
65 # both darcs-all -r http://darcs.haskell.org/ghc-6.12 pull
66 # and darcs-all -r ../HEAD pull
67 # The latter is called a "checked-out tree".
69 # NB: darcs-all *ignores* the defaultrepo of all repos other than the
70 # root one. So the remote repos must be laid out in one of the two
71 # formats given by <local-path> and <remote-path> in the file 'packages'.
74 $| = 1; # autoflush stdout after each print, to avoid output after die
79 my $ignore_failure = 0;
80 my $want_remote_repo = 0;
81 my $checked_out_flag = 0;
87 # Figure out where to get the other repositories from.
90 my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`;
96 if ($repo =~ /^...*:/) {
98 # Above regex says "at least two chars before the :", to avoid
99 # catching Win32 drives ("C:\").
102 # --checked-out is needed if you want to use a checked-out repo
104 if ($checked_out_flag) {
105 $checked_out_tree = 1;
107 $checked_out_tree = 0;
110 # Don't drop the last part of the path if specified with -r, as
111 # it expects repos of the form:
113 # http://darcs.haskell.org
117 # http://darcs.haskell.org/ghc
120 $repo_base =~ s#/[^/]+/?$##;
123 elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
124 # Local filesystem, either absolute or relative path
125 # (assumes a checked-out tree):
127 $checked_out_tree = 1;
130 die "Couldn't work out repo";
133 return $repo_base, $checked_out_tree;
144 print "warning: @_\n";
149 message "== running darcs @_";
150 system ("darcs", @_) == 0
152 or die "darcs failed: $?";
159 my ($repo_base, $checked_out_tree) = getrepo();
161 open IN, "< packages" or die "Can't open packages file";
170 if (/^([^# ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) {
172 $line{"localpath"} = $1;
174 $line{"remotepath"} = $3;
176 $line{"upstream"} = $5;
177 push @packages, \%line;
179 elsif (! /^(#.*)?$/) {
180 die "Bad content on line $lineNum of packages file: $_";
194 my ($repo_base, $checked_out_tree) = getrepo();
196 for $line (@packages) {
197 $localpath = $$line{"localpath"};
198 $tag = $$line{"tag"};
199 $remotepath = $$line{"remotepath"};
201 if ($checked_out_tree) {
202 $path = "$repo_base/$localpath";
205 $path = "$repo_base/$remotepath";
208 if (-d "$localpath/_darcs") {
209 if ($want_remote_repo) {
210 if ($command =~ /^opt/) {
211 # Allows ./darcs-all optimize --relink
212 darcs (@_, "--repodir", $localpath, "--sibling=$path");
214 darcs (@_, "--repodir", $localpath, $path);
217 darcs (@_, "--repodir", $localpath);
220 elsif ($tag eq "-") {
221 message "== Required repo $localpath is missing! Skipping";
224 message "== $localpath repo not present; skipping";
238 my ($repo_base, $checked_out_tree) = getrepo();
240 if (! grep /(?:--complete|--partial|--lazy)/, @_) {
241 warning("adding --partial, to override use --complete");
242 $r_flags = [@_, "--partial"];
248 for $line (@packages) {
249 $localpath = $$line{"localpath"};
250 $tag = $$line{"tag"};
251 $remotepath = $$line{"remotepath"};
253 if ($checked_out_tree) {
254 $path = "$repo_base/$localpath";
257 $path = "$repo_base/$remotepath";
260 if ($tags{$tag} eq 1) {
262 warning("$localpath already present; omitting");
265 darcs (@$r_flags, $path, $localpath);
271 sub darcsupstreampull {
276 for $line (@packages) {
277 $localpath = $$line{"localpath"};
278 $upstream = $$line{"upstream"};
280 if ($upstream ne "-") {
282 darcs ("pull", @_, "--repodir", $localpath, $upstream);
289 if (! -d "compiler") {
290 die "error: darcs-all must be run from the top level of the ghc tree."
296 $tags{"testsuite"} = 0;
301 # We handle -q here as well as lower down as we need to skip over it
302 # if it comes before the darcs command
306 elsif ($arg eq "-s") {
309 elsif ($arg eq "-r") {
310 $defaultrepo = shift;
312 elsif ($arg eq "-i") {
315 # --nofib tells get to also grab the nofib repo.
316 # It has no effect on the other commands.
317 elsif ($arg eq "--nofib") {
320 elsif ($arg eq "--no-nofib") {
323 # --testsuite tells get to also grab the testsuite repo.
324 # It has no effect on the other commands.
325 elsif ($arg eq "--testsuite") {
326 $tags{"testsuite"} = 1;
328 elsif ($arg eq "--no-testsuite") {
329 $tags{"testsuite"} = 0;
331 # --dph tells get to also grab the dph repo.
332 # It has no effect on the other commands.
333 elsif ($arg eq "--dph") {
336 elsif ($arg eq "--no-dph") {
339 # --extralibs tells get to also grab the extra repos.
340 # It has no effect on the other commands.
341 elsif ($arg eq "--extra") {
344 elsif ($arg eq "--no-extra") {
347 # Use --checked-out if the remote repos are a checked-out tree,
348 # rather than the master trees.
349 elsif ($arg eq "--checked-out") {
350 $checked_out_flag = 1;
354 if (grep /^-q$/, @_) {
362 die "What do you want to do?";
366 if ($command eq "get") {
369 elsif ($command eq "upstreampull") {
371 darcsupstreampull @_;
374 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
375 # Hack around whatsnew failing if there are no changes
378 if ($command =~ /^(pul|pus|sen|put|opt)/) {
379 $want_remote_repo = 1;
388 message "== Checking for old bytestring repo";
389 if (-d "libraries/bytestring/_darcs") {
390 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
392 ============================
395 You have an old bytestring repository in your GHC tree!
397 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
398 version of bytestring will be used from a tarball instead.
399 ============================
404 message "== Checking for bytestring tarball";
405 if (-d "libraries/bytestring" && not -d "libraries/bytestring/_darcs") {
407 ============================
410 You have an old bytestring in your GHC tree!
412 Please remove it (e.g. "rm -r libraries/bytestring"), and then run
413 "./darcs-all get" to get the darcs repository.
414 ============================
418 message "== Checking for unpulled tarball patches";
419 if ((system "darcs annotate --match 'hash 20090930200358-3fd76-cab3bf4a0a9e3902eb6dd41f71712ad3a6a9bcd1' > /dev/null 2> /dev/null") == 0) {
421 ============================
424 You have the unpulled tarball patches in your GHC tree!
427 darcs unpull -p "Use mingw tarballs to get mingw on Windows"
428 and say yes to each patch.
429 ============================