summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2009-07-07 10:02:09 +0000
committerMichael Raskin <7c6f434c@mail.ru>2009-07-07 10:02:09 +0000
commitd79e32c9b9551c7a943873cae9c732a92287944b (patch)
treedb3aabfa00170a4c9eb43dafd9aeb6f638591a70
parentaf58e1024bec81a42ceae0fa07097917bfc4029b (diff)
downloadnixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.tar
nixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.tar.gz
nixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.tar.bz2
nixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.tar.lz
nixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.tar.xz
nixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.tar.zst
nixpkgs-d79e32c9b9551c7a943873cae9c732a92287944b.zip
Add fetchmtn
svn path=/nixpkgs/trunk/; revision=16204
-rw-r--r--pkgs/build-support/fetchmtn/builder.sh41
-rw-r--r--pkgs/build-support/fetchmtn/default.nix32
2 files changed, 73 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchmtn/builder.sh b/pkgs/build-support/fetchmtn/builder.sh
new file mode 100644
index 00000000000..58fd7e41c9a
--- /dev/null
+++ b/pkgs/build-support/fetchmtn/builder.sh
@@ -0,0 +1,41 @@
+source $stdenv/setup
+
+set -x
+
+header "getting revision $selector";
+
+done=;
+for source in $dbs; do
+	if mtn pull --debug --db "$cacheDB" "$source" "${branch}"; then
+		revision="$(mtn --db "$cacheDB" au toposort $(mtn --db "$cacheDB" au select "$selector") | tail -1)";
+		if [ -n "$revision" ]; then
+			if mtn --db "$cacheDB" au get_revision "$revision"; then
+				echo "found revision $revision"
+				done=1;
+			else
+				echo "revision $revision does not exist";
+			fi
+		else
+			echo "selector $selector does not match any revision";
+		fi
+	else
+		echo "pulling branch $branch wasn't succesfull";
+	fi;
+	if test -n "$done"; then
+		break;
+	fi;
+done;
+
+stopNest;
+
+header "checking out the revision $revision";
+
+if test -n "$done"; then
+	mtn checkout --db "$cacheDB" -r "$revision" "$out" -b "${branch}"
+else
+	echo "Needed revision still not found. Exiting";
+	exit 1;
+fi;
+
+stopNest
+
diff --git a/pkgs/build-support/fetchmtn/default.nix b/pkgs/build-support/fetchmtn/default.nix
new file mode 100644
index 00000000000..7fda2821905
--- /dev/null
+++ b/pkgs/build-support/fetchmtn/default.nix
@@ -0,0 +1,32 @@
+# You can specify some extra mirrors and a cache DB via options
+{stdenv, monotone, defaultDBMirrors ? [], cacheDB ? ""}:
+# dbs is a list of strings
+# each is an url for sync
+
+# selector is mtn selector, like h:org.example.branch
+# 
+{name ? "", dbs ? [], selector ? "", branch, md5 ? "", sha1 ? "", sha256 ? ""}:
+
+stdenv.mkDerivation {
+  name = if name != "" then name else "mtn-checkout";
+  builder = ./builder.sh;
+  buildInputs = [monotone];
+
+  outputHashAlgo = if sha256 == "" then (if sha1 == "" then "md5" else "sha1") else "sha256";
+  outputHashMode = "recursive";
+  outputHash = if sha256 == "" then (if sha1 == "" then md5 else sha1) else sha256;
+
+  dbs = defaultDBMirrors ++ dbs;
+  cacheDB = if cacheDB != "" then cacheDB else "./mtn-checkout.db";
+  selector = if selector != "" then selector else "h:" + branch;
+  inherit branch;
+
+  impureEnvVars = [
+    # We borrow these environment variables from the caller to allow
+    # easy proxy configuration.  This is impure, but a fixed-output
+    # derivation like fetchurl is allowed to do so since its result is
+    # by definition pure.
+    "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
+    ];
+}
+