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: $?";
162 my ($repo_base, $checked_out_tree) = getrepo();
164 open IN, "< packages" or die "Can't open packages file";
172 if (/^([^# ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) {
177 if ($checked_out_tree) {
178 $path = "$repo_base/$localpath";
181 $path = "$repo_base/$remotepath";
184 if (-d "$localpath/_darcs") {
185 if ($want_remote_repo) {
186 if ($command =~ /^opt/) {
187 # Allows ./darcs-all optimize --relink
188 darcs (@_, "--repodir", $localpath, "--sibling=$path");
190 darcs (@_, "--repodir", $localpath, $path);
193 darcs (@_, "--repodir", $localpath);
196 elsif ($tag eq "-") {
197 message "== Required repo $localpath is missing! Skipping";
200 message "== $localpath repo not present; skipping";
203 elsif (! /^(#.*)?$/) {
204 die "Bad content on line $line of packages file: $_";
218 my ($repo_base, $checked_out_tree) = getrepo();
220 if (! grep /(?:--complete|--partial|--lazy)/, @_) {
221 warning("adding --partial, to override use --complete");
222 $r_flags = [@_, "--partial"];
228 open IN, "< packages" or die "Can't open packages file";
236 if (/^([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) {
241 if ($checked_out_tree) {
242 $path = "$repo_base/$localpath";
245 $path = "$repo_base/$remotepath";
248 if (($tag eq "-") || defined($tags{$tag})) {
250 warning("$localpath already present; omitting");
253 darcs (@$r_flags, $path, $localpath);
257 elsif (! /^(#.*)?$/) {
258 die "Bad content on line $line of packages file: $_";
264 if (! -d "compiler") {
265 die "error: darcs-all must be run from the top level of the ghc tree."
270 # We handle -q here as well as lower down as we need to skip over it
271 # if it comes before the darcs command
275 elsif ($arg eq "-s") {
278 elsif ($arg eq "-r") {
279 $defaultrepo = shift;
281 elsif ($arg eq "-i") {
284 # --nofib tells get to also grab the nofib repo.
285 # It has no effect on the other commands.
286 elsif ($arg eq "--nofib") {
289 # --testsuite tells get to also grab the testsuite repo.
290 # It has no effect on the other commands.
291 elsif ($arg eq "--testsuite") {
292 $tags{"testsuite"} = 1;
294 # --extralibs tells get to also grab the extra repos.
295 # It has no effect on the other commands.
296 elsif ($arg eq "--extra") {
299 elsif ($arg eq "--checked-out") {
300 $checked_out_flag = 1;
304 if (grep /^-q$/, @_) {
312 die "What do you want to do?";
315 if ($command eq "get") {
319 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
320 # Hack around whatsnew failing if there are no changes
323 if ($command =~ /^(pul|pus|sen|put|opt)/) {
324 $want_remote_repo = 1;
333 message "== Checking for old bytestring repo";
334 if (-d "libraries/bytestring/_darcs") {
335 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
337 ============================
340 You have an old bytestring repository in your GHC tree!
342 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
343 version of bytestring will be used from a tarball instead.
344 ============================
349 message "== Checking for bytestring tarball";
350 if (-d "libraries/bytestring" && not -d "libraries/bytestring/_darcs") {
352 ============================
355 You have an old bytestring in your GHC tree!
357 Please remove it (e.g. "rm -r libraries/bytestring"), and then run
358 "./darcs-all get" to get the darcs repository.
359 ============================
363 message "== Checking for unpulled tarball patches";
364 if ((system "darcs annotate --match 'hash 20090930200358-3fd76-cab3bf4a0a9e3902eb6dd41f71712ad3a6a9bcd1' > /dev/null 2> /dev/null") == 0) {
366 ============================
369 You have the unpulled tarball patches in your GHC tree!
372 darcs unpull -p "Use mingw tarballs to get mingw on Windows"
373 and say yes to each patch.
374 ============================