summary refs log tree commit diff
path: root/pkgs/build-support/fetchmtn/builder.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/fetchmtn/builder.sh')
-rw-r--r--pkgs/build-support/fetchmtn/builder.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchmtn/builder.sh b/pkgs/build-support/fetchmtn/builder.sh
new file mode 100644
index 000000000000..58fd7e41c9a7
--- /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
+