void-packages/common/environment/setup/git.sh
Enno Boland d84d62940d 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.
2016-03-06 13:07:10 +01:00

16 lines
702 B
Bash

# 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_USE_BUILD_MTIME" -a -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
# 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