Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
2.6 kB · 79 lines
Shell
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980# Run a builder, flip exit code, save log and fix outputs## Sub-goals:# - Delegate to another original builder passed via args# - Save the build log to output for further checks# - Make the derivation succeed if the original builder fails# - Make the derivation fail if the original builder returns exit code 0## Requirements:# This runs before, without and after stdenv. Do not modify the environment;# especially not before invoking the original builder. For example, use# "@" substitutions instead of PATH.# Do not export any variables.
# Stricter bashset -eu
# ------------------------# Run the original builder
echo "testBuildFailure: Expecting non-zero exit from builder and args: ${*@Q}"
("$@" 2>&1) | @coreutils@/bin/tee $TMPDIR/testBuildFailure.log \ | while IFS= read -r ln; do echo "original builder: $ln" done
r=${PIPESTATUS[0]}if [[ $r = 0 ]]; then echo "testBuildFailure: The builder did not fail, but a failure was expected!" exit 1fiecho "testBuildFailure: Original builder produced exit code: $r"
# -----------------------------------------# Write the build log to the default output
# Source structured attrs as per nixpkgs/pkgs/stdenv/generic/source-stdenv.sh## We need this so that we can read $outputs when `__structuredAttrs` is enabled## NOTE: This MUST be done after the original builder has finished!# Otherwise we could pollute its environment.if [ -e "${NIX_ATTRS_SH_FILE:-}" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
# Variables injected by replaceVars## `$outputs` is unordered when `__structuredAttrs` is enabled,# so we use `replaceVars` to pass in an ordered `$outputNames` array@vars@
declare -a outputPathsfor name in "${outputNames[@]}"; do # Either dereference $name, or access $outputs[] associative array outputPath=${!name:-${outputs[$name]}} outputPaths+=( "$outputPath" )donedefOutPath=${outputPaths[0]}
if [[ ! -d $defOutPath ]]; then if [[ -e $defOutPath ]]; then @coreutils@/bin/mv $defOutPath $TMPDIR/out-node @coreutils@/bin/mkdir $defOutPath @coreutils@/bin/mv $TMPDIR/out-node $defOutPath/result fifi
@coreutils@/bin/mkdir -p $defOutPath@coreutils@/bin/mv $TMPDIR/testBuildFailure.log $defOutPath/testBuildFailure.logecho $r >$defOutPath/testBuildFailure.exit
# ------------------------------------------------------# Put empty directories in place for any missing outputs
for outputPath in "${outputPaths[@]}"; do if [[ ! -e "${outputPath}" ]]; then @coreutils@/bin/mkdir "${outputPath}"; fidone