pkgmeek: give the variables more intuitive names

This commit is contained in:
John McQuah 2022-06-02 05:59:01 -04:00
parent ed5c4d8597
commit ae21ff444b

View File

@ -9,7 +9,7 @@
main() {
######################## main routine ################################
local o_ignored work _local_ here url u f
local errDL=0; local errUZ=0; local pkg_ood=1
local errDL=0; local errUZ=0; local pkg_utd=1
parse_options "$@"
[ "$PKGMK_RECURSIVE" = "no" ] || recursive "$@"
#
@ -86,8 +86,8 @@ done ; }
[ $errDL != 0 ] || info "Successfully obtained all needed source files."
# If the user only asked for '-utd', perform the check using the sources that do exist.
check_pkg_mtime && pkg_ood=0
[ "$PKGMK_MTIME_ONLY" = "no" ] || exit $pkg_ood
check_pkg_mtime || pkg_utd=0
[ "$PKGMK_MTIME_ONLY" = "no" ] || exit $pkg_utd
# Some further tests before proceeding with the build
[ "$PKGMK_DOWNLOAD_ONLY" = "no" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || \
@ -96,12 +96,12 @@ check_pkg_mtime && pkg_ood=0
# Take into account all the actions that can be done with a previously built package,
# or with a full set of sources
[ "$pkg_ood" = 0 ] || [ "$PKGMK_FORCE" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] \
[ "$pkg_utd" = 0 ] || [ "$PKGMK_FORCE" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] \
|| [ "$PKGMK_UPDATE_SIG" = "yes" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || [ "$PKGMK_EXTRACT_ONLY" = "no" ] \
|| { info "$package is up to date, use '-f' to force a rebuild."; exit 0; }
# Silence the progress report if the user never intended to proceed with unpacking
[ "$pkg_ood" = 0 ] || [ "$PKGMK_CHECK_SIG" = "yes" ] || echo "Checking signatures before unpacking..."
[ "$pkg_utd" = 1 ] || [ "$PKGMK_CHECK_SIG" = "yes" ] || echo "Checking signatures before unpacking..."
# The option -uf is meant to be used AFTER a previous invocation of pkgmeek has
# alerted the user to a footprint mismatch. The options -us|-um are likewise meant
@ -110,7 +110,7 @@ if [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ]; then
[ -f "$package" ] || \
{ error "unable to update footprint. File '$package' not found.";
exit "$E_MANIFEST"; }
[ "$pkg_ood" = 0 ] || [ "$PKGMK_FORCE" = "yes" ] || \
[ "$pkg_utd" = 1 ] || [ "$PKGMK_FORCE" = "yes" ] || \
{ error "outdated package. Use '-f' to force the footprint update.";
exit "$E_FOOTPRINT"; }
cat_manifest footprint > "$PKGMK_ROOT/.footprint" || \
@ -135,7 +135,7 @@ fi
# 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."
[ "$pkg_ood" = 0 ] || [ "$PKGMK_IGNORE_SIG" = "yes" ] || \
[ "$pkg_utd" = 1 ] || [ "$PKGMK_IGNORE_SIG" = "yes" ] || \
{ check_signature "pre-build" | parse_signify_output;
case $? in
0) info "Sources successfully authenticated." ;;
@ -147,7 +147,7 @@ esac; }
# What used to be called unpack_source() is now hard-coded into the main routine.
# If you need to shield specific source files from unpacking, use the "renames"
# feature of Pkgfile(5) to avoid matching any of the following patterns.
if [ "$pkg_ood" = 1 ] || [ "$PKGMK_FORCE" = "yes" ]; then
if [ "$pkg_utd" = 0 ] || [ "$PKGMK_FORCE" = "yes" ]; then
for (( u=0; u<${#_local_[@]}; u++ )) ; do
here="${_local_[$u]}"
@ -226,7 +226,6 @@ E_SIGNATURE=9 # error verifying the signature
readonly PKGMK_VERSION="#VERSION#"
readonly PKGMK_COMMAND="$0"
readonly PKGMK_ROOT="$PWD"
readonly PKGMK_SIGNIFY="/usr/bin/signify"
readonly PRTWASH_COMMAND="/usr/bin/prtwash"
readonly PKGMK_GIT_COMMAND="/usr/bin/git"
PKGMK_DOWNLOAD_PROG="/usr/bin/wget"
@ -364,20 +363,20 @@ check_reqvars () {
}
check_pkg_mtime() { # can be called even if some sources are missing
local li=0; local pkg_ood=1; local msg="$package is not up to date."
local li=0; local utd=0; local msg="$package is not up to date."
if [ -f "$pkg_dir$package" ]; then
pkg_ood=0
while [ $li -lt ${#_local_[@]} ] && [ "$pkg_ood" = 0 ]; do
utd=1
while [ $li -lt ${#_local_[@]} ] && [ "$utd" = 1 ]; do
[ ! -e "${_local_[$li]}" ] || \
[ $(realpath "${_local_[$li]}") -nt "$pkg_dir$package" ] || pkg_ood=1
[ $(realpath "${_local_[$li]}") -nt "$pkg_dir$package" ] || utd=0
li=$(( li+1 ))
done
[ ! -e Pkgfile ] || [ Pkgfile -nt "$pkg_dir$package" ] || pkg_ood=1
[ ! -e Pkgfile ] || [ Pkgfile -nt "$pkg_dir$package" ] || utd=0
fi
[ "$pkg_ood" = 1 ] || msg="$package is up to date."
[ "$PKGMK_MTIME_ONLY" = "no" ] || info "$msg"
[ "$utd" = 0 ] || msg="$package is up to date."
info "$msg"; return $utd
}
cat_manifest() {
@ -466,10 +465,10 @@ check_signature() { # called from $PKGMK_ROOT in the case "when"="pre-Pkgfile",
[ -e "$FILE" ] || ln -sf "$PKGMK_ROOT/$FILE" .
done
if [ -f "$PKGMK_PUBLICKEY" ]; then
$PKGMK_SIGNIFY -C -p "$PKGMK_PUBLICKEY" -x "$PKGMK_ROOT/.signature" \
/usr/bin/signify -C -p "$PKGMK_PUBLICKEY" -x "$PKGMK_ROOT/.signature" \
"${reqfiles[@]}" 2>&1
else
$PKGMK_SIGNIFY -C -x "$PKGMK_ROOT/.signature" \
/usr/bin/signify -C -x "$PKGMK_ROOT/.signature" \
"${reqfiles[@]}" 2>&1
fi
else
@ -494,7 +493,7 @@ cat_signature() {
for ((si=0; si < ${#source[@]}; si++)); do ordered+=("${_local_[$si]}"); done
sha256sum --tag "${ordered[@]}" \
| sed 's|^SHA256 (.*/\(.*\))\(.* = .*\)|SHA256 (\1)\2|' \
| "$PKGMK_SIGNIFY" -S -e -x - -q -s "$key" -m - \
| /usr/bin/signify -S -e -x - -q -s "$key" -m - \
| sed "s|${key/%.sec/.pub}|$pub|"
break
fi
@ -510,7 +509,7 @@ refresh_signature() {
[ -n "$PKGMK_PRIVATEKEY" ] || REPO=$(dirname "$PWD" | sed 's|^.*/||; s|\.git$||;')
[ -n "$REPO" ] && PKGMK_PRIVATEKEY="/etc/ports/${REPO}.sec"
if ! tail -n +3 ".signature" | $PKGMK_SIGNIFY -S -e -x - -q \
if ! tail -n +3 ".signature" | /usr/bin/signify -S -e -x - -q \
-s "$PKGMK_PRIVATEKEY" -m - > .signature.tmp ; then
rm .signature.tmp
error "Refreshing signature failed"