| git.druid.rocks | index | druid520 | ports | ports/ | textproc/ | gawk/ | del.sh |
ports/textproc/gawk/del.sh
set -e
# see add.sh's own comment on USE_own_awk_symlink: when it's off (the
# default), THIS install never created $MP_PREFIX/bin/awk in the first
# place -- but autotools' own "make uninstall" rule removes it
# unconditionally regardless of whether THIS install actually put it
# there, so if some OTHER package's own "awk" (build-tools/onetrueawk,
# say) happens to be sitting at that same path when gawk gets removed,
# "make uninstall" would delete someone else's live binary with zero
# indication anything beyond "gawk was removed" happened. move it
# aside first and restore it after -- a plain "mv" of a nonexistent
# path is a harmless no-op either way, so this is safe to run
# unconditionally rather than needing to know in advance whether
# there's anything to protect.
#
# real "if" throughout, not "[ ... ] && cmd" chains: busybox ash (this
# system's own default SHELL) aborts the ENTIRE script the moment a
# bare "&&"/"||" list's own non-last command fails, not just skips the
# rest of that one list (see /etc/mpx.env's own identical warning, a
# real incident there too, and add.sh's own identical fix this same
# pass) -- "nothing to restore" is exactly that kind of non-last
# command legitimately returning false under set -e.
if [ -z "$USE_own_awk_symlink" ]; then
mv $MP_PREFIX/bin/awk /tmp/gawk-del-awk-save 2>/dev/null || true
fi
# remove: runs BEFORE add.sh ever (re-)clones a checkout on a
# reinstall (and after "mp clean gawk" wipes a stale one too), same
# class of bug already found and fixed across this tree this same
# pass -- a no-op here is fine either way, mp's own manifest sweep
# covers the actual file cleanup regardless.
if cd gawk 2>/dev/null; then
make clean || true
make uninstall || true
cd ..
fi
if [ -z "$USE_own_awk_symlink" ]; then
if [ -f /tmp/gawk-del-awk-save ]; then
mv /tmp/gawk-del-awk-save $MP_PREFIX/bin/awk
fi
fi
rm -rf gawk