pkgmeek: bugfix for an uninitialized loop variable
This commit is contained in:
parent
bb5937463f
commit
dc9c379d48
@ -10,6 +10,7 @@ main() {
|
||||
######################## main routine ################################
|
||||
local o_ignored work _local_ here url u f errDL pkg_ood errUZ
|
||||
parse_options "$@"
|
||||
[ "$PKGMK_RECURSIVE" = "no" ] || recursive "$@"
|
||||
#
|
||||
# Exit early if cleaning was requested
|
||||
#
|
||||
@ -32,13 +33,13 @@ validate_pkgfile || exit $E_PKGFILE
|
||||
|
||||
set -e
|
||||
|
||||
# respect the settings for centralized source and package directories
|
||||
# respect the settings for centralized source and package directories ...
|
||||
[ -v pkg_dir ] || pkg_dir="$PKGMK_PACKAGE_DIR"/
|
||||
[ -w "$pkg_dir" ] || pkg_dir="$(pwd)"/
|
||||
[ -v src_dir ] || src_dir="$PKGMK_SOURCE_DIR"
|
||||
[ -w "$src_dir" ] || src_dir=
|
||||
|
||||
# respect the setting for WORK_DIR in case the user wants to build in RAM
|
||||
# ... and for WORK_DIR in case the user wants to build in RAM
|
||||
[ -v PKGMK_WORK_DIR ] && work="$PKGMK_WORK_DIR"
|
||||
|
||||
# Let the main routine and subsequent subroutines know what filenames
|
||||
@ -84,16 +85,20 @@ rm -rf "$work"; mkdir -p "$work"/{src,pkg} && cd "$work"
|
||||
fi
|
||||
done; }
|
||||
|
||||
[ "$errDL" = 0 ] && info "Successfully obtained all source files."
|
||||
|
||||
# If the user only asked for '-utd', perform the check using the sources that do exist.
|
||||
check_pkg_mtime && pkg_ood=0 || pkg_ood=1
|
||||
[ "$PKGMK_MTIME_ONLY" = "no" ] || exit $pkg_ood
|
||||
|
||||
[ "$PKGMK_DOWNLOAD_ONLY" = "yes" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] \
|
||||
|| [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] \
|
||||
|| [ $errDL -gt 0 ] || exit $(( E_DOWNLOAD*(errDL > 0) ))
|
||||
|| [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] \
|
||||
|| [ "$PKGMK_EXTRACT_ONLY" = "yes" ] || [ $errDL -gt 0 ] || exit $(( E_DOWNLOAD*(errDL > 0) ))
|
||||
|
||||
# Some further tests before proceeding with the build
|
||||
[ "$pkg_ood" = 1 ] || [ "$PKGMK_FORCE" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || exit 0
|
||||
[ "$pkg_ood" = 1 ] || [ "$PKGMK_FORCE" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] \
|
||||
|| [ "$PKGMK_UPDATE_SIG" = "yes" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] \
|
||||
|| [ "$PKGMK_EXTRACT_ONLY" = "yes" ] || exit 0
|
||||
[ "$PKGMK_CHECK_SIG" = "yes" ] || echo "Checking signatures before unpacking..."
|
||||
|
||||
# The option -uf is meant to be used AFTER a previous invocation of pkgmeek has
|
||||
@ -150,8 +155,9 @@ for (( u=0; u<${#_local_[@]}; u++ )) ; do
|
||||
esac
|
||||
done
|
||||
|
||||
[ $errUZ = 0 ] || { error "Failed to unpack all sources."; exit "$E_UNPACK"; }
|
||||
[ "$PKGMK_EXTRACT_ONLY" = "yes" ] && exit 0
|
||||
[ $errUZ = 0 ] && info "Sources successfully unpacked." || \
|
||||
{ error "Failed to unpack all sources."; exit "$E_UNPACK"; }
|
||||
[ "$PKGMK_EXTRACT_ONLY" = "no" ] || exit 0
|
||||
|
||||
# The actual build step!
|
||||
if ! (SRC=$(pwd)/src; PKG=$(pwd)/pkg; cd src; set -x; build); then
|
||||
@ -160,7 +166,7 @@ else
|
||||
info "Build succeeded. Moving on to compression."
|
||||
fi
|
||||
|
||||
[ -f "$PKGMK_ROOT/$PKGMK_NOSTRIP" ] && ns_filter="| grep -v -f $PKGMK_NOSTRIP"
|
||||
[ -f "$PKGMK_ROOT/.nostrip" ] && ns_filter="| grep -v -f .nostrip"
|
||||
find pkg -type f $ns_filter | while read -r f; do
|
||||
case $(file -b "$f") in
|
||||
*ELF*executable*not\ stripped*) strip --strip-all "$f" ;;
|
||||
@ -195,12 +201,10 @@ find . -maxdepth 1 -mindepth 1 -type l -delete
|
||||
[ -z "$PKGMK_SU" ] || [ -x $(command -v "$PKGMK_SU") ] || PKGMK_SU="/usr/bin/doas ";
|
||||
[ -x $(command -v "$PKGMK_SU") ] || PKGMK_SU="su -c";
|
||||
|
||||
if [ "$PKGMK_INSTALL_COMMAND" ]; then
|
||||
if ! $PKGMK_SU $PKGMK_INSTALL_COMMAND "$package"; then
|
||||
error "Unable to install $package using pkgadd."
|
||||
exit $E_INSTALL
|
||||
fi
|
||||
fi
|
||||
[ -z "$PKGMK_INSTALL_COMMAND" ] || \
|
||||
$PKGMK_SU $PKGMK_INSTALL_COMMAND "$package" || \
|
||||
{ error "Unable to install $package using pkgadd.";
|
||||
exit "$E_INSTALL"; }
|
||||
|
||||
# Clean up, part 2
|
||||
[ "$PKGMK_KEEP_WORK" = "yes" ] || [ "$pkg_dir" = "$(pwd)/" ] || rm -f "$package"
|
||||
@ -235,6 +239,7 @@ PKGMK_COMPRESSION_MODE="gz"
|
||||
|
||||
PKGMK_INSTALL_COMMAND=""
|
||||
PKGMK_CLEAN="no"
|
||||
PKGMK_RECURSIVE="no"
|
||||
PKGMK_DOWNLOAD_ONLY="no"
|
||||
PKGMK_EXTRACT_ONLY="no"
|
||||
PKGMK_MTIME_ONLY="no"
|
||||
@ -250,14 +255,12 @@ PKGMK_IGNORE_SIG="no"
|
||||
PKGMK_REFRESH_SIG="no"
|
||||
PKGMK_CHECK_SIG="no"
|
||||
PKGMK_PRIVATEKEY=""
|
||||
PKGMK_NOSTRIP=".nostrip"
|
||||
|
||||
######################## subroutines ################################
|
||||
parse_options() {
|
||||
ARGV=( "$@" ) # retain all arguments in case '-r' was not the first
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
-r|--recursive) recursive ${ARGV[@]} ;;
|
||||
-r|--recursive) PKGMK_RECURSIVE="yes" ;;
|
||||
-c|--clean) [ -x "$PRTWASH_COMMAND" ] && PKGMK_CLEAN="yes" || \
|
||||
{ error "option '-c' not supported ($PRTWASH_COMMAND not installed)";
|
||||
exit 1; } ;;
|
||||
@ -274,7 +277,7 @@ parse_options() {
|
||||
-in|--ignore-new) PKGMK_IGNORE_NEW="yes" ;;
|
||||
-im|--ignore-md5sum) PKGMK_IGNORE_MD5="yes" ;;
|
||||
-is|--ignore-signature) PKGMK_IGNORE_SIG="yes" ;;
|
||||
-ns|--no-strip) touch "$PKGMK_NOSTRIP" ;;
|
||||
-ns|--no-strip) touch "$PKGMK_ROOT/.nostrip" ;;
|
||||
-f|--force) PKGMK_FORCE="yes" ;;
|
||||
-kw|--keep-work) PKGMK_KEEP_WORK="yes" ;;
|
||||
-i|--install) PKGMK_INSTALL_COMMAND="/usr/bin/pkgadd" ;;
|
||||
@ -371,6 +374,7 @@ check_reqvars () {
|
||||
|
||||
check_pkg_mtime() { # can be called even if some sources are missing
|
||||
local status=1; local li=0; local pkg_ood="yes"
|
||||
local msg="$package is not up to date."
|
||||
|
||||
if [ -f "$package" ]; then
|
||||
pkg_ood="no"
|
||||
@ -381,11 +385,8 @@ check_pkg_mtime() { # can be called even if some sources are missing
|
||||
[ ! -e Pkgfile ] || [ "$package" -nt Pkgfile ] || pkg_ood="yes"
|
||||
fi
|
||||
|
||||
if [ "$pkg_ood" = "no" ]; then
|
||||
status=0; info "$package is up to date."
|
||||
else
|
||||
[ "$PKGMK_CHECK_SIG" = "yes" ] || info "$package is not up to date."
|
||||
fi
|
||||
[ "$pkg_ood" = "yes" ] || { status=0; msg="$package is up to date."; }
|
||||
[ "$PKGMK_MTIME_ONLY" = "no" ] || info "$msg"
|
||||
return $status
|
||||
}
|
||||
|
||||
@ -461,13 +462,13 @@ check_signature() { # called from $PKGMK_ROOT in the case "when"="pre-Pkgfile",
|
||||
# otherwise called from within $work. Pass control to
|
||||
# check_manifest() if the signature is missing and "ignore-md5"
|
||||
# has not been requested.
|
||||
local reqfiles s
|
||||
local reqfiles; local s=0
|
||||
local when="$1"
|
||||
|
||||
|
||||
if [ -f "$PKGMK_ROOT/.signature" ]; then
|
||||
[ "$when" = "pre-Pkgfile" ] && reqfiles=(Pkgfile) || reqfiles=(.footprint)
|
||||
while [ "$when" = "pre-build" ] && [ $s -le ${#_local_[@]} ]; do
|
||||
while [ "$when" = "pre-build" ] && [ "$s" -le ${#_local_[@]} ]; do
|
||||
[[ "${source[$s]}" =~ ^(http|https|git).*/\.git ]] || \
|
||||
reqfiles=("${reqfiles[@]}" "${_local_[$s]}")
|
||||
s=$(( s+1 ))
|
||||
@ -527,17 +528,16 @@ refresh_signature() {
|
||||
}
|
||||
|
||||
recursive() {
|
||||
local ARGS DIR
|
||||
local ARGS DIR FILE
|
||||
[ "$PKGMK_CLEAN" == "no" ] || { find "$PKGMK_ROOT" -name Pkgfile -printf "%h\n" \
|
||||
| xargs "$PRTWASH_COMMAND" -s -p -b -q; exit $? ; }
|
||||
|
||||
ARGS=$(echo "$@" | sed "s/--recursive//g; s/\s*-r\s*/ /g")
|
||||
for DIR in $(find "$PKGMK_ROOT" -type d | sort); do
|
||||
if [ -f "$DIR/Pkgfile" ]; then
|
||||
info "Entering directory '$DIR'."
|
||||
(cd "$DIR" && "$PKGMK_COMMAND" $ARGS)
|
||||
info "Leaving directory '$DIR'."
|
||||
fi
|
||||
for FILE in $(find "$PKGMK_ROOT" -name Pkgfile | sort); do
|
||||
DIR=$(dirname "$FILE")
|
||||
[ -d $DIR ] && { info "Entering directory '$DIR'.";
|
||||
(cd "$DIR" && "$PKGMK_COMMAND" $ARGS);
|
||||
info "Leaving directory '$DIR'."; }
|
||||
done
|
||||
exit
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user