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";
124 message "== running darcs @_";
125 system ("darcs", @_) == 0
127 or die "darcs failed: $?";
137 my ($repo_base, $checked_out_tree) = getrepo();
139 open IN, "< packages" or die "Can't open packages file";
145 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
147 $tag = defined($2) ? $2 : "";
150 if ($checked_out_tree) {
151 $path = "$repo_base/$localpath";
154 $path = "$repo_base/$remotepath";
157 if (-d "$localpath/_darcs") {
158 if ($want_remote_repo) {
159 darcs (@_, "--repodir", $localpath, $path);
161 darcs (@_, "--repodir", $localpath);
165 message "== Required repo $localpath is missing! Skipping";
168 message "== $localpath repo not present; skipping";
171 elsif (! /^(#.*)?$/) {
176 if ($_[0] eq "pull" || $_[0] eq "pul") {
189 my ($repo_base, $checked_out_tree) = getrepo();
191 if (! grep /(?:--complete|--partial)/, @_) {
192 warning("adding --partial, to override use --complete");
193 $r_flags = [@_, "--partial"];
199 open IN, "< packages" or die "Can't open packages file";
205 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
207 $tag = defined($2) ? $2 : "";
210 if ($checked_out_tree) {
211 $path = "$repo_base/$localpath";
214 $path = "$repo_base/$remotepath";
217 if (($tag eq "") || defined($tags{$tag})) {
219 warning("$localpath already present; omitting");
222 darcs (@$r_flags, $path, $localpath);
226 elsif (! /^(#.*)?$/) {
244 my ($repo_base, $checked_out_tree) = getrepo();
246 message "== Syncing tarballs";
248 open IN, "< tarballs" or die "Can't open packages file";
252 foreach (@tarballs) {
254 if (m@^([^# ]+)/([^#/ ]+) +([^ ]+)$@) {
255 $localdirectory = $1;
258 $localpath = "$localdirectory/$localfilename";
260 $localtarballs{$localdirectory}{$localfilename} = 1;
262 if (! -e $localpath) {
263 if ($checked_out_tree) {
264 $path = "$repo_base/$localpath";
267 $path = "$repo_base/$remotepath";
269 &download($path, $localpath);
272 elsif (! /^(#.*)?$/) {
277 foreach $localdirectory (keys %localtarballs) {
278 FILE: foreach $actualpath (glob "$localdirectory/*.tar.gz $localdirectory/*.tar.bz2") {
279 $actualfilename = $actualpath;
280 $actualfilename =~ s#.*/##;
281 if (! defined($localtarballs{$localdirectory}{$actualfilename})) {
282 message "== Deleting $actualpath";
290 if (! -d "compiler") {
291 die "error: darcs-all must be run from the top level of the ghc tree."
296 # We handle -q here as well as lower down as we need to skip over it
297 # if it comes before the darcs command
301 elsif ($arg eq "-s") {
304 elsif ($arg eq "-r") {
305 $defaultrepo = shift;
307 elsif ($arg eq "-i") {
310 # --nofib tells get to also grab the nofib repo.
311 # It has no effect on the other commands.
312 elsif ($arg eq "--nofib") {
315 # --testsuite tells get to also grab the testsuite repo.
316 # It has no effect on the other commands.
317 elsif ($arg eq "--testsuite") {
318 $tags{"testsuite"} = 1;
320 elsif ($arg eq "--checked-out") {
321 $checked_out_flag = 1;
325 if (grep /^-q$/, @_) {
333 die "What do you want to do?";
336 if ($command eq "get") {
340 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
341 # Hack around whatsnew failing if there are no changes
344 if ($command =~ /^(pul|pus|sen|put)/) {
345 $want_remote_repo = 1;
352 message "== Checking for old bytestring repo";
353 if (-d "libraries/bytestring/_darcs") {
354 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
356 ============================
359 You have an old bytestring repository in your GHC tree!
361 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
362 version of bytestring will be used from a tarball instead.
363 ============================