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 (($tag eq "-") || defined($tags{$tag})) {
262 warning("$localpath already present; omitting");
265 darcs (@$r_flags, $path, $localpath);
272 if (! -d "compiler") {
273 die "error: darcs-all must be run from the top level of the ghc tree."
278 # We handle -q here as well as lower down as we need to skip over it
279 # if it comes before the darcs command
283 elsif ($arg eq "-s") {
286 elsif ($arg eq "-r") {
287 $defaultrepo = shift;
289 elsif ($arg eq "-i") {
292 # --nofib tells get to also grab the nofib repo.
293 # It has no effect on the other commands.
294 elsif ($arg eq "--nofib") {
297 # --testsuite tells get to also grab the testsuite repo.
298 # It has no effect on the other commands.
299 elsif ($arg eq "--testsuite") {
300 $tags{"testsuite"} = 1;
302 # --extralibs tells get to also grab the extra repos.
303 # It has no effect on the other commands.
304 elsif ($arg eq "--extra") {
307 elsif ($arg eq "--checked-out") {
308 $checked_out_flag = 1;
312 if (grep /^-q$/, @_) {
320 die "What do you want to do?";
324 if ($command eq "get") {
328 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
329 # Hack around whatsnew failing if there are no changes
332 if ($command =~ /^(pul|pus|sen|put|opt)/) {
333 $want_remote_repo = 1;
342 message "== Checking for old bytestring repo";
343 if (-d "libraries/bytestring/_darcs") {
344 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
346 ============================
349 You have an old bytestring repository in your GHC tree!
351 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
352 version of bytestring will be used from a tarball instead.
353 ============================
358 message "== Checking for bytestring tarball";
359 if (-d "libraries/bytestring" && not -d "libraries/bytestring/_darcs") {
361 ============================
364 You have an old bytestring in your GHC tree!
366 Please remove it (e.g. "rm -r libraries/bytestring"), and then run
367 "./darcs-all get" to get the darcs repository.
368 ============================
372 message "== Checking for unpulled tarball patches";
373 if ((system "darcs annotate --match 'hash 20090930200358-3fd76-cab3bf4a0a9e3902eb6dd41f71712ad3a6a9bcd1' > /dev/null 2> /dev/null") == 0) {
375 ============================
378 You have the unpulled tarball patches in your GHC tree!
381 darcs unpull -p "Use mingw tarballs to get mingw on Windows"
382 and say yes to each patch.
383 ============================