[WIP] print line number and message when abort

This commit is contained in:
leafee98 2023-03-24 20:14:51 +08:00
parent efb316796a
commit 0896012d95

30
makedeb
View file

@ -11,11 +11,12 @@ OVERRIDE_VERSION=""
ACTION="" ACTION=""
set -o functrace
set -o nounset set -o nounset
set -o errtrace set -o errtrace
set -o errexit set -o errexit
function err_occur { err "Build aborted in: %s" "$ACTION" ; } function err_occur { err "Build aborted in: %s" "$ACTION" ; err "Failed at $1: $2"; }
trap err_occur ERR trap 'err_occur "${LINENO}" "${BASH_COMMAND}"' ERR
# prefer terminal safe colored and bold text when tput is supported # prefer terminal safe colored and bold text when tput is supported
if tput setaf 0 &>/dev/null; then if tput setaf 0 &>/dev/null; then
@ -248,25 +249,21 @@ if (( FAKE_PACKAGE )); then
fi fi
if is_function package; then if is_function package; then
ACTION="package" ACTION="custom package"; msg "run function: %s..." "${ACTION}"
msg "run custom function: %s..." "package"
package package
fi fi
ACTION="generating deb" ACTION="generating deb package"; msg "${ACTION}..."
msg "generating deb package..."
generate_deb generate_deb
exit $? exit $?
fi fi
ACTION="clean" ACTION="cleaning"; msg "${ACTION}..."
msg "cleaning..."
rm -rf "${srcdir}" "${pkgdir}" rm -rf "${srcdir}" "${pkgdir}"
mkdir -p ${srcdir} ${pkgdir} mkdir -p ${srcdir} ${pkgdir}
ACTION="retrieve source" ACTION="retrieving source"; msg "${ACTION}..."
msg "retrieving source..."
for s in "${source[@]}"; do for s in "${source[@]}"; do
if grep "::" <<< "$s" > /dev/null; then if grep "::" <<< "$s" > /dev/null; then
file_name="${s%%::*}" file_name="${s%%::*}"
@ -278,7 +275,8 @@ for s in "${source[@]}"; do
retrive_source_single "${file_name}" "${url}" retrive_source_single "${file_name}" "${url}"
done done
msg "extracting source..."
ACTION="extracting source"; msg "${ACTION}..."
for s in "${source[@]}"; do for s in "${source[@]}"; do
if grep "::" <<< "$s" > /dev/null; then if grep "::" <<< "$s" > /dev/null; then
file_name="${s%%::*}" file_name="${s%%::*}"
@ -289,22 +287,20 @@ for s in "${source[@]}"; do
done done
if is_function build; then if is_function build; then
ACTION="build" ACTION="custom build"; msg "run function: %s..." "${ACTION}"
msg "run custom function: %s..." "build"
build build
fi fi
ACTION="pkgver" ACTION="custom pkgver";
if [[ -n "${OVERRIDE_VERSION}" ]] ; then if [[ -n "${OVERRIDE_VERSION}" ]] ; then
msg "Using override version: %s" "${OVERRIDE_VERSION}" msg "Using override version: %s" "${OVERRIDE_VERSION}"
pkgver="${OVERRIDE_VERSION}" pkgver="${OVERRIDE_VERSION}"
elif is_function pkgver; then elif is_function pkgver; then
msg "run custom function: %s..." "pkgver" msg "run function: %s..." "${ACTION}"
pkgver="$(pkgver)" pkgver="$(pkgver)"
fi fi
ACTION="generate control" ACTION="generating control"; msg "${ACTION}..."
msg "generating control..."
mkdir -p "${pkgdir}/DEBIAN" mkdir -p "${pkgdir}/DEBIAN"
echo 9 > "${pkgdir}/DEBIAN/compat" echo 9 > "${pkgdir}/DEBIAN/compat"
debian_control > "${pkgdir}/DEBIAN/control" debian_control > "${pkgdir}/DEBIAN/control"