xbps-src: use $XBPS_GIT_CMD for git

This commit is contained in:
Đoàn Trần Công Danh 2020-04-22 20:59:26 +07:00 committed by Danh Doan
parent f1773b7792
commit 20f9bedefb
3 changed files with 14 additions and 21 deletions

View File

@ -1,19 +1,17 @@
# If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
# only run this, if SOURCE_DATE_EPOCH isn't set.
if [ -z "$XBPS_GIT_CMD" ]; then
msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
fi
if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
unset SOURCE_DATE_EPOCH
return 0
fi
if [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
if command -v chroot-git &>/dev/null; then
GIT_CMD=$(command -v chroot-git)
elif command -v git &>/dev/null; then
GIT_CMD=$(command -v git)
fi
elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
# check if the template is under version control:
if $GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
if $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
export SOURCE_DATE_EPOCH="$(stat -c %Y ${XBPS_SRCPKGDIR}/${basepkg}/template)"
else
export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
export SOURCE_DATE_EPOCH="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
fi
fi

View File

@ -3,7 +3,7 @@
hook() {
local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
local GIT_CMD rev
local rev
# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
if [ -z $XBPS_USE_GIT_REVS ]; then
@ -14,16 +14,12 @@ hook() {
return
fi
if command -v chroot-git &>/dev/null; then
GIT_CMD=$(command -v chroot-git)
elif command -v git &>/dev/null; then
GIT_CMD=$(command -v git)
else
msg_error "$pkgver: cannot find chroot-git or git utility, exiting...\n"
if [ -z "$XBPS_GIT_CMD" ]; then
msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
fi
cd $XBPS_SRCPKGDIR
rev="$($GIT_CMD rev-parse --short HEAD)"
rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
echo "${sourcepkg}:${rev}"
echo "${sourcepkg}:${rev}" > $GITREVS_FILE
}

View File

@ -508,14 +508,13 @@ fi
# Try using chroot-git then git from the host system
if command -v chroot-git &>/dev/null; then
XBPS_GIT_CMD=$(command -v chroot-git)
export XBPS_GIT_CMD=$(command -v chroot-git)
elif command -v git &>/dev/null; then
XBPS_GIT_CMD=$(command -v git)
export XBPS_GIT_CMD=$(command -v git)
else
echo "neither chroot-git or git are available in your system!" 1>&2
exit 1
fi
readonly XBPS_GIT_CMD
if [ -n "$XBPS_HOSTDIR" ]; then
export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs