Allow users to reproduce builds on their own systems
[?]
Apr 4, 2013, 3:30 PM
HZWUT4YNGQE3RSTS7XAZK4UQCUHZ5KHA7CHL2JNSXQIPPB6UGKTQCDependencies
- [2]
K22TMPH5Make the info tables less compressed - [3]
ND75XNSQAllow showing all evaluations that contain a given build - [*]
LBNVQXUB* Build the /build stuff in a separate controller. - [*]
HSVVEKTY* Start of a JSON API to get information about a specific build. - [*]
J5UVLXOK* Start of a basic Catalyst web interface. - [*]
3PNG7NIBRemove trailing whitespace - [*]
D5QIOJGP* Move everything up one directory.
Change contents
- edit in src/lib/Hydra/Controller/Build.pm at line 593
}sub reproduce : Chained('build') PathPart('reproduce') Args(0) {my ($self, $c) = @_;$c->response->content_type('text/x-shellscript');$c->response->header('Content-Disposition', 'attachment; filename="reproduce-build-' . $c->stash->{build}->id . '.sh"');$c->stash->{template} = 'reproduce.tt'; - edit in src/root/build.tt at line 80
[% IF build.nixexprinput %]<a class="btn btn-info pull-right clearfix"href="[%c.uri_for('/build' build.id 'reproduce')%]">Reproduce this build locally</a>[% END %] - file addition: reproduce.tt[9.1486]
#! /bin/sh# This script has been generated automatically by Hydra from the build# at [% c.uri_for('/build' build.id) %].set -eexport NIX_PATH=srcDir=${TMPDIR:-/tmp}/build-[% build.id +%]mkdir -p "$srcDir"/buildcd "$srcDir"/buildecho "storing sources in $srcDir" >&2declare -a args# Fetch the inputs.[%+ FOREACH input IN build.inputs %]inputDir=[%+ IF input.type == "git" %]inputDir="$srcDir/[% input.name %]/git-export"if ! [ -d "$inputDir" ]; thenecho "fetching Git input ‘[% input.name %]’ from ‘[% input.uri %]’ (commit [% input.revision %])..." >&2inputDirTmp="$inputDir.tmp"rm -rf "$inputDirTmp"mkdir -p "$inputDirTmp"git clone '[% input.uri %]' "$inputDirTmp"(cd "$inputDirTmp" && git checkout '[% input.revision %]')revCount="$(cd "$inputDirTmp" && (git rev-list '[% input.revision %]' | wc -l))"rm -rf "$inputDirTmp/.git"mv "$inputDirTmp" "$inputDir"fiargs+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; shortRev = \"[% input.revision.substr(0, 7) %]\"; revCount = \"$revCount\"; }")[%+ ELSIF input.type == "hg" %]inputDir="$srcDir/[% input.name %]/hg-archive"if ! [ -d "$inputDir" ]; thenecho "fetching Mercurial input ‘[% input.name %]’ from ‘[% input.uri %]’ (commit [% input.revision %])..." >&2inputDirTmp="$inputDir.tmp"rm -rf "$inputDirTmp"hg clone '[% input.uri %]' "$inputDirTmp" -r '[% input.revision %]'rm -rf "$inputDirTmp/.hg"mv "$inputDirTmp" "$inputDir"fiargs+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; revCount = \"$revCount\"; }")[%+ ELSIF input.type == "svn" %]inputDir="$srcDir/[% input.name %]/svn-export"if ! [ -d "$inputDir" ]; thenecho "fetching Subversion input ‘[% input.name %]’ from ‘[% input.uri %]’ (commit [% input.revision %])..." >&2rm -rf "$inputDir.tmp"svn export '[% input.uri %]@[% input.revision %]' "$inputDir.tmp"mv "$inputDir.tmp" "$inputDir"fiargs+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; }")[% ELSIF input.type == "string" %]args+=(--arg '[% input.name %]' '"[% input.value %]"')[% ELSIF input.type == "boolean" %]args+=(--arg '[% input.name %]' '[% input.value %]')[% ELSE %]echo "$0: input ‘[% input.name %]’ has unsupported type ‘[% input.type %]’" >&2exit 1[% END %][% IF input.name == build.nixexprinput +%]nixExprInputDir="$inputDir"[%+ END %]if [ -n "$inputDir" ]; thenNIX_PATH="$NIX_PATH${NIX_PATH:+:}[% input.name %]=$inputDir"fi[%+ END %]# Run nix-build.if [ -z "$nixExprInputDir" ]; thenecho "$0: don't know the path to the Nix expression!" >&2exit 1fi#args+=(--option binary-caches '[% c.uri_for('/') %]')# Since Hydra runs on x86_64-linux, pretend we're one. This matters# when evaluating jobs that rely on builtins.currentSystem.args+=(--option system x86_64-linux)echo "Nix path is $NIX_PATH" >&2echo "Nix args are ${args[@]}" >&2nix-build "$nixExprInputDir/[% build.nixexprpath %]" -A '[% build.job.name %]' "${args[@]}" "$@"