pkgmeek: more informative progress messages
This commit is contained in:
parent
3337d49093
commit
ed5c4d8597
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
######################## main routine ################################
|
######################## main routine ################################
|
||||||
local o_ignored work _local_ here url u f errDL errUZ; local pkg_ood=1
|
local o_ignored work _local_ here url u f
|
||||||
|
local errDL=0; local errUZ=0; local pkg_ood=1
|
||||||
parse_options "$@"
|
parse_options "$@"
|
||||||
[ "$PKGMK_RECURSIVE" = "no" ] || recursive "$@"
|
[ "$PKGMK_RECURSIVE" = "no" ] || recursive "$@"
|
||||||
#
|
#
|
||||||
@ -29,9 +30,7 @@ fi
|
|||||||
#
|
#
|
||||||
validate_pkgfile || exit $E_PKGFILE
|
validate_pkgfile || exit $E_PKGFILE
|
||||||
[ -f .32bit ] && PGKMK_ARCH=32 || PKGMK_ARCH=64
|
[ -f .32bit ] && PGKMK_ARCH=32 || PKGMK_ARCH=64
|
||||||
. "Pkgfile"; . "$PKGMK_CONF"
|
. "Pkgfile"; . "$PKGMK_CONF"; set -e
|
||||||
|
|
||||||
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"/
|
[ -v pkg_dir ] || pkg_dir="$PKGMK_PACKAGE_DIR"/
|
||||||
@ -66,7 +65,7 @@ done
|
|||||||
rm -rf "$work"; mkdir -p "$work"/{src,pkg} && cd "$work"
|
rm -rf "$work"; mkdir -p "$work"/{src,pkg} && cd "$work"
|
||||||
|
|
||||||
# Skip the retrieval of sources if the user only asked for '-utd'
|
# Skip the retrieval of sources if the user only asked for '-utd'
|
||||||
errDL=0; [ "$PKGMK_MTIME_ONLY" = "yes" ] || {
|
[ "$PKGMK_MTIME_ONLY" = "yes" ] || {
|
||||||
for (( u=0; u<${#_local_[@]}; u++ )); do
|
for (( u=0; u<${#_local_[@]}; u++ )); do
|
||||||
here="${_local_[$u]}"; url="${source[$u]}";
|
here="${_local_[$u]}"; url="${source[$u]}";
|
||||||
# at least one of the following commands should put a file of the
|
# at least one of the following commands should put a file of the
|
||||||
@ -80,27 +79,29 @@ here="${_local_[$u]}"; url="${source[$u]}";
|
|||||||
[ -e "$here" ] || [[ ! $url =~ ^(https|ssh|git)://.*/(.+)\.git ]] || \
|
[ -e "$here" ] || [[ ! $url =~ ^(https|ssh|git)://.*/(.+)\.git ]] || \
|
||||||
( "$PKGMK_GIT_COMMAND" clone "$url" "$here" ) || continue ;
|
( "$PKGMK_GIT_COMMAND" clone "$url" "$here" ) || continue ;
|
||||||
# but if not, exit with an informative error message
|
# but if not, exit with an informative error message
|
||||||
if [ ! -e "$here" ]; then
|
[ -e "$here" ] || { error "failed to download $here. Check connection and try again.";
|
||||||
error "failed to download $here. Check connection and try again."
|
errDL+=1; }
|
||||||
errDL+=1
|
|
||||||
fi ;
|
|
||||||
done ; }
|
done ; }
|
||||||
|
|
||||||
[ "$errDL" != 0 ] || info "Successfully obtained all needed source files."
|
[ $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.
|
# 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
|
check_pkg_mtime && pkg_ood=0
|
||||||
[ "$PKGMK_MTIME_ONLY" = "no" ] || exit $pkg_ood
|
[ "$PKGMK_MTIME_ONLY" = "no" ] || exit $pkg_ood
|
||||||
|
|
||||||
[ "$PKGMK_DOWNLOAD_ONLY" = "no" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] || [ "$PKGMK_EXTRACT_ONLY" = "yes" ] || [ "$errDL" = 0 ] || exit $(( E_DOWNLOAD*(errDL != 0) ))
|
|
||||||
|
|
||||||
# Some further tests before proceeding with the build
|
# Some further tests before proceeding with the build
|
||||||
[ "$pkg_ood" = 1 ] || [ "$PKGMK_FORCE" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] \
|
[ "$PKGMK_DOWNLOAD_ONLY" = "no" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || \
|
||||||
|
[ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] || [ "$PKGMK_UPDATE_SIG" = "yes" ] || \
|
||||||
|
[ "$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,
|
||||||
|
# or with a full set of sources
|
||||||
|
[ "$pkg_ood" = 0 ] || [ "$PKGMK_FORCE" = "yes" ] || [ "$PKGMK_UPDATE_FOOTPRINT" = "yes" ] \
|
||||||
|| [ "$PKGMK_UPDATE_SIG" = "yes" ] || [ "$PKGMK_UPDATE_MD5" = "yes" ] || [ "$PKGMK_EXTRACT_ONLY" = "no" ] \
|
|| [ "$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; }
|
|| { 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
|
# Silence the progress report if the user never intended to proceed with unpacking
|
||||||
[ "$PKGMK_CHECK_SIG" = "yes" ] || echo "Checking signatures before unpacking..."
|
[ "$pkg_ood" = 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
|
# 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
|
# alerted the user to a footprint mismatch. The options -us|-um are likewise meant
|
||||||
@ -134,7 +135,8 @@ 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" ] || { check_signature "pre-build" | parse_signify_output;
|
[ "$pkg_ood" = 0 ] || [ "$PKGMK_IGNORE_SIG" = "yes" ] || \
|
||||||
|
{ 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" ;;
|
||||||
@ -145,7 +147,8 @@ esac; }
|
|||||||
# What used to be called unpack_source() is now hard-coded into the main routine.
|
# 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"
|
# 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.
|
# feature of Pkgfile(5) to avoid matching any of the following patterns.
|
||||||
errUZ=0
|
if [ "$pkg_ood" = 1 ] || [ "$PKGMK_FORCE" = "yes" ]; then
|
||||||
|
|
||||||
for (( u=0; u<${#_local_[@]}; u++ )) ; do
|
for (( u=0; u<${#_local_[@]}; u++ )) ; do
|
||||||
here="${_local_[$u]}"
|
here="${_local_[$u]}"
|
||||||
case "$here" in
|
case "$here" in
|
||||||
@ -156,16 +159,14 @@ for (( u=0; u<${#_local_[@]}; u++ )) ; do
|
|||||||
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
|
||||||
|
|
||||||
# The actual build step!
|
# The actual build step!
|
||||||
if ! (SRC=$(pwd)/src; PKG=$(pwd)/pkg; cd src; set -x; build); then
|
(SRC=$(pwd)/src; PKG=$(pwd)/pkg; cd src; set -x; build) &&
|
||||||
error "Unsuccessful build!"; exit $E_BUILD
|
info "Build succeeded. Moving on to compression." ||
|
||||||
else
|
{ error "Unsuccessful build!"; exit "$E_BUILD"; }
|
||||||
info "Build succeeded. Moving on to compression."
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -f "$PKGMK_ROOT/.nostrip" ] && ns_filter="| grep -v -f .nostrip"
|
[ -f "$PKGMK_ROOT/.nostrip" ] && ns_filter="| grep -v -f .nostrip"
|
||||||
find pkg -type f $ns_filter | while read -r f; do
|
find pkg -type f $ns_filter | while read -r f; do
|
||||||
@ -183,9 +184,7 @@ find pkg -xtype l -path '*/man/man*/*' -print0 \
|
|||||||
[ $UID = 0 ] || fake_uid="--uid 0 --gid 0"
|
[ $UID = 0 ] || fake_uid="--uid 0 --gid 0"
|
||||||
if (cd pkg; bsdtar --format=gnutar $fake_uid -cf "$pkg_dir$package" *); then
|
if (cd pkg; bsdtar --format=gnutar $fake_uid -cf "$pkg_dir$package" *); then
|
||||||
info "Package creation successful."
|
info "Package creation successful."
|
||||||
else
|
else { error "Unable to create the compressed package $package."; exit $E_DIRPERM; }
|
||||||
error "Unable to create the compressed package $package."
|
|
||||||
exit $E_DIRPERM
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure that $work/ contains the package or a symlink to it, then check the footprint
|
# Ensure that $work/ contains the package or a symlink to it, then check the footprint
|
||||||
@ -195,6 +194,7 @@ fi
|
|||||||
# Clean up, part 1: remove soft links and the {src,pkg} trees
|
# Clean up, part 1: remove soft links and the {src,pkg} trees
|
||||||
find . -maxdepth 1 -mindepth 1 -type l -delete
|
find . -maxdepth 1 -mindepth 1 -type l -delete
|
||||||
[ "$PKGMK_KEEP_WORK" = "yes" ] || rm -rf src pkg
|
[ "$PKGMK_KEEP_WORK" = "yes" ] || rm -rf src pkg
|
||||||
|
fi # Continue from here if the build was skipped
|
||||||
|
|
||||||
# Install if requested
|
# Install if requested
|
||||||
# First find out how the effective user will invoke pkgadd
|
# First find out how the effective user will invoke pkgadd
|
||||||
@ -283,35 +283,26 @@ parse_options() {
|
|||||||
-i|--install) PKGMK_INSTALL_COMMAND="/usr/bin/pkgadd" ;;
|
-i|--install) PKGMK_INSTALL_COMMAND="/usr/bin/pkgadd" ;;
|
||||||
-u|--upgrade) PKGMK_INSTALL_COMMAND="/usr/bin/pkgadd -u" ;;
|
-u|--upgrade) PKGMK_INSTALL_COMMAND="/usr/bin/pkgadd -u" ;;
|
||||||
-pk|--public-key)
|
-pk|--public-key)
|
||||||
if [ ! "$2" ]; then
|
[ "$2" ] || { echo "$(basename "$PKGMK_COMMAND"): option $1 requires an argument";
|
||||||
echo "$(basename "$PKGMK_COMMAND"): option $1 requires an argument"
|
exit 1; }
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PKGMK_PUBLICKEY="$2"
|
PKGMK_PUBLICKEY="$2"
|
||||||
shift ;;
|
shift ;;
|
||||||
-sk|--secret-key)
|
-sk|--secret-key)
|
||||||
if [ ! "$2" ]; then
|
[ "$2" ] || { echo "$(basename "$PKGMK_COMMAND"): option $1 requires an argument";
|
||||||
echo "$(basename "$PKGMK_COMMAND"): option $1 requires an argument"
|
exit 1; }
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PKGMK_PRIVATEKEY="$2"
|
PKGMK_PRIVATEKEY="$2"
|
||||||
shift ;;
|
shift ;;
|
||||||
-cf|--config-file)
|
-cf|--config-file)
|
||||||
if [ ! "$2" ]; then
|
[ "$2" ] || { echo "$(basename "$PKGMK_COMMAND"): option $1 requires an argument";
|
||||||
echo "$(basename "$PKGMK_COMMAND"): option $1 requires an argument"
|
exit 1; }
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PKGMK_CONF="$2"
|
PKGMK_CONF="$2"
|
||||||
shift ;;
|
shift ;;
|
||||||
-v|--version)
|
-v|--version)
|
||||||
echo "$(basename "$PKGMK_COMMAND") (pkgutils) $PKGMK_VERSION"
|
echo "$(basename "$PKGMK_COMMAND") (pkgutils) $PKGMK_VERSION"; exit 0 ;;
|
||||||
exit 0 ;;
|
|
||||||
-h|--help)
|
-h|--help)
|
||||||
print_help
|
print_help; exit 0 ;;
|
||||||
exit 0 ;;
|
|
||||||
*)
|
*)
|
||||||
echo "$(basename "$PKGMK_COMMAND"): invalid option $1"
|
echo "$(basename "$PKGMK_COMMAND"): invalid option $1"; exit 1 ;;
|
||||||
exit 1 ;;
|
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user