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

View file

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