#!/bin/bash cleanup_logs() { if [[ -f PKGBUILD ]]; then shopt -s nullglob dir="." files=("$dir/"*.log "$dir/"*.log.*) if [[ -f "${files[0]}" ]]; then mkdir -p "$dir/logs" mv "${files[@]}" "$dir/logs/" || return gzip -f "$dir/logs/"*.log "$dir/logs/"*.log.{1,2,3,4,5,6,7,8,9} fi fi } /usr/bin/pkgctl "$@" exitcode=$? if [[ "$1" == "build" ]]; then cleanup_logs fi exit "$exitcode"