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
} }
@ -337,22 +340,22 @@ XBPS_OPTIONS=
while getopts "a:CEfgGhH:Ij:Lm:No:r:tV" opt; do while getopts "a:CEfgGhH:Ij:Lm:No:r:tV" opt; do
case $opt in case $opt in
a) readonly XBPS_CROSS_BUILD="$OPTARG"; XBPS_OPTIONS+="-a $OPTARG ";; a) readonly XBPS_CROSS_BUILD="$OPTARG"; XBPS_OPTIONS+=" -a $OPTARG";;
C) readonly XBPS_KEEP_ALL=1; XBPS_OPTIONS+="-C ";; C) readonly XBPS_KEEP_ALL=1; XBPS_OPTIONS+=" -C";;
E) readonly XBPS_BINPKG_EXISTS=1; XBPS_OPTIONS+=" -E";; E) readonly XBPS_BINPKG_EXISTS=1; XBPS_OPTIONS+=" -E";;
f) readonly XBPS_BUILD_FORCEMODE=1; XBPS_OPTIONS+="-f ";; f) readonly XBPS_BUILD_FORCEMODE=1; XBPS_OPTIONS+=" -f";;
G) readonly XBPS_USE_GIT_REVS=1; XBPS_OPTIONS+="-G ";; G) readonly XBPS_USE_GIT_REVS=1; XBPS_OPTIONS+=" -G";;
g) readonly XBPS_DEBUG_PKGS=1; XBPS_OPTIONS+="-g ";; g) readonly XBPS_DEBUG_PKGS=1; XBPS_OPTIONS+=" -g";;
H) readonly XBPS_HOSTDIR="$(readlink -m $OPTARG 2>/dev/null)"; XBPS_OPTIONS+="-H $XBPS_HOSTDIR ";; H) readonly XBPS_HOSTDIR="$(readlink -m $OPTARG 2>/dev/null)"; XBPS_OPTIONS+=" -H $XBPS_HOSTDIR";;
h) usage && exit 0;; h) usage && exit 0;;
I) readonly XBPS_SKIP_DEPS=1; XBPS_OPTIONS+="-I ";; I) readonly XBPS_SKIP_DEPS=1; XBPS_OPTIONS+=" -I";;
j) readonly XBPS_MAKEJOBS="$OPTARG"; XBPS_OPTIONS+="-j $OPTARG ";; j) readonly XBPS_MAKEJOBS="$OPTARG"; XBPS_OPTIONS+=" -j $OPTARG";;
L) export NOCOLORS=1; XBPS_OPTIONS+="-L ";; L) export NOCOLORS=1; XBPS_OPTIONS+=" -L";;
m) readonly XBPS_MASTERDIR=$(readlink -m $OPTARG 2>/dev/null); XBPS_OPTIONS+="-m $XBPS_MASTERDIR ";; m) readonly XBPS_MASTERDIR=$(readlink -m $OPTARG 2>/dev/null); XBPS_OPTIONS+=" -m $XBPS_MASTERDIR";;
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