From ab0acd059481ea0b2dc9dfc9cd5ee08aaa676212 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Sun, 1 Sep 2019 11:50:14 +0000 Subject: kiss: save errored builds to log files FossilOrigin-Name: 3accf6c9cf799bb60600d0858dd03c0ef750b495f4d6e3259332e2cc04d7bcc7 --- kiss | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'kiss') diff --git a/kiss b/kiss index a3a3249..96aba14 100755 --- a/kiss +++ b/kiss @@ -507,10 +507,21 @@ pkg_build() { # to avoid collisions with other packages. mkdir -p "$pkg_dir/$pkg/$pkg_db" - # Move to the build directory and call the build script. + # Move to the build directory. cd "$mak_dir/$pkg" - "$repo_dir/build" "$pkg_dir/$pkg" || - die "[$pkg] Build failed" + + # Call the build script and create a temporary file on error. + # This is the simplest way to mimic "pipefail" in POSIX sh as + # you cannot exit from within a pipe. + { "$repo_dir/build" "$pkg_dir/$pkg" || :> "$pkg-err"; } | tee log + + # If the file exists the build errored, die here and save the log. + [ -f "$pkg-err" ] && { + cp -f log "$log_dir/$pkg-$date.log" + + die "[$pkg] Build failed" \ + "[$pkg] Build log saved to '$log_dir/$pkg-$date.log'" + } # Copy the repository files to the package directory. # This acts as the database entry. @@ -1094,6 +1105,9 @@ main() { # variable is ever changed. old_ifs=$IFS + # Store the current date and time for build error logs. + date=$(date +%Y-%m-%d-%H:%M) + # Catch errors and ensure that build files and directories are cleaned # up before we die. This occurs on 'Ctrl+C' as well as success and error. trap pkg_clean EXIT INT @@ -1106,6 +1120,7 @@ main() { "${tar_dir:=$cac_dir/extract-$pid}" \ "${src_dir:=$cac_dir/sources}" \ "${bin_dir:=$cac_dir/bin}" \ + "${log_dir:=$cac_dir/logs}" \ || die "Couldn't create cache directories" args "$@" -- cgit v1.2.3 From 117dd1e13e5f4ed0a05ea51e08dc7ad643fea474 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Sun, 1 Sep 2019 12:02:06 +0000 Subject: logs: simplify temp files. FossilOrigin-Name: bd8d4b803dc00652b3a6a127cf28c3e405dc9a8129818682ff978f4b7be935d5 --- kiss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kiss') diff --git a/kiss b/kiss index 96aba14..112bf9e 100755 --- a/kiss +++ b/kiss @@ -513,10 +513,10 @@ pkg_build() { # Call the build script and create a temporary file on error. # This is the simplest way to mimic "pipefail" in POSIX sh as # you cannot exit from within a pipe. - { "$repo_dir/build" "$pkg_dir/$pkg" || :> "$pkg-err"; } | tee log + { "$repo_dir/build" "$pkg_dir/$pkg" || :> err; } | tee log # If the file exists the build errored, die here and save the log. - [ -f "$pkg-err" ] && { + [ -f err ] && { cp -f log "$log_dir/$pkg-$date.log" die "[$pkg] Build failed" \ -- cgit v1.2.3