kiss: Store builds logs on fail

This commit is contained in:
Dylan Araps 2020-01-28 10:08:15 +02:00
parent 43c68c066b
commit 60ac1c094e
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 19 additions and 6 deletions

21
kiss
View File

@ -640,8 +640,18 @@ pkg_build() {
log "$pkg" "Starting build" log "$pkg" "Starting build"
# Call the build script. # Call the build script, log the output to the terminal
"$repo_dir/build" "$pkg_dir/$pkg" || die "$pkg" "Build failed" # and to a file. There's no PIPEFAIL in POSIX shelll so
# we must resort to tricks like killing the script ourselves.
{ "$repo_dir/build" "$pkg_dir/$pkg" || {
log "$pkg" "Build failed"
pkg_clean
kill 0
} } 2>&1 | tee "$log_dir/$pkg-$pid-$time"
# Delete the log file if the build succeeded to prevent
# the directory from filling very quickly with useless logs.
[ "$KISS_DEBUG" = 1 ] || rm -f "$log_dir/$pkg-$pid-$time"
# Copy the repository files to the package directory. # Copy the repository files to the package directory.
# This acts as the database entry. # This acts as the database entry.
@ -1072,8 +1082,6 @@ pkg_clean() {
# to the build. # to the build.
stty -F /dev/tty echo 2>/dev/null stty -F /dev/tty echo 2>/dev/null
[ "$KISS_DEBUG" != 1 ] || return
# Block 'Ctrl+C' while cache is being cleaned. # Block 'Ctrl+C' while cache is being cleaned.
trap '' INT trap '' INT
@ -1245,6 +1253,10 @@ main() {
# POSIX correctness. # POSIX correctness.
grep=$(command -v ggrep) || grep='grep' grep=$(command -v ggrep) || grep='grep'
# Store the date and time of script invocation to be used as the name
# of the log files the package manager creates uring builds.
time=$(date '+%d-%m-%Y-%H:%M')
# This allows for automatic setup of a KISS chroot and will # This allows for automatic setup of a KISS chroot and will
# do nothing on a normal system. # do nothing on a normal system.
mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||: mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||:
@ -1256,6 +1268,7 @@ main() {
"${pkg_dir:=$cac_dir/pkg-$pid}" \ "${pkg_dir:=$cac_dir/pkg-$pid}" \
"${tar_dir:=$cac_dir/extract-$pid}" \ "${tar_dir:=$cac_dir/extract-$pid}" \
"${src_dir:=$cac_dir/sources}" \ "${src_dir:=$cac_dir/sources}" \
"${log_dir:=$cac_dir/logs}" \
"${bin_dir:=$cac_dir/bin}" \ "${bin_dir:=$cac_dir/bin}" \
|| die "Couldn't create cache directories" || die "Couldn't create cache directories"

4
kiss.1
View File

@ -69,8 +69,8 @@ export KISS_FORCE=0
# This can be used to have the package manager run in a "fake root". # This can be used to have the package manager run in a "fake root".
export KISS_ROOT=/ export KISS_ROOT=/
# Keep build, package and extraction cache directories for debugging # Keep build logs around for successful builds and not just failing
# purposes. # ones. Helpful when debugging.
# #
# Set it to '1' to enable. # Set it to '1' to enable.
export KISS_DEBUG=0 export KISS_DEBUG=0