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;
85 # Figure out where to get the other repositories from.
88 my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`;
94 if ($repo =~ /^...*:/) {
96 # Above regex says "at least two chars before the :", to avoid
97 # catching Win32 drives ("C:\").
100 # --checked-out is needed if you want to use a checked-out repo
102 if ($checked_out_flag) {
103 $checked_out_tree = 1;
105 $checked_out_tree = 0;
108 # Don't drop the last part of the path if specified with -r, as
109 # it expects repos of the form:
111 # http://darcs.haskell.org
115 # http://darcs.haskell.org/ghc
118 $repo_base =~ s#/[^/]+/?$##;
121 elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
122 # Local filesystem, either absolute or relative path
123 # (assumes a checked-out tree):
125 $checked_out_tree = 1;
128 die "Couldn't work out repo";
131 return $repo_base, $checked_out_tree;
142 print "warning: @_\n";
147 message "== running darcs @_";
148 system ("darcs", @_) == 0
150 or die "darcs failed: $?";
161 my ($repo_base, $checked_out_tree) = getrepo();
163 open IN, "< packages" or die "Can't open packages file";
169 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
171 $tag = defined($2) ? $2 : "";
174 if ($checked_out_tree) {
175 $path = "$repo_base/$localpath";
178 $path = "$repo_base/$remotepath";
181 if (-d "$localpath/_darcs") {
182 if ($want_remote_repo) {
183 if ($command =~ /^opt/) {
184 # Allows ./darcs-all optimize --relink
185 darcs (@_, "--repodir", $localpath, "--sibling=$path");
187 darcs (@_, "--repodir", $localpath, $path);
190 darcs (@_, "--repodir", $localpath);
194 message "== Required repo $localpath is missing! Skipping";
197 message "== $localpath repo not present; skipping";
200 elsif (! /^(#.*)?$/) {
214 my ($repo_base, $checked_out_tree) = getrepo();
216 if (! grep /(?:--complete|--partial|--lazy)/, @_) {
217 warning("adding --partial, to override use --complete");
218 $r_flags = [@_, "--partial"];
224 open IN, "< packages" or die "Can't open packages file";
230 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
232 $tag = defined($2) ? $2 : "";
235 if ($checked_out_tree) {
236 $path = "$repo_base/$localpath";
239 $path = "$repo_base/$remotepath";
242 if (($tag eq "") || defined($tags{$tag})) {
244 warning("$localpath already present; omitting");
247 darcs (@$r_flags, $path, $localpath);
251 elsif (! /^(#.*)?$/) {
258 if (! -d "compiler") {
259 die "error: darcs-all must be run from the top level of the ghc tree."
264 # We handle -q here as well as lower down as we need to skip over it
265 # if it comes before the darcs command
269 elsif ($arg eq "-s") {
272 elsif ($arg eq "-r") {
273 $defaultrepo = shift;
275 elsif ($arg eq "-i") {
278 # --nofib tells get to also grab the nofib repo.
279 # It has no effect on the other commands.
280 elsif ($arg eq "--nofib") {
283 # --testsuite tells get to also grab the testsuite repo.
284 # It has no effect on the other commands.
285 elsif ($arg eq "--testsuite") {
286 $tags{"testsuite"} = 1;
288 # --extralibs tells get to also grab the extra repos.
289 # It has no effect on the other commands.
290 elsif ($arg eq "--extra") {
293 elsif ($arg eq "--checked-out") {
294 $checked_out_flag = 1;
298 if (grep /^-q$/, @_) {
306 die "What do you want to do?";
309 if ($command eq "get") {
313 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
314 # Hack around whatsnew failing if there are no changes
317 if ($command =~ /^(pul|pus|sen|put|opt)/) {
318 $want_remote_repo = 1;
327 message "== Checking for old bytestring repo";
328 if (-d "libraries/bytestring/_darcs") {
329 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
331 ============================
334 You have an old bytestring repository in your GHC tree!
336 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
337 version of bytestring will be used from a tarball instead.
338 ============================
343 message "== Checking for bytestring tarball";
344 if (-d "libraries/bytestring" && not -d "libraries/bytestring/_darcs") {
346 ============================
349 You have an old bytestring in your GHC tree!
351 Please remove it (e.g. "rm -r libraries/bytestring"), and then run
352 "./darcs-all get" to get the darcs repository.
353 ============================
357 message "== Checking for unpulled tarball patches";
358 if ((system "darcs annotate --match 'hash 20090930200358-3fd76-cab3bf4a0a9e3902eb6dd41f71712ad3a6a9bcd1' > /dev/null 2> /dev/null") == 0) {
360 ============================
363 You have the unpulled tarball patches in your GHC tree!
366 darcs unpull -p "Use mingw tarballs to get mingw on Windows"
367 and say yes to each patch.
368 ============================