common: replace XBPS_COMMIT_TIMESTAMP by SOURCE_DATE_EPOCH

This way we are compatible to the Debians proposal. See [1].

[1] https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html
This commit is contained in:
Enno Boland 2016-03-01 18:27:16 +01:00
parent 69cb0beb58
commit b5e49c48e7
4 changed files with 10 additions and 10 deletions

View file

@ -1,9 +1,9 @@
if [ -n "$XBPS_COMMIT_TIMESTAMP" ]; then
if [ -n "$SOURCE_DATE_EPOCH" ]; then
CFLAGS+=" -Wno-builtin-macro-redefined -include $XBPS_STATEDIR/timestamp-macros.h"
CXXFLAGS+=" -Wno-builtin-macro-redefined -include $XBPS_STATEDIR/timestamp-macros.h"
for i in "DATE,%b %d %Y" "TIME,%H:%M:%S" "DATETIME,%b %d %Y %H:%M:%S"; do
mcr=${i%%,*}
val=$(LC_ALL=C date --date "$XBPS_COMMIT_TIMESTAMP" +"${i#*,}")
val=$(LC_ALL=C date --date "@$SOURCE_DATE_EPOCH" +"${i#*,}")
cat >> $XBPS_STATEDIR/timestamp-macros.h <<EOF
#undef __${mcr}__
#define __${mcr}__ "${val}"

View file

@ -1,10 +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
# only run this, if SOURCE_DATE_EPOCH isn't set
if [ -z "$XBPS_USE_BUILD_MTIME" ] && [ -z "${SOURCE_DATE_EPOCH}" ]; 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 .)"
export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} log --pretty='%ct' -n1 .)"
fi

View file

@ -2,9 +2,9 @@
# - sets the timestamps in a package to the commit date
hook() {
# 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"
# If SOURCE_DATE_EPOCH is set, set mtimes to that timestamp.
if [ -n "$SOURCE_DATE_EPOCH" ]; then
msg_normal "$pkgver: setting mtimes to %s\n" "$(date --date "@$SOURCE_DATE_EPOCH")"
find $PKGDESTDIR -print0 | xargs -0 touch -h --date "@$SOURCE_DATE_EPOCH"
fi
}

View file

@ -198,7 +198,7 @@ chroot_handler() {
action="$arg $action"
env -i PATH="/usr/bin:/usr/sbin:$PATH" SHELL=/bin/sh \
HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \
XBPS_COMMIT_TIMESTAMP="$XBPS_COMMIT_TIMESTAMP" \
SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \
/void-packages/xbps-src $action $pkg