From b038dacf8acaab2f4e3aa9f011cd8defb855b7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Sat, 3 Jul 2021 10:50:39 +0700 Subject: [PATCH] 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. --- common/environment/setup/install.sh | 73 ++++++------------- common/xbps-src/libexec/xbps-src-doinstall.sh | 1 - 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh index 742f13075f8f..f533212b7daf 100644 --- a/common/environment/setup/install.sh +++ b/common/environment/setup/install.sh @@ -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: \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: \n" return 1 diff --git a/common/xbps-src/libexec/xbps-src-doinstall.sh b/common/xbps-src/libexec/xbps-src-doinstall.sh index 14e117a923b9..fb5d35d1a59a 100755 --- a/common/xbps-src/libexec/xbps-src-doinstall.sh +++ b/common/xbps-src/libexec/xbps-src-doinstall.sh @@ -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