From 61b5972ebbe5514d9bba007f9d97fc59a82a5897 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 14 Jul 2021 13:02:56 +0300 Subject: [PATCH] kiss: give build scripts some environment variables - Defines DESTDIR so you no longer need to export it yourself. - Defines CC and CXX so all builds will now work with other compilers if gcc/g++ are the default when unset. - Defines KISS_ROOT with the sanitized version used by the package manager. It can now be safely joined with other paths. ("$KISS_ROOT/path/to/file") --- kiss | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/kiss b/kiss index 672649e..b72ca7b 100755 --- a/kiss +++ b/kiss @@ -804,13 +804,27 @@ pkg_build() { # Call the build script, log the output to the terminal and to a file. # There's no PIPEFAIL in POSIX shell so we must resort to tricks like kill. - { "$repo_dir/build" "$pkg_dir/$1" "$repo_ver" 2>&1 || { - log "$1" "Build failed" - log "$1" "Log stored to $log_dir/$1-$time-$pid" - run_hook build-fail "$pkg" "$pkg_dir/$1" - pkg_clean - kill 0 - } } | tee "$log_dir/$1-$time-$pid" + { + set -a + + # Give the script a modified environment. Define CC and CXX giving them + # the generic values cc and c++. Define KISS_ROOT sanitized to ensure + # safe path joining in build files. + CC="${CC:-cc}" \ + CXX="${CXX:-c++}" \ + DESTDIR="$pkg_dir/$1" \ + KISS_ROOT="$KISS_ROOT" \ + + "$repo_dir/build" "$pkg_dir/$1" "$repo_ver" 2>&1 || { + log "$1" "Build failed" + log "$1" "Log stored to $log_dir/$1-$time-$pid" + run_hook build-fail "$pkg" "$pkg_dir/$1" + pkg_clean + kill 0 + } + + set +a + } | tee "$log_dir/$1-$time-$pid" # Delete the log file if the build succeeded to prevent the directory # from filling very quickly with useless logs.