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 # -q says to be quite, and -s to be silent.
27 # -i says to ignore darcs errors and move on to the next repository
29 # -r repo says to use repo as the location of package repositories
31 # --checked-out says that the remote repo is in checked-out layout, as
32 # opposed to the layout used for the main repo. By default a repo on
33 # the local filesystem is assumed to be checked-out, and repos accessed
34 # via HTTP or SSH are assumed to be in the main repo layout; use
35 # --checked-out to override the latter.
37 # --nofib, --testsuite also get the nofib and testsuite repos respectively
39 # The darcs get flag you are most likely to want is --complete. By
40 # default we pass darcs the --partial flag.
43 $| = 1; # autoflush stdout after each print, to avoid output after die
48 my $ignore_failure = 0;
49 my $want_remote_repo = 0;
50 my $checked_out_flag = 0;
54 # Figure out where to get the other repositories from.
57 my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`;
63 if ($repo =~ /^...*:/) {
65 # Above regex says "at least two chars before the :", to avoid
66 # catching Win32 drives ("C:\").
69 # --checked-out is needed if you want to use a checked-out repo
71 if ($checked_out_flag) {
72 $checked_out_tree = 1;
74 $checked_out_tree = 0;
77 # Don't drop the last part of the path if specified with -r, as
78 # it expects repos of the form:
80 # http://darcs.haskell.org
84 # http://darcs.haskell.org/ghc
87 $repo_base =~ s#/[^/]+/?$##;
90 elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
91 # Local filesystem, either absolute or relative path
92 # (assumes a checked-out tree):
94 $checked_out_tree = 1;
97 die "Couldn't work out repo";
100 return $repo_base, $checked_out_tree;
111 print "warning: @_\n";
116 message "== running darcs @_";
117 system ("darcs", @_) == 0
119 or die "darcs failed: $?";
130 my ($repo_base, $checked_out_tree) = getrepo();
132 open IN, "< packages" or die "Can't open packages file";
138 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
140 $tag = defined($2) ? $2 : "";
143 if ($checked_out_tree) {
144 $path = "$repo_base/$localpath";
147 $path = "$repo_base/$remotepath";
150 if (-d "$localpath/_darcs") {
151 if ($want_remote_repo) {
152 if ($command =~ /^opt/) {
153 # Allows ./darcs-all optimize --relink
154 darcs (@_, "--repodir", $localpath, "--sibling=$path");
156 darcs (@_, "--repodir", $localpath, $path);
159 darcs (@_, "--repodir", $localpath);
163 message "== Required repo $localpath is missing! Skipping";
166 message "== $localpath repo not present; skipping";
169 elsif (! /^(#.*)?$/) {
183 my ($repo_base, $checked_out_tree) = getrepo();
185 if (! grep /(?:--complete|--partial)/, @_) {
186 warning("adding --partial, to override use --complete");
187 $r_flags = [@_, "--partial"];
193 open IN, "< packages" or die "Can't open packages file";
199 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
201 $tag = defined($2) ? $2 : "";
204 if ($checked_out_tree) {
205 $path = "$repo_base/$localpath";
208 $path = "$repo_base/$remotepath";
211 if (($tag eq "") || defined($tags{$tag})) {
213 warning("$localpath already present; omitting");
216 darcs (@$r_flags, $path, $localpath);
220 elsif (! /^(#.*)?$/) {
227 if (! -d "compiler") {
228 die "error: darcs-all must be run from the top level of the ghc tree."
233 # We handle -q here as well as lower down as we need to skip over it
234 # if it comes before the darcs command
238 elsif ($arg eq "-s") {
241 elsif ($arg eq "-r") {
242 $defaultrepo = shift;
244 elsif ($arg eq "-i") {
247 # --nofib tells get to also grab the nofib repo.
248 # It has no effect on the other commands.
249 elsif ($arg eq "--nofib") {
252 # --testsuite tells get to also grab the testsuite repo.
253 # It has no effect on the other commands.
254 elsif ($arg eq "--testsuite") {
255 $tags{"testsuite"} = 1;
257 elsif ($arg eq "--checked-out") {
258 $checked_out_flag = 1;
262 if (grep /^-q$/, @_) {
270 die "What do you want to do?";
273 if ($command eq "get") {
277 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
278 # Hack around whatsnew failing if there are no changes
281 if ($command =~ /^(pul|pus|sen|put|opt)/) {
282 $want_remote_repo = 1;
289 message "== Checking for old bytestring repo";
290 if (-d "libraries/bytestring/_darcs") {
291 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
293 ============================
296 You have an old bytestring repository in your GHC tree!
298 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
299 version of bytestring will be used from a tarball instead.
300 ============================
305 message "== Checking for unpulled tarball patches";
306 if ((system "darcs annotate --match 'hash 20090930200358-3fd76-cab3bf4a0a9e3902eb6dd41f71712ad3a6a9bcd1' > /dev/null 2> /dev/null") == 0) {
308 ============================
311 You have the unpulled tarball patches in your GHC tree!
314 darcs unpull -p "Use mingw tarballs to get mingw on Windows"
315 and say yes to each patch.
316 ============================