common/environment: check if package is under version control.

only use git commit date for SOURCE_DATE_EPOCH if the template is under version
control.  Fall back to templates mtime if it's not managed by git.
This commit is contained in:
Enno Boland 2016-03-06 12:52:20 +01:00
parent c23b7e6ba4
commit d84d62940d

View file

@ -6,5 +6,10 @@ if [ -z "$XBPS_USE_BUILD_MTIME" -a -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT"
elif command -v git &>/dev/null; then
GIT_CMD=$(command -v git)
fi
export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} log --pretty='%ct' -n1 .)"
# check if the template is under version control:
if $GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status --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_SRCPKGDIR}/${basepkg} log --pretty='%ct' -n1 .)"
fi
fi