setup: compute gitrev from outside of chroot

Together with previous commit, `xbps-src` is able to support
git-worktree and shared repository by now.
This commit is contained in:
Đoàn Trần Công Danh 2020-04-21 22:52:38 +07:00 committed by Danh Doan
parent 2cd2b99e41
commit 2af30cdd78
3 changed files with 17 additions and 6 deletions

View File

@ -18,3 +18,15 @@ elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
export SOURCE_DATE_EPOCH="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
fi
fi
# if XBPS_USE_GIT_REVS is enabled in conf file,
# compute XBPS_GIT_REVS to use in pkg hooks
if [ -z "$XBPS_USE_GIT_REVS" ]; then
unset XBPS_GIT_REVS
elif [ -z "$XBPS_GIT_REVS" ]; then
if [ -n "$IN_CHROOT" ]; then
msg_error "xbps-src's BUG: XBPS_GIT_REVS is undefined\n"
else
export XBPS_GIT_REVS="$($XBPS_GIT_CMD -C "${XBPS_DISTDIR}" rev-parse --verify --short HEAD)"
fi
fi

View File

@ -3,7 +3,6 @@
hook() {
local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
local rev
# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
if [ -z $XBPS_USE_GIT_REVS ]; then
@ -14,12 +13,11 @@ hook() {
return
fi
if [ -z "$XBPS_GIT_CMD" ]; then
msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
if [ -z "$XBPS_GIT_REVS" ]; then
msg_error "BUG: XBPS_GIT_REVS is not set\n"
fi
cd $XBPS_SRCPKGDIR
rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
echo "${sourcepkg}:${rev}"
echo "${sourcepkg}:${rev}" > $GITREVS_FILE
echo "${sourcepkg}:${XBPS_GIT_REVS}"
echo "${sourcepkg}:${XBPS_GIT_REVS}" > $GITREVS_FILE
}

View File

@ -175,6 +175,7 @@ chroot_handler() {
${HTTP_PROXY_AUTH:+HTTP_PROXY_AUTH="${HTTP_PROXY_AUTH}"} \
${FTP_RETRIES:+FTP_RETRIES="${FTP_RETRIES}"} \
SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
XBPS_GIT_REVS="$XBPS_GIT_REVS" \
XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \