xbps-src: retire XBPS_PKGDESTDIR

Historically, PKGDESTDIR was only set during pkg_install, and
XBPS_PKGDESTDIR was set to indicate that we're in subpkg's
pkg_install.

However, from 0b95cb8f5d, (Merge xbps-src code to make it usable in
a standalone mode., 2014-03-22), PKGDESTDIR is always set,
regardless of states.

Let's drop all usages of XBPS_PKGDESTDIR.

While we're at it, error out of vmove is used outside of subpkg.
This commit is contained in:
Đoàn Trần Công Danh 2021-07-03 10:50:39 +07:00 committed by Đoàn Trần Công Danh
parent b0d6286bc9
commit d8e2056a8f
2 changed files with 22 additions and 52 deletions

View file

@ -144,10 +144,9 @@ _vlicense() {
_vinstall() { _vinstall() {
local file="$1" mode="$2" targetdir="$3" targetfile="$4" local file="$1" mode="$2" targetdir="$3" targetfile="$4"
local _destdir=
if [ -z "$DESTDIR" ]; then if [ -z "$PKGDESTDIR" ]; then
msg_red "$pkgver: vinstall: DESTDIR unset, can't continue...\n" msg_red "$pkgver: vinstall: PKGDESTDIR unset, can't continue...\n"
return 1 return 1
fi fi
@ -161,24 +160,18 @@ _vinstall() {
return 1 return 1
fi fi
if [ -n "$XBPS_PKGDESTDIR" ]; then
_destdir="$PKGDESTDIR"
else
_destdir="$DESTDIR"
fi
if [ -z "$targetfile" ]; then if [ -z "$targetfile" ]; then
install -Dm${mode} "${file}" "${_destdir}/${targetdir}/${file##*/}" install -Dm${mode} "${file}" "${PKGDESTDIR}/${targetdir}/${file##*/}"
else else
install -Dm${mode} "${file}" "${_destdir}/${targetdir}/${targetfile##*/}" install -Dm${mode} "${file}" "${PKGDESTDIR}/${targetdir}/${targetfile##*/}"
fi fi
} }
_vcopy() { _vcopy() {
local files="$1" targetdir="$2" _destdir local files="$1" targetdir="$2"
if [ -z "$DESTDIR" ]; then if [ -z "$PKGDESTDIR" ]; then
msg_red "$pkgver: vcopy: DESTDIR unset, can't continue...\n" msg_red "$pkgver: vcopy: PKGDESTDIR unset, can't continue...\n"
return 1 return 1
fi fi
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
@ -186,17 +179,11 @@ _vcopy() {
return 1 return 1
fi fi
if [ -n "$XBPS_PKGDESTDIR" ]; then cp -a $files ${PKGDESTDIR}/${targetdir}
_destdir="$PKGDESTDIR"
else
_destdir="$DESTDIR"
fi
cp -a $files ${_destdir}/${targetdir}
} }
_vmove() { _vmove() {
local f files="$1" _destdir _pkgdestdir _targetdir local f files="$1" _targetdir
if [ -z "$DESTDIR" ]; then if [ -z "$DESTDIR" ]; then
msg_red "$pkgver: vmove: DESTDIR unset, can't continue...\n" msg_red "$pkgver: vmove: DESTDIR unset, can't continue...\n"
@ -204,6 +191,9 @@ _vmove() {
elif [ -z "$PKGDESTDIR" ]; then elif [ -z "$PKGDESTDIR" ]; then
msg_red "$pkgver: vmove: PKGDESTDIR unset, can't continue...\n" msg_red "$pkgver: vmove: PKGDESTDIR unset, can't continue...\n"
return 1 return 1
elif [ "$DESTDIR" = "$PKGDESTDIR" ]; then
msg_red "$pkgver: vmove is intended to be used in pkg_install\n"
return 1
fi fi
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
msg_red "$pkgver: vmove: 1 argument expected: <files>\n" msg_red "$pkgver: vmove: 1 argument expected: <files>\n"
@ -214,30 +204,22 @@ _vmove() {
break break
done done
if [ -n "$XBPS_PKGDESTDIR" ]; then
_pkgdestdir="$PKGDESTDIR"
_destdir="$DESTDIR"
else
_pkgdestdir="$DESTDIR"
_destdir="$DESTDIR"
fi
if [ -z "${_targetdir}" ]; then if [ -z "${_targetdir}" ]; then
[ ! -d ${_pkgdestdir} ] && install -d ${_pkgdestdir} [ ! -d ${PKGDESTDIR} ] && install -d ${PKGDESTDIR}
mv ${_destdir}/$files ${_pkgdestdir} mv ${DESTDIR}/$files ${PKGDESTDIR}
else else
if [ ! -d ${_pkgdestdir}/${_targetdir} ]; then if [ ! -d ${PKGDESTDIR}/${_targetdir} ]; then
install -d ${_pkgdestdir}/${_targetdir} install -d ${PKGDESTDIR}/${_targetdir}
fi fi
mv ${_destdir}/$files ${_pkgdestdir}/${_targetdir} mv ${DESTDIR}/$files ${PKGDESTDIR}/${_targetdir}
fi fi
} }
_vmkdir() { _vmkdir() {
local dir="$1" mode="$2" _destdir local dir="$1" mode="$2"
if [ -z "$DESTDIR" ]; then if [ -z "$PKGDESTDIR" ]; then
msg_red "$pkgver: vmkdir: DESTDIR unset, can't continue...\n" msg_red "$pkgver: vmkdir: PKGDESTDIR unset, can't continue...\n"
return 1 return 1
fi fi
@ -246,16 +228,10 @@ _vmkdir() {
return 1 return 1
fi fi
if [ -n "$XBPS_PKGDESTDIR" ]; then
_destdir="$PKGDESTDIR"
else
_destdir="$DESTDIR"
fi
if [ -z "$mode" ]; then if [ -z "$mode" ]; then
install -d ${_destdir}/${dir} install -d ${PKGDESTDIR}/${dir}
else else
install -dm${mode} ${_destdir}/${dir} install -dm${mode} ${PKGDESTDIR}/${dir}
fi fi
} }
@ -265,11 +241,6 @@ _vcompletion() {
local _fish_completion_dir=usr/share/fish/vendor_completions.d/ local _fish_completion_dir=usr/share/fish/vendor_completions.d/
local _zsh_completion_dir=usr/share/zsh/site-functions/ local _zsh_completion_dir=usr/share/zsh/site-functions/
if [ -z "$DESTDIR" ]; then
msg_red "$pkgver: vcompletion: DESTDIR unset, can't continue...\n"
return 1
fi
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n" msg_red "$pkgver: vcompletion: 2 arguments expected: <file> <shell>\n"
return 1 return 1

View file

@ -58,7 +58,6 @@ if [ ! -f $XBPS_SUBPKG_INSTALL_DONE ]; then
install -d $PKGDESTDIR install -d $PKGDESTDIR
if declare -f pkg_install >/dev/null; then if declare -f pkg_install >/dev/null; then
export XBPS_PKGDESTDIR=1
run_pkg_hooks pre-install run_pkg_hooks pre-install
run_func pkg_install run_func pkg_install
fi fi