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:
parent
a34576cac3
commit
3c04642877
6 changed files with 25 additions and 20 deletions
1
common/environment/build/timestamp-macros.sh
Symbolic link
1
common/environment/build/timestamp-macros.sh
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../configure/timestamp-macros.sh
|
8
common/environment/configure/timestamp-macros.sh
Normal file
8
common/environment/configure/timestamp-macros.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
if [ -n "$XBPS_COMMIT_TIMESTAMP" ]; then
|
||||||
|
CFLAGS+=" -Wno-builtin-macro-redefined"
|
||||||
|
CXXFLAGS+=" -Wno-builtin-macro-redefined"
|
||||||
|
for i in "DATE,%b\x20%d\x20%Y" "TIME,%H:%M:%S" "DATETIME,%b\x20%d\x20%Y\x20%H:%M:%S"; do
|
||||||
|
CFLAGS+=" -U__${i%%,*}__ -D__${i%%,*}__=\\\"$(LC_ALL=C date --date "$XBPS_COMMIT_TIMESTAMP" +"${i#*,}")\\\""
|
||||||
|
CXXFLAGS+=" -U__${i%%,*}__ -D__${i%%,*}__=\\\"$(LC_ALL=C date --date "$XBPS_COMMIT_TIMESTAMP" +"${i#*,}")\\\""
|
||||||
|
done
|
||||||
|
fi
|
1
common/environment/install/timestamp-macros.sh
Symbolic link
1
common/environment/install/timestamp-macros.sh
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../configure/timestamp-macros.sh
|
10
common/environment/setup/git.sh
Normal file
10
common/environment/setup/git.sh
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
|
||||||
|
# only run this, if XBPS_COMMIT_TIMESTAMP isn't set
|
||||||
|
if [ -z "$XBPS_USE_BUILD_MTIME" ] && [ -z "${XBPS_COMMIT_TIMESTAMP}" ]; 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
|
||||||
|
export XBPS_COMMIT_TIMESTAMP="$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} log --pretty='%ci' --date=iso -n1 .)"
|
||||||
|
fi
|
|
@ -2,25 +2,9 @@
|
||||||
# - sets the timestamps in a package to the commit date
|
# - sets the timestamps in a package to the commit date
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
local GIT_CMD date basepkg
|
# If XBPS_COMMIT_TIMESTAMP is set, set mtimes to that timestamp.
|
||||||
|
if [ -n "$XBPS_COMMIT_TIMESTAMP" ]; then
|
||||||
# If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
|
msg_normal "$pkgver: setting mtimes to %s\n" "$(date --date "$XBPS_COMMIT_TIMESTAMP")"
|
||||||
if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
|
find $PKGDESTDIR -print0 | xargs -0 touch -h --date "$XBPS_COMMIT_TIMESTAMP"
|
||||||
return
|
|
||||||
fi
|
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"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,7 @@ chroot_handler() {
|
||||||
action="$arg $action"
|
action="$arg $action"
|
||||||
env -i PATH="/usr/bin:/usr/sbin:$PATH" SHELL=/bin/sh \
|
env -i PATH="/usr/bin:/usr/sbin:$PATH" SHELL=/bin/sh \
|
||||||
HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \
|
HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \
|
||||||
|
XBPS_COMMIT_TIMESTAMP="$XBPS_COMMIT_TIMESTAMP" \
|
||||||
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
|
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
|
||||||
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \
|
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \
|
||||||
/void-packages/xbps-src $action $pkg
|
/void-packages/xbps-src $action $pkg
|
||||||
|
|
Loading…
Reference in a new issue