diff options
Diffstat (limited to 'pkgs/build-support/setup-hooks/multiple-outputs.sh')
-rw-r--r-- | pkgs/build-support/setup-hooks/multiple-outputs.sh | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index 8a2fc2f915e91..fc1bb3e164583 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -4,16 +4,30 @@ preFixupHooks+=(_multioutDocs) preFixupHooks+=(_multioutDevs) postFixupHooks+=(_multioutPropagateDev) -# Assign the first string containing nonempty variable to the variable named $1 +# _assignFirst varName otherVarNames* +# +# Set the value of the variable named $varName to the first of otherVarNames +# that refers to a non-empty variable name. +# +# If none of otherVarNames refers to a non-empty variable, the error message is +# specific to this function's use case, which is setting up the output variables. _assignFirst() { local varName="$1" local REMOVE=REMOVE # slightly hacky - we allow REMOVE (i.e. not a variable name) shift - while (( $# )); do - if [ -n "${!1-}" ]; then eval "${varName}"="$1"; return; fi - shift + for var in "$@"; do + if [ -n "${!var-}" ]; then eval "${varName}"="${var}"; return; fi done - echo "Error: _assignFirst found no valid variant!" + echo + echo "error: _assignFirst: could not find a non-empty variable to assign to ${varName}. The following variables were all unset or empty: $*." + if [ -z "${out:-}" ]; then + echo ' If you do not want an "out" output in your derivation, make sure to define' + echo ' the other specific required outputs. This can be achieved by picking one' + echo " of $* to add as an output." + echo ' You do not have to remove "out" if you want to have a different default' + echo ' output, as it is the first output in `outputs` that is the default output.' + echo + fi return 1 # none found } |