+if ($defaultrepo =~ /^...*:/) {
+ # HTTP or SSH
+ # Above regex says "at least two chars before the :", to avoid
+ # catching Win32 drives ("C:\").
+ $defaultrepo_base = $defaultrepo;
+ $defaultrepo_base =~ s#/[^/]+/?$##;
+ $defaultrepo_lib = "$defaultrepo_base/packages";
+ $hsc2hs_repo_loc = $defaultrepo_base;
+}
+elsif ($defaultrepo =~ /^(\.\.)?\//) {
+ # Local filesystem, either absolute or relative path
+ # (assumes a checked-out tree):
+ $defaultrepo_base = $defaultrepo;
+ $defaultrepo_lib = "$defaultrepo/libraries";
+ $hsc2hs_repo_loc = "$defaultrepo_base/utils";
+}
+else {
+ die "Couldn't work out defaultrepo";
+}
+
+my $verbose = 2;
+my $ignore_failure = 0;
+
+# --extra says we grab the extra libs with 'get'. It has no effect on
+# the other commands.
+my $extra = 0;
+# --nofib/--testsuite tell get to also grab the respective repos.
+# They have no effect on the other commands.
+my $nofib = 0;
+my $testsuite = 0;
+
+sub message {
+ if ($verbose >= 2) {
+ print "@_\n";
+ }
+}
+
+sub warning {
+ if ($verbose >= 1) {
+ print "warning: @_\n";
+ }
+}
+
+sub darcs {
+ message "== running darcs @_";
+ system ("darcs", @_) == 0
+ or $ignore_failure
+ or die "darcs failed: $?";
+}