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

@ -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
}