diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2009-07-07 10:02:09 +0000 |
---|---|---|
committer | Michael Raskin <7c6f434c@mail.ru> | 2009-07-07 10:02:09 +0000 |
commit | d79e32c9b9551c7a943873cae9c732a92287944b (patch) | |
tree | db3aabfa00170a4c9eb43dafd9aeb6f638591a70 /pkgs | |
parent | af58e1024bec81a42ceae0fa07097917bfc4029b (diff) | |
download | nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.tar nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.tar.gz nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.tar.bz2 nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.tar.lz nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.tar.xz nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.tar.zst nixlib-d79e32c9b9551c7a943873cae9c732a92287944b.zip |
Add fetchmtn
svn path=/nixpkgs/trunk/; revision=16204
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/fetchmtn/builder.sh | 41 | ||||
-rw-r--r-- | pkgs/build-support/fetchmtn/default.nix | 32 |
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 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 + diff --git a/pkgs/build-support/fetchmtn/default.nix b/pkgs/build-support/fetchmtn/default.nix new file mode 100644 index 000000000000..7fda2821905f --- /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" + ]; +} + |