Add fetchmtn

svn path=/nixpkgs/trunk/; revision=16204
This commit is contained in:
Michael Raskin 2009-07-07 10:02:09 +00:00
parent af58e1024b
commit d79e32c9b9
2 changed files with 73 additions and 0 deletions

View File

@ -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

View File

@ -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"
];
}