From 659898bd6738454acb3fa5de96a926daea6aa96a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 2 May 2013 16:04:28 +0200 Subject: [PATCH] reproduce.tt: Add --help flag And a --dir flag to override the directory where inputs etc. are stored. --- src/root/reproduce.tt | 69 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/src/root/reproduce.tt b/src/root/reproduce.tt index 0d394ca8..f8159ce7 100644 --- a/src/root/reproduce.tt +++ b/src/root/reproduce.tt @@ -1,18 +1,65 @@ -#! /bin/sh +#! /usr/bin/env bash # This script has been generated automatically by Hydra from the build # at [% c.uri_for('/build' build.id) %]. set -e +tmpDir=${TMPDIR:-/tmp}/build-[% build.id +%] +declare -a args extraArgs + + +# Process the command line. +while [ $# -gt 0 ]; do + arg="$1" + shift + if [ "$arg" = --help ]; then + cat <&2 + exit 1 + fi + shift + else + extraArgs+=("$arg") + fi +done + + export NIX_PATH= -srcDir=${TMPDIR:-/tmp}/build-[% build.id +%] -mkdir -p "$srcDir"/build -cd "$srcDir"/build -echo "storing sources in $srcDir" >&2 - -declare -a args +mkdir -p "$tmpDir" +cd "$tmpDir" +echo "storing sources in $tmpDir" >&2 # Fetch the inputs. @@ -22,7 +69,7 @@ inputDir= [%+ IF input.type == "git" %] -inputDir="$srcDir/[% input.name %]/git-export" +inputDir="$tmpDir/[% input.name %]/git-export" if ! [ -d "$inputDir" ]; then echo "fetching Git input ‘[% input.name %]’ from ‘[% input.uri %]’ (commit [% input.revision %])..." >&2 @@ -40,7 +87,7 @@ args+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revisio [%+ ELSIF input.type == "hg" %] -inputDir="$srcDir/[% input.name %]/hg-archive" +inputDir="$tmpDir/[% input.name %]/hg-archive" if ! [ -d "$inputDir" ]; then echo "fetching Mercurial input ‘[% input.name %]’ from ‘[% input.uri %]’ (commit [% input.revision %])..." >&2 @@ -55,7 +102,7 @@ args+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revisio [%+ ELSIF input.type == "svn" %] -inputDir="$srcDir/[% input.name %]/svn-export" +inputDir="$tmpDir/[% input.name %]/svn-export" if ! [ -d "$inputDir" ]; then echo "fetching Subversion input ‘[% input.name %]’ from ‘[% input.uri %]’ (commit [% input.revision %])..." >&2 @@ -104,4 +151,4 @@ args+=(--option system x86_64-linux) echo "Nix path is $NIX_PATH" >&2 echo "Nix args are ${args[@]}" >&2 -nix-build "$nixExprInputDir/[% build.nixexprpath %]" -A '[% build.job.name %]' "${args[@]}" "$@" +nix-build "$nixExprInputDir/[% build.nixexprpath %]" -A '[% build.job.name %]' "${args[@]}" "${extraArgs[@]}"