xbps-src: introduce XBPS_STATEDIR to store state files, logs and others.

XBPS_STATEDIR is created in XBPS_BUILDDIR/.xbps-${sourcepkg}-${version}
and contains logs and state files for all phases, as well as wrappers.

We can now inspect the output from all hooks.
This commit is contained in:
Juan RP 2014-12-11 11:02:22 +01:00
parent 8ad235c69d
commit 6e13dcbaff
11 changed files with 33 additions and 33 deletions

View File

@ -42,8 +42,8 @@ genpkg() {
if [ -s ${PKGDESTDIR}/shlib-requires ]; then
_shrequires="$(cat ${PKGDESTDIR}/shlib-requires)"
fi
if [ -s ${wrksrc}/.xbps_${sourcepkg}_git_revs ]; then
_gitrevs="$(cat ${wrksrc}/.xbps_${sourcepkg}_git_revs)"
if [ -s ${XBPS_STATEDIR}/gitrev ]; then
_gitrevs="$(cat ${XBPS_STATEDIR}/gitrev)"
fi
if [ -n "$provides" ]; then

View File

@ -2,7 +2,7 @@
# commit sha1 (in short mode) for all files of a source pkg.
hook() {
local GITREVS_FILE=${wrksrc}/.xbps_${sourcepkg}_git_revs
local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
local GIT_CMD rev
# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.

View File

@ -29,9 +29,9 @@ if [ -z $pkgname -o -z $version ]; then
exit 1
fi
XBPS_BUILD_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_build_done"
XBPS_PRE_BUILD_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_pre_build_done"
XBPS_POST_BUILD_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_post_build_done"
XBPS_BUILD_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_build_done"
XBPS_PRE_BUILD_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_pre_build_done"
XBPS_POST_BUILD_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_post_build_done"
if [ -f "$XBPS_BUILD_DONE" ]; then
exit 0

View File

@ -24,9 +24,9 @@ for f in $XBPS_COMMONDIR/environment/configure/*.sh; do
source_file "$f"
done
XBPS_CONFIGURE_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_configure_done"
XBPS_PRECONFIGURE_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_pre_configure_done"
XBPS_POSTCONFIGURE_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_post_configure_done"
XBPS_CONFIGURE_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_configure_done"
XBPS_PRECONFIGURE_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_pre_configure_done"
XBPS_POSTCONFIGURE_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_post_configure_done"
if [ -f "$XBPS_CONFIGURE_DONE" ]; then
exit 0

View File

@ -24,7 +24,7 @@ for f in $XBPS_COMMONDIR/environment/extract/*.sh; do
source_file "$f"
done
XBPS_EXTRACT_DONE="$wrksrc/.xbps_extract_done"
XBPS_EXTRACT_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_extract_done"
if [ -f $XBPS_EXTRACT_DONE ]; then
exit 0

View File

@ -24,7 +24,7 @@ for f in $XBPS_COMMONDIR/environment/fetch/*.sh; do
source_file "$f"
done
XBPS_FETCH_DONE="$wrksrc/.xbps_fetch_done"
XBPS_FETCH_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_fetch_done"
if [ -f "$XBPS_FETCH_DONE" ]; then
exit 0

View File

@ -24,9 +24,9 @@ for f in $XBPS_COMMONDIR/environment/install/*.sh; do
source_file "$f"
done
XBPS_INSTALL_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_install_done"
XBPS_PRE_INSTALL_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_pre_install_done"
XBPS_POST_INSTALL_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_post_install_done"
XBPS_INSTALL_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_install_done"
XBPS_PRE_INSTALL_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_pre_install_done"
XBPS_POST_INSTALL_DONE="${XBPS_STATEDIR}/${sourcepkg}_${XBPS_CROSS_BUILD}_post_install_done"
cd $wrksrc || msg_error "$pkgver: cannot access to wrksrc [$wrksrc]\n"
if [ -n "$build_wrksrc" ]; then
@ -74,7 +74,7 @@ if [ ! -f $XBPS_INSTALL_DONE ]; then
exit 0
fi
XBPS_SUBPKG_INSTALL_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_${PKGNAME}_install_done"
XBPS_SUBPKG_INSTALL_DONE="${XBPS_STATEDIR}/${PKGNAME}_${XBPS_CROSS_BUILD}_subpkg_install_done"
# If it's a subpkg execute the pkg_install() function.
if [ ! -f $XBPS_SUBPKG_INSTALL_DONE ]; then

View File

@ -25,7 +25,7 @@ for f in $XBPS_COMMONDIR/environment/install/*.sh; do
done
XBPS_PREPKG_DONE="$wrksrc/.xbps_${XBPS_CROSS_BUILD}_${PKGNAME}_prepkg_done"
XBPS_PREPKG_DONE="${XBPS_STATEDIR}/${PKGNAME}_${XBPS_CROSS_BUILD}_prepkg_done"
if [ -f $XBPS_PREPKG_DONE ]; then
exit 0

View File

@ -1,21 +1,18 @@
# vim: set ts=4 sw=4 et:
run_func() {
local func="$1" desc="$2" restoretrap= logpipe= logfile= teepid=
local func="$1" desc="$2" funcname="$3" restoretrap= logpipe= logfile= teepid=
if [ -d "${wrksrc}" ]; then
logpipe=$(mktemp -u --tmpdir=${wrksrc} .xbps_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe)
logfile=${wrksrc}/.xbps_${XBPS_CROSS_BUILD}_${func}.log
else
logpipe=$(mktemp -t -u .xbps_${XBPS_CROSS_BUILD}_${func}_${pkgname}_logpipe.XXXXXXX)
logfile=$(mktemp -t .xbps_${XBPS_CROSS_BUILD}_${func}_${pkgname}.log.XXXXXXXX)
fi
: ${funcname:=$func}
logpipe=$(mktemp -u --tmpdir=${XBPS_STATEDIR} ${pkgname}_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe)
logfile=${XBPS_STATEDIR}/${pkgname}_${XBPS_CROSS_BUILD}_${funcname}.log
msg_normal "${pkgver:-xbps-src}: running ${desc:-${func}} ...\n"
set -E
restoretrap=$(trap -p ERR)
trap 'error_func $func $LINENO' ERR
trap 'error_func $funcname $LINENO' ERR
mkfifo "$logpipe"
tee "$logfile" < "$logpipe" &
@ -176,7 +173,7 @@ run_pkg_hooks() {
hookn=$(basename $f)
hookn=${hookn%.sh}
. $f
run_func hook "$phase hook: $hookn"
run_func hook "$phase hook: $hookn" ${phase}_${hookn}
done
}
@ -400,5 +397,7 @@ setup_pkg() {
exit 0
fi
export XBPS_WRAPPERDIR="${wrksrc}/.xbps/bin"
export XBPS_STATEDIR="${XBPS_BUILDDIR}/.xbps-${sourcepkg}-${version}"
export XBPS_WRAPPERDIR="${XBPS_STATEDIR}/wrappers"
mkdir -p $XBPS_WRAPPERDIR
}

View File

@ -177,10 +177,10 @@ remove_pkg() {
msg_normal "$f: removing 32bit files from destdir...\n"
rm -rf ${_destdir}/${f}-32bit-${version}
fi
rm -f $wrksrc/.xbps_${XBPS_CROSS_BUILD}_${f}_install_done
rm -f $wrksrc/.xbps_${XBPS_CROSS_BUILD}_${f}_prepkg_done
rm -f ${XBPS_STATEDIR}/${f}_${cross}_subpkg_install_done
rm -f ${XBPS_STATEDIR}/${f}_${cross}_prepkg_done
done
rm -f $wrksrc/.xbps_${cross}_install_done
rm -f $wrksrc/.xbps_${cross}_pre_install_done
rm -f $wrksrc/.xbps_${cross}_post_install_done
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_install_done
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_pre_install_done
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_post_install_done
}

View File

@ -266,7 +266,7 @@ install_bbootstrap() {
masterdir_zap() {
for f in bin boot builddir destdir dev etc home lib lib32 lib64 mnt \
opt proc root run sbin sys tmp usr var host media xbps \
xbps-packages void-packages .xbps_chroot_init; do
void-packages .xbps_chroot_init; do
if [ -d "$XBPS_MASTERDIR/$f" ]; then
echo "Removing directory $XBPS_MASTERDIR/$f ..."
rm -rf $XBPS_MASTERDIR/$f
@ -559,6 +559,7 @@ case "$XBPS_TARGET" in
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG || exit $?
else
[ -d $XBPS_STATEDIR ] && rm -rf $XBPS_STATEDIR
remove_pkg_wrksrc $wrksrc
if declare -f do_clean >/dev/null; then
run_func do_clean