xbps-src: more improvements for -E and -t options.

If both options are set, check first if the binpkg exists before
creating the temporary masterdir, and clean this up properly.
This commit is contained in:
Juan RP 2015-03-01 16:45:16 +01:00
parent 2f524cf66a
commit bdb798fa64
3 changed files with 27 additions and 25 deletions

View File

@ -206,6 +206,8 @@ chroot_handler() {
[ -n "$XBPS_ALT_REPOSITORY" ] && arg="$arg -r $XBPS_ALT_REPOSITORY" [ -n "$XBPS_ALT_REPOSITORY" ] && arg="$arg -r $XBPS_ALT_REPOSITORY"
[ -n "$XBPS_USE_GIT_REVS" ] && arg="$arg -G" [ -n "$XBPS_USE_GIT_REVS" ] && arg="$arg -G"
[ -n "$XBPS_PKG_OPTIONS" ] && arg="$arg -o $XBPS_PKG_OPTIONS" [ -n "$XBPS_PKG_OPTIONS" ] && arg="$arg -o $XBPS_PKG_OPTIONS"
[ -n "$XBPS_TEMP_MASTERDIR" ] && arg="$arg -t -C"
[ -n "$XBPS_BINPKG_EXISTS" ] && arg="$arg -E"
action="$arg $action" action="$arg $action"
env -i PATH="/usr/bin:/usr/sbin:$PATH" HOME=/tmp IN_CHROOT=1 LANG=en_US.UTF-8 \ env -i PATH="/usr/bin:/usr/sbin:$PATH" HOME=/tmp IN_CHROOT=1 LANG=en_US.UTF-8 \

View File

@ -37,8 +37,8 @@ error_func() {
exit_and_cleanup() { exit_and_cleanup() {
local rval=$1 local rval=$1
if [ -n "$XBPS_TEMP_MASTERDIR" ]; then if [ -n "$XBPS_TEMP_MASTERDIR" -a "$XBPS_TEMP_MASTERDIR" != "1" ]; then
rm -rf "$XBPS_MASTERDIR" rm -rf "$XBPS_TEMP_MASTERDIR"
fi fi
exit ${rval:=0} exit ${rval:=0}
} }

View File

@ -211,15 +211,18 @@ check_config_vars() {
} }
create_temporary_masterdir() { create_temporary_masterdir() {
local tmpmdir=$(mktemp -d -q -p $XBPS_DISTDIR masterdir.XXXXXXXXX || exit 1) if [ -n "$IN_CHROOT" -o -z "$XBPS_TEMP_MASTERDIR" ]; then
return
fi
XBPS_TEMP_MASTERDIR=$(mktemp -d -q -p $XBPS_DISTDIR masterdir.XXXXXXXXX || exit 1)
cp -a $XBPS_MASTERDIR/* $tmpmdir/ cp -a $XBPS_MASTERDIR/* $XBPS_TEMP_MASTERDIR/
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR: failed to setup temporary masterdir $tmpmdir!" echo "ERROR: failed to setup temporary masterdir $XBPS_TEMP_MASTERDIR!"
exit 1 exit 1
fi fi
export CHROOT_READY=1 export CHROOT_READY=1
export XBPS_MASTERDIR=$tmpmdir export XBPS_MASTERDIR=$XBPS_TEMP_MASTERDIR
} }
@ -352,7 +355,7 @@ while getopts "a:CEfgGhH:Ij:Lm:No:r:tV" opt; do
N) readonly XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+=" -N";; N) readonly XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+=" -N";;
o) readonly XBPS_PKG_OPTIONS="$OPTARG"; XBPS_OPTIONS+=" -o $OPTARG";; o) readonly XBPS_PKG_OPTIONS="$OPTARG"; XBPS_OPTIONS+=" -o $OPTARG";;
r) readonly XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+=" -r $OPTARG";; r) readonly XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+=" -r $OPTARG";;
t) readonly XBPS_TEMP_MASTERDIR=1; XBPS_KEEP_ALL=1; XBPS_OPTIONS+=" -t -C";; t) export XBPS_TEMP_MASTERDIR=1; XBPS_OPTIONS+=" -t -C";;
V) echo $XBPS_SRC_VERSION && exit 0;; V) echo $XBPS_SRC_VERSION && exit 0;;
--) shift; break;; --) shift; break;;
esac esac
@ -405,11 +408,6 @@ fi
# #
check_config_vars check_config_vars
if [ -z "$IN_CHROOT" -a -n "$XBPS_TEMP_MASTERDIR" ]; then
# Create a temporary masterdir (hardlinked) for this build.
create_temporary_masterdir
fi
if [ -n "$XBPS_HOSTDIR" ]; then if [ -n "$XBPS_HOSTDIR" ]; then
export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs
readonly XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources readonly XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources
@ -537,6 +535,7 @@ check_build_requirements
trap 'exit_func' INT TERM trap 'exit_func' INT TERM
# #
# Main switch. # Main switch.
# #
@ -609,6 +608,7 @@ case "$XBPS_TARGET" in
fetch|extract|build|configure|install|pkg) fetch|extract|build|configure|install|pkg)
BEGIN_INSTALL=1 BEGIN_INSTALL=1
read_pkg read_pkg
create_temporary_masterdir
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
else else