diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh index 870fa984e05..a2f7f0a28ee 100644 --- a/common/environment/setup/git.sh +++ b/common/environment/setup/git.sh @@ -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 diff --git a/common/hooks/post-install/05-generate-gitrevs.sh b/common/hooks/post-install/05-generate-gitrevs.sh index 82b2ab1a786..754ba8865b9 100644 --- a/common/hooks/post-install/05-generate-gitrevs.sh +++ b/common/hooks/post-install/05-generate-gitrevs.sh @@ -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 } diff --git a/xbps-src b/xbps-src index 1211094b444..fb5d94c6310 100755 --- a/xbps-src +++ b/xbps-src @@ -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