pkgmeek: customize the status message based on the user's settings for IGNORE_NEW and IGNORE_MISSING

This commit is contained in:
John McQuah 2022-06-02 20:29:57 -04:00
parent be1a0eca6e
commit 0b7e71ec1e

View File

@ -56,9 +56,9 @@ for (( s=0; s<${#source[@]}; s++ )); do
[ -z "${renames[$s]}" ] || [ "${renames[$s]}" = "SKIP" ] || \ [ -z "${renames[$s]}" ] || [ "${renames[$s]}" = "SKIP" ] || \
_local_[$s]="${renames[$s]}" _local_[$s]="${renames[$s]}"
done done
# Example: _local_ = ( upstream-ball-v12.tgz # Example: _local_ = ( some-git-repo/
# random.patch # upstream-ball-v12.tgz
# some-git-repo/ ) # random.patch )
# The effective user should at least have write permissions on $PWD # The effective user should at least have write permissions on $PWD
[ -w "$(dirname "$work")" ] || work="$(pwd)"/work [ -w "$(dirname "$work")" ] || work="$(pwd)"/work
@ -96,7 +96,7 @@ check_pkg_mtime; pkg_utd=$?
# Some further tests before proceeding with the build # Some further tests before proceeding with the build
[ "$PKGMK_DOWNLOAD_ONLY" = "no" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || \ [ "$PKGMK_DOWNLOAD_ONLY" = "no" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || \
[ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] || \ [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] || \
[ "$PKGMK_EXTRACT_ONLY" = "yes" ] || [ "$errDL" = 0 ] || exit $(( E_DOWNLOAD*(errDL != 0) )) [ "$PKGMK_EXTRACT_ONLY" = "yes" ] || [ $errDL != 0 ] || exit $(( E_DOWNLOAD*(errDL != 0) ))
# Take into account all the actions that can be done with a previously built package, # Take into account all the actions that can be done with a previously built package,
# or with a full set of sources # or with a full set of sources
@ -140,8 +140,7 @@ fi
# All the sources should be here by now, let's verify that we can trust them. # All the sources should be here by now, let's verify that we can trust them.
readonly cs_fail_msg="Use '--ignore-signature' to override, if you have determined integrity by other means." readonly cs_fail_msg="Use '--ignore-signature' to override, if you have determined integrity by other means."
[ "$PKGMK_IGNORE_SIG" = "yes" ] || \ [ "$PKGMK_IGNORE_SIG" = "yes" ] || { check_signature "pre-build" | parse_signify_output;
{ check_signature "pre-build" | parse_signify_output;
case $? in case $? in
0) info "Sources successfully authenticated." ;; 0) info "Sources successfully authenticated." ;;
1) error "Signature file missing or corrupted." ; echo "$cs_fail_msg" ;; 1) error "Signature file missing or corrupted." ; echo "$cs_fail_msg" ;;
@ -164,7 +163,7 @@ if [ "$pkg_utd" = 0 ] || [ "$PKGMK_FORCE" = "yes" ]; then
esac esac
done done
[ $errUZ != 0 ] || info "Sources successfully unpacked." || \ [ $errUZ = 0 ] && info "Sources successfully unpacked." || \
{ error "Failed to unpack all sources."; exit "$E_UNPACK"; } { error "Failed to unpack all sources."; exit "$E_UNPACK"; }
[ "$PKGMK_EXTRACT_ONLY" = "no" ] || exit 0 [ "$PKGMK_EXTRACT_ONLY" = "no" ] || exit 0
@ -356,14 +355,14 @@ validate_pkgfile() { # called from within PKGMK_ROOT
} }
check_reqvars () { check_reqvars () {
local checksum local checksum nullvars;
read -r checksum read -r checksum
[ $((checksum & 1)) = 1 ] && absent=" 'name'" [ $((checksum & 1)) = 1 ] && nullvars=" 'name'"
[ $((checksum & 2)) = 2 ] && absent+=" 'version'" [ $((checksum & 2)) = 2 ] && nullvars+=" 'version'"
[ $((checksum & 4)) = 4 ] && absent+=" 'release'" [ $((checksum & 4)) = 4 ] && nullvars+=" 'release'"
[ $((checksum & 8)) = 8 ] && absent+=" 'build()'" [ $((checksum & 8)) = 8 ] && nullvars+=" 'build()'"
[ "$checksum" = 0 ] || { error "Pkgfile does not specify these required variables:"; \ [ "$checksum" = 0 ] || { error "Pkgfile does not specify these required variables:"; \
info "$absent"; exit "$E_PKGFILE"; } info "$nullvars"; exit "$E_PKGFILE"; }
} }
check_pkg_mtime() { # can be called even if some sources are missing check_pkg_mtime() { # can be called even if some sources are missing
@ -400,7 +399,7 @@ cat_manifest() {
check_manifest() { check_manifest() {
local FILTER TRUTH CN CM local FILTER TRUTH CN CM
local FILE="$1.tmp"; local retval=0 local FILE="$1.tmp"; local retval=0; local severity=error;
[ -f "$package" ] || [ "$1" = "md5sum" ] || { error "$package not found. Cannot check $1."; [ -f "$package" ] || [ "$1" = "md5sum" ] || { error "$package not found. Cannot check $1.";
return "$E_MANIFEST"; } return "$E_MANIFEST"; }
[ "$1" = "md5sum" ] && FILTER="| sort -k 3" || FILTER="" [ "$1" = "md5sum" ] && FILTER="| sort -k 3" || FILTER=""
@ -413,17 +412,17 @@ check_manifest() {
sed '/^@@/d; /^+++/d; /^---/d; s/^+/NEW /g; s/^-/MISSING /g' \ sed '/^@@/d; /^+++/d; /^---/d; s/^+/NEW /g; s/^-/MISSING /g' \
> "${FILE%tmp}diff" > "${FILE%tmp}diff"
if [ -s "${FILE%tmp}diff" ]; then if [ -s "${FILE%tmp}diff" ]; then
error "$1 mismatch found:"
cat "${FILE%tmp}diff" >&2
CN=$(grep -c ^NEW "${FILE%tmp}diff") CN=$(grep -c ^NEW "${FILE%tmp}diff")
CM=$(grep -c ^MISSING "${FILE%tmp}diff") CM=$(grep -c ^MISSING "${FILE%tmp}diff")
if [ "$1" = "footprint" ]; then if [ "$1" = "footprint" ]; then
[ "$PKGMK_IGNORE_NEW" = "yes" ] || retval+=$CN [ "$PKGMK_IGNORE_NEW" = "no" ] && retval+=$CN || severity=warning
[ "$PKGMK_IGNORE_MISSING" = "yes" ] || retval+=$CM [ "$PKGMK_IGNORE_MISSING" = "no" ] && retval+=$CM
retval=$(( E_MANIFEST*( retval>0 ) )) retval=$(( E_MANIFEST*( retval>0 ) ))
else else
retval=$E_MANIFEST retval=$E_MANIFEST
fi fi
$severity "$1 mismatch found:"
cat "${FILE%tmp}diff" >&2
fi fi
else else
warning ".$1 not found, creating new."; mv "$FILE" "$TRUTH" warning ".$1 not found, creating new."; mv "$FILE" "$TRUTH"