From 6e13dcbaffee4c88693cdff0d96218144db453ec Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 11 Dec 2014 11:02:22 +0100 Subject: [PATCH] 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. --- common/hooks/do-pkg/00-gen-pkg.sh | 4 ++-- .../hooks/post-install/05-generate-gitrevs.sh | 2 +- common/xbps-src/libexec/xbps-src-dobuild.sh | 6 +++--- .../xbps-src/libexec/xbps-src-doconfigure.sh | 6 +++--- common/xbps-src/libexec/xbps-src-doextract.sh | 2 +- common/xbps-src/libexec/xbps-src-dofetch.sh | 2 +- common/xbps-src/libexec/xbps-src-doinstall.sh | 8 +++---- common/xbps-src/libexec/xbps-src-prepkg.sh | 2 +- common/xbps-src/shutils/common.sh | 21 +++++++++---------- common/xbps-src/shutils/pkgtarget.sh | 10 ++++----- xbps-src | 3 ++- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh index e3da4ea8d1..2b4c93dfb7 100644 --- a/common/hooks/do-pkg/00-gen-pkg.sh +++ b/common/hooks/do-pkg/00-gen-pkg.sh @@ -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 diff --git a/common/hooks/post-install/05-generate-gitrevs.sh b/common/hooks/post-install/05-generate-gitrevs.sh index e4e0690973..fe162e2224 100644 --- a/common/hooks/post-install/05-generate-gitrevs.sh +++ b/common/hooks/post-install/05-generate-gitrevs.sh @@ -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. diff --git a/common/xbps-src/libexec/xbps-src-dobuild.sh b/common/xbps-src/libexec/xbps-src-dobuild.sh index af71cb8c49..78de296416 100755 --- a/common/xbps-src/libexec/xbps-src-dobuild.sh +++ b/common/xbps-src/libexec/xbps-src-dobuild.sh @@ -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 diff --git a/common/xbps-src/libexec/xbps-src-doconfigure.sh b/common/xbps-src/libexec/xbps-src-doconfigure.sh index cd4c070ab8..5f03a0df69 100755 --- a/common/xbps-src/libexec/xbps-src-doconfigure.sh +++ b/common/xbps-src/libexec/xbps-src-doconfigure.sh @@ -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 diff --git a/common/xbps-src/libexec/xbps-src-doextract.sh b/common/xbps-src/libexec/xbps-src-doextract.sh index d769f68593..ba8a3d7be8 100755 --- a/common/xbps-src/libexec/xbps-src-doextract.sh +++ b/common/xbps-src/libexec/xbps-src-doextract.sh @@ -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 diff --git a/common/xbps-src/libexec/xbps-src-dofetch.sh b/common/xbps-src/libexec/xbps-src-dofetch.sh index e5241aeca0..ef7a975c9a 100755 --- a/common/xbps-src/libexec/xbps-src-dofetch.sh +++ b/common/xbps-src/libexec/xbps-src-dofetch.sh @@ -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 diff --git a/common/xbps-src/libexec/xbps-src-doinstall.sh b/common/xbps-src/libexec/xbps-src-doinstall.sh index 3f0178fe47..33ca84ec36 100755 --- a/common/xbps-src/libexec/xbps-src-doinstall.sh +++ b/common/xbps-src/libexec/xbps-src-doinstall.sh @@ -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 diff --git a/common/xbps-src/libexec/xbps-src-prepkg.sh b/common/xbps-src/libexec/xbps-src-prepkg.sh index d5e657ae8c..b89d741fec 100755 --- a/common/xbps-src/libexec/xbps-src-prepkg.sh +++ b/common/xbps-src/libexec/xbps-src-prepkg.sh @@ -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 diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index 1ffc316c77..d74539139c 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -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 } diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh index 736a4c6513..3a229cdc26 100644 --- a/common/xbps-src/shutils/pkgtarget.sh +++ b/common/xbps-src/shutils/pkgtarget.sh @@ -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 } diff --git a/xbps-src b/xbps-src index 8dbef8dc63..43b39da08a 100755 --- a/xbps-src +++ b/xbps-src @@ -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