Add fetchmtn
svn path=/nixpkgs/trunk/; revision=16204
This commit is contained in:
parent
af58e1024b
commit
d79e32c9b9
41
pkgs/build-support/fetchmtn/builder.sh
Normal file
41
pkgs/build-support/fetchmtn/builder.sh
Normal 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
|
||||
|
32
pkgs/build-support/fetchmtn/default.nix
Normal file
32
pkgs/build-support/fetchmtn/default.nix
Normal 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"
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user