Commit 610379bc authored by Ian Lynagh's avatar Ian Lynagh

Make darcs-all a perl script

This fixes a problem where patches altering the darcs-all script break
on Windows as the file is open. The script is now also slightly nicer,
on balance.
parent b3a0711b
...@@ -72,7 +72,7 @@ check-packages : ...@@ -72,7 +72,7 @@ check-packages :
@for d in `cat libraries/core-packages`; do \ @for d in `cat libraries/core-packages`; do \
if test ! -d libraries/$$d; then \ if test ! -d libraries/$$d; then \
echo "Looks like you're missing libraries/$$d,"; \ echo "Looks like you're missing libraries/$$d,"; \
echo "maybe you haven't done 'sh darcs-all get'?"; \ echo "maybe you haven't done './darcs-all get'?"; \
exit 1; \ exit 1; \
fi \ fi \
done done
......
...@@ -27,7 +27,7 @@ There are two ways to get a source tree: ...@@ -27,7 +27,7 @@ There are two ways to get a source tree:
ghc-<version>-src-extralibs.tar.bz2 ghc-<version>-src-extralibs.tar.bz2
You only need the first one, which contains GHC itself and You only need the first one, which contains GHC itself and
the "core" libraries. the "core" libraries.
The extralibs package contains a bunch of optional libraries. If The extralibs package contains a bunch of optional libraries. If
you want, you can unpack this over the top of your source tree, and you want, you can unpack this over the top of your source tree, and
...@@ -45,16 +45,17 @@ There are two ways to get a source tree: ...@@ -45,16 +45,17 @@ There are two ways to get a source tree:
$ darcs get http://darcs.haskell.org/ghc/ $ darcs get http://darcs.haskell.org/ghc/
Then run the darcs-all shell script in that repository Then run the darcs-all script in that repository
to get the other repositories: to get the other repositories:
$ cd ghc $ cd ghc
$ sh darcs-all get $ chmod +x darcs-all
$ ./darcs-all get
This grabs the "core" packages by default. To get the full set of This grabs the "core" packages by default. To get the full set of
packages, instead say packages, instead say
$ sh darcs-all --extra get $ ./darcs-all --extra get
This also downloads the libraries that are normally bundled in the This also downloads the libraries that are normally bundled in the
"extralibs" package (see above). "extralibs" package (see above).
...@@ -71,7 +72,7 @@ below). ...@@ -71,7 +72,7 @@ below).
You also need a few other tools installed: Happy [4], Alex [5], and You also need a few other tools installed: Happy [4], Alex [5], and
Haddock [6] (for building library documentation), and a good DocBook Haddock [6] (for building library documentation), and a good DocBook
XML toolchain if you want to build the compiler documentation. XML toolchain if you want to build the compiler documentation.
Quick start: the following gives you a default build: Quick start: the following gives you a default build:
...@@ -107,5 +108,5 @@ Contributors ...@@ -107,5 +108,5 @@ Contributors
============ ============
Please see Please see
http://www.haskell.org/ghc/contributors.html http://www.haskell.org/ghc/contributors.html
...@@ -7,7 +7,7 @@ do ...@@ -7,7 +7,7 @@ do
if test ! -d libraries/$d if test ! -d libraries/$d
then then
echo "Looks like you're missing libraries/$d," echo "Looks like you're missing libraries/$d,"
echo "maybe you haven't done 'sh darcs-all get'?" echo "maybe you haven't done './darcs-all get'?"
exit 1 exit 1
fi fi
done done
......
#!/bin/sh #!/usr/bin/perl -w
set -e use strict;
top_dirs="nofib testsuite" my @top_dirs = ("nofib", "testsuite");
# Figure out where to get the other repositories from, # Figure out where to get the other repositories from,
# based on where this GHC repo came from. # based on where this GHC repo came from.
defaultrepo=`cat _darcs/prefs/defaultrepo` my $defaultrepo = `cat _darcs/prefs/defaultrepo`;
case $defaultrepo in chomp $defaultrepo;
# HTTP or SSH: my $defaultrepo_base;
http://* | *:*) my $defaultrepo_lib;
defaultrepo_base="`echo $defaultrepo | sed 's!/ghc$!!'`"
defaultrepo_lib="$defaultrepo_base"/packages;; if ($defaultrepo =~ /:/) {
# Local filesystem (assumes a checked-out tree): # HTTP or SSH
/*) $defaultrepo_base = $defaultrepo;
defaultrepo_base="$defaultrepo" $defaultrepo_base =~ s#/ghc$##;
defaultrepo_lib="$defaultrepo"/libraries;; $defaultrepo_lib = "$defaultrepo_base/packages";
esac
quiet=NO
message()
{
if [ "$quiet" = "NO" ]; then
echo "$@"
fi
} }
elsif ($defaultrepo =~ /^\//) {
darcsall() # Local filesystem (assumes a checked-out tree):
{ $defaultrepo_base = $defaultrepo;
message "== running darcs $@ at the top level" $defaultrepo_lib = "$defaultrepo/libraries";
darcs "$@"
for dir in $top_dirs; do
if test -d $dir -a -d $dir/_darcs; then
message "== running darcs $@ in $dir"
darcs "$@" --repodir $dir
else
message "== $dir not present or not a repository; skipping"
fi
done
for pkg in `cat libraries/core-packages libraries/extra-packages`; do
if test -d libraries/$pkg; then
message "== running darcs $@ in libraries/$pkg"
darcs "$@" --repodir libraries/$pkg
else
echo "warning: $pkg doesn't seem to exist, use 'darcs-all get' to get it"
fi
done
} }
else {
darcsget() die "Couldn't work out defaultrepo";
{
case $* in
*--complete*|*--partial*)
additional_flag="" ;;
*)
echo "warning: adding --partial, to override use --complete"
additional_flag="--partial" ;;
esac
if test "$nofib" = "YES"; then
if test -d nofib; then
echo "warning: nofib already present; omitting"
else
repo="$defaultrepo_base"/nofib
message "== running darcs get $additional_flag $@ $repo"
darcs get $additional_flag "$@" $repo
fi
fi
if test "$testsuite" = "YES"; then
if test -d testsuite; then
echo "warning: testsuite already present; omitting"
else
repo="$defaultrepo_base"/testsuite
message "== running darcs get $additional_flag $@ $repo"
darcs get $additional_flag "$@" $repo
fi
fi
cd libraries
if test "$extra" = "YES"; then
packages=`cat core-packages extra-packages`
else
packages=`cat core-packages`
fi
for pkg in $packages; do
if test -d $pkg; then
echo "warning: $pkg already present; omitting"
else
repo=$defaultrepo_lib/$pkg
message "== running darcs get $additional_flag $@ $repo"
darcs get $additional_flag "$@" $repo
fi
done
} }
if test ! -d _darcs -o ! -d compiler; then my $verbose = 1;
echo "error: darcs-all must be run from the top level of the ghc tree." my $ignore_failure = 0;
exit 1;
fi
case $* in
*-q*) quiet=YES;;
esac
# --extra says we grab the extra libs with 'get'. It has no effect on # --extra says we grab the extra libs with 'get'. It has no effect on
# the other commands. # the other commands.
extra=NO my $extra = 0;
# --nofib/--testsuite tell get to also grab the respective repos. # --nofib/--testsuite tell get to also grab the respective repos.
# They have no effect on the other commands. # They have no effect on the other commands.
nofib=NO my $nofib = 0;
testsuite=NO my $testsuite = 0;
args_done=NO while ($#_ ne -1) {
my $arg = shift;
while [ "$args_done" = NO ] if ($arg eq "-q") {
do $verbose = 0;
case $1 in }
--extra) shift; extra=YES;; elsif ($arg eq "--extra") {
--nofib) shift; nofib=YES;; $extra = 1;
--testsuite) shift; testsuite=YES;; }
*) args_done=YES;; elsif ($arg eq "--nofib") {
esac $nofib = 1;
done }
elsif ($arg eq "--testsuite") {
case $1 in $testsuite = 1;
get) shift; darcsget "$@";; }
# Hack around whatsnew failing if there are no changes else {
w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall "$@";; unshift @_, $arg;
*) darcsall "$@";; last;
esac }
}
sub message {
if ($verbose) {
print "@_\n";
}
}
sub warning {
print "warning: @_\n";
}
sub darcs {
message "== running darcs @_";
system ("darcs", @_) == 0
or $ignore_failure
or die "darcs failed: $?";
}
sub darcsall {
darcs @_;
for my $dir (@top_dirs) {
if (-d $dir && -d "$dir/_darcs") {
darcs (@_, "--repodir", $dir);
}
else {
message "== $dir not present or not a repository; skipping";
}
}
for my $pkg (`cat libraries/core-packages libraries/extra-packages`) {
chomp $pkg;
if (-d "libraries/$pkg") {
darcs (@_, "--repodir", "libraries/$pkg");
}
else {
warning("$pkg doesn't exist, use 'darcs-all get' to get it");
}
}
}
sub darcsgetpackage {
my ($get_it, $r_flags, $repo_root, $package) = @_;
if ($get_it) {
if (-d $package) {
warning("$package already present; omitting");
}
else {
darcs (@$r_flags, "$repo_root/$package");
}
}
}
sub darcsget {
my $r_flags;
if (! grep /(?:--complete|--partial)/, @_) {
warning("adding --partial, to override use --complete");
$r_flags = [@_, "--partial"];
}
else {
$r_flags = \@_;
}
darcsgetpackage($nofib, $r_flags, $defaultrepo_base, "nofib");
darcsgetpackage($testsuite, $r_flags, $defaultrepo_base, "testsuite");
chdir "libraries";
my @packages;
if ($extra) {
@packages = `cat core-packages extra-packages`;
}
else {
@packages = `cat core-packages`;
}
for my $pkg (@packages) {
chomp $pkg;
darcsgetpackage(1, $r_flags, $defaultrepo_lib, $pkg);
}
}
sub main {
if (! -d "_darcs" || ! -d "compiler") {
die "error: darcs-all must be run from the top level of the ghc tree."
}
if ($#_ eq -1) {
die "What do you want to do?";
}
my $command = $_[0];
if ($command eq "get") {
darcsget @_;
}
else {
if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
# Hack around whatsnew failing if there are no changes
$ignore_failure = 1;
}
darcsall @_;
}
}
main(@ARGV);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment