Skip to content

Commit

Permalink
pkgmk.in: refactor build_needed(), minor clean up
Browse files Browse the repository at this point in the history
make build_needed return 0 if build needed and 1 otherwise; this helps
to call build_needed as a command and not invoking shell, like
"$(build_needed)" = "yes|no".
  • Loading branch information
sighook committed Aug 3, 2023
1 parent afd1468 commit ce2d2e7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pkgmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ check_footprint() {
if [ -f .footprint ]; then
cp .footprint "$__FILE.footprint.orig"

diff -w -t -U 0 \
diff -w -t -U 0 \
"$__FILE.footprint.orig" \
"$__FILE.footprint" \
| sed '/^@@/d' \
Expand Down Expand Up @@ -527,28 +527,28 @@ update_footprint() {

build_needed() {
local __FILE=
local __RESULT="yes"
local __NEEDED="yes"

if [ -f "$TARGET" ]; then
__RESULT="no"
__NEEDED="no"
for __FILE in Pkgfile ${source}; do
__FILE=$(get_filename "$__FILE")
if [ -e "$__FILE" ] && ! test "$TARGET" -nt "$__FILE"; then
__RESULT="yes"
__NEEDED="yes"
break
fi
done
fi

echo $__RESULT
[ "$__NEEDED" = yes ] || return 1
}

######################################################################
# main && main helpers #
######################################################################

# Don't warn about unreachable commands in these functions. See
# trap(1p) for more information.
# Don't warn about unreachable commands in these functions.
# See trap(1p) for more information.
# shellcheck disable=2317
interrupted() {
echo ""
Expand Down Expand Up @@ -662,8 +662,7 @@ main() {
if [ -f .32bit ]; then
export PKGMK_ARCH=32
else
# multilib
export PKGMK_ARCH=64
export PKGMK_ARCH=64 # multilib
fi

parse_options "$@"
Expand Down Expand Up @@ -728,15 +727,15 @@ main() {
fi

if [ "$PKGMK_UP_TO_DATE" = "yes" ]; then
if [ "$(build_needed)" = "yes" ]; then
if build_needed; then
info "Package '$TARGET' is not up to date."
else
info "Package '$TARGET' is up to date."
fi
exit 0
fi

if [ "$(build_needed)" = "no" ] \
if ! build_needed \
&& [ "$PKGMK_FORCE" = "no" ] \
&& [ "$PKGMK_CHECK_MD5SUM" = "no" ]; then
info "Package '$TARGET' is up to date."
Expand Down

0 comments on commit ce2d2e7

Please sign in to comment.