environment/build: overwrite __DATE__, __TIME__, and __TIMESTAMP__ macros.

This commit overwrites timestamps that depend on timestamps with the
commit date of a package.
This commit is contained in:
Enno Boland 2016-02-29 08:46:40 +01:00
parent a34576cac3
commit 3c04642877
6 changed files with 25 additions and 20 deletions

View file

@ -2,25 +2,9 @@
# - sets the timestamps in a package to the commit date
hook() {
local GIT_CMD date basepkg
# If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
return
# If XBPS_COMMIT_TIMESTAMP is set, set mtimes to that timestamp.
if [ -n "$XBPS_COMMIT_TIMESTAMP" ]; then
msg_normal "$pkgver: setting mtimes to %s\n" "$(date --date "$XBPS_COMMIT_TIMESTAMP")"
find $PKGDESTDIR -print0 | xargs -0 touch -h --date "$XBPS_COMMIT_TIMESTAMP"
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"
fi
basepkg=$pkgname
if [ -L "${XBPS_SRCPKGDIR}/$basepkg" ]; then
basepkg=$(readlink "${XBPS_SRCPKGDIR}/$basepkg")
fi
date=$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} log --pretty='%ci' --date=iso -n1 .)
msg_normal "$pkgver: setting mtimes to %s\n" "$(date --date "$date")"
find $PKGDESTDIR -print0 | xargs -0 touch -h --date "$date"
}