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 my ($from, $to) = @_;
118 my @cmd = ("wget", $from, "-O", $to);
119 message "== running @cmd";
122 die "Failed to execute wget: $!\n";
125 die "wget failed: $?\n";
130 message "== running darcs @_";
131 system ("darcs", @_) == 0
133 or die "darcs failed: $?";
143 my ($repo_base, $checked_out_tree) = getrepo();
145 open IN, "< packages" or die "Can't open packages file";
151 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
153 $tag = defined($2) ? $2 : "";
156 if ($checked_out_tree) {
157 $path = "$repo_base/$localpath";
160 $path = "$repo_base/$remotepath";
163 if (-d "$localpath/_darcs") {
164 if ($want_remote_repo) {
165 darcs (@_, "--repodir", $localpath, $path);
167 darcs (@_, "--repodir", $localpath);
171 message "== Required repo $localpath is missing! Skipping";
174 message "== $localpath repo not present; skipping";
177 elsif (! /^(#.*)?$/) {
182 if ($_[0] eq "pull" || $_[0] eq "pul") {
195 my ($repo_base, $checked_out_tree) = getrepo();
197 if (! grep /(?:--complete|--partial)/, @_) {
198 warning("adding --partial, to override use --complete");
199 $r_flags = [@_, "--partial"];
205 open IN, "< packages" or die "Can't open packages file";
211 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
213 $tag = defined($2) ? $2 : "";
216 if ($checked_out_tree) {
217 $path = "$repo_base/$localpath";
220 $path = "$repo_base/$remotepath";
223 if (($tag eq "") || defined($tags{$tag})) {
225 warning("$localpath already present; omitting");
228 darcs (@$r_flags, $path, $localpath);
232 elsif (! /^(#.*)?$/) {
250 my ($repo_base, $checked_out_tree) = getrepo();
252 message "== Syncing tarballs";
254 open IN, "< tarballs" or die "Can't open packages file";
258 foreach (@tarballs) {
260 if (m@^([^# ]+)/([^#/ ]+) +([^ ]+)$@) {
261 $localdirectory = $1;
264 $localpath = "$localdirectory/$localfilename";
266 $localtarballs{$localdirectory}{$localfilename} = 1;
268 if (! -e $localpath) {
269 if ($checked_out_tree) {
270 $path = "$repo_base/$localpath";
273 $path = "$repo_base/$remotepath";
275 &download($path, $localpath);
278 elsif (! /^(#.*)?$/) {
283 foreach $localdirectory (keys %localtarballs) {
284 FILE: foreach $actualpath (glob "$localdirectory/*.tar.gz $localdirectory/*.tar.bz2") {
285 $actualfilename = $actualpath;
286 $actualfilename =~ s#.*/##;
287 if (! defined($localtarballs{$localdirectory}{$actualfilename})) {
288 message "== Deleting $actualpath";
296 if (! -d "compiler") {
297 die "error: darcs-all must be run from the top level of the ghc tree."
302 # We handle -q here as well as lower down as we need to skip over it
303 # if it comes before the darcs command
307 elsif ($arg eq "-s") {
310 elsif ($arg eq "-r") {
311 $defaultrepo = shift;
313 elsif ($arg eq "-i") {
316 # --nofib tells get to also grab the nofib repo.
317 # It has no effect on the other commands.
318 elsif ($arg eq "--nofib") {
321 # --testsuite tells get to also grab the testsuite repo.
322 # It has no effect on the other commands.
323 elsif ($arg eq "--testsuite") {
324 $tags{"testsuite"} = 1;
326 elsif ($arg eq "--checked-out") {
327 $checked_out_flag = 1;
331 if (grep /^-q$/, @_) {
339 die "What do you want to do?";
342 if ($command eq "get") {
346 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
347 # Hack around whatsnew failing if there are no changes
350 if ($command =~ /^(pul|pus|sen|put)/) {
351 $want_remote_repo = 1;
358 message "== Checking for old bytestring repo";
359 if (-d "libraries/bytestring/_darcs") {
360 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
362 ============================
365 You have an old bytestring repository in your GHC tree!
367 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
368 version of bytestring will be used from a tarball instead.
369 ============================