aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnno Boland <g@s01.de>2016-02-19 12:45:49 +0000
committerEnno Boland <g@s01.de>2016-02-19 15:21:56 +0000
commit16050ad3f292306b0421ee6133b174db3f1b227d (patch)
tree06c9ed93d6aa4b820b30d435b4a6fa6576911e6f
parentbb03d78ad09097250c8105601f87845a025115b6 (diff)
downloadvoid-packages-16050ad3f292306b0421ee6133b174db3f1b227d.tar
void-packages-16050ad3f292306b0421ee6133b174db3f1b227d.tar.gz
void-packages-16050ad3f292306b0421ee6133b174db3f1b227d.tar.bz2
void-packages-16050ad3f292306b0421ee6133b174db3f1b227d.tar.lz
void-packages-16050ad3f292306b0421ee6133b174db3f1b227d.tar.xz
void-packages-16050ad3f292306b0421ee6133b174db3f1b227d.tar.zst
void-packages-16050ad3f292306b0421ee6133b174db3f1b227d.zip
hooks/pre-pkg: fixed mtime support for packages.
overwrites the mtime of all files in a package with the commit-date of the package.
-rw-r--r--common/hooks/pre-pkg/90-set-timestamps.sh26
-rw-r--r--etc/defaults.conf6
-rwxr-xr-xxbps-src3
3 files changed, 34 insertions, 1 deletions
diff --git a/common/hooks/pre-pkg/90-set-timestamps.sh b/common/hooks/pre-pkg/90-set-timestamps.sh
new file mode 100644
index 00000000000..a60a90f1ddf
--- /dev/null
+++ b/common/hooks/pre-pkg/90-set-timestamps.sh
@@ -0,0 +1,26 @@
+# This hook executes the following tasks:
+# - sets the timestamps in a package to the commit date
+
+hook() {
+ local GIT_CMD date basepkg
+
+ # If XBPS_USE_GIT_COMMIT_DATE is disabled in conf file don't continue.
+ if [ -z $XBPS_USE_GIT_COMMIT_DATE ]; then
+ return
+ 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 --date "$date"
+}
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 500a16514f3..956c5fb4277 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -113,3 +113,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
#
#XBPS_CHROOT_CMD=proot
#XBPS_CHROOT_CMD_ARGS=""
+
+# [OPTIONAL]
+# Enable fixed timestamps. If set xbps-src will overwrite the mtime of all files
+# in a package with the commit date of the package.
+#
+#XBPS_USE_GIT_COMMIT_DATE=yes
diff --git a/xbps-src b/xbps-src
index 114d1e12411..4747076800c 100755
--- a/xbps-src
+++ b/xbps-src
@@ -560,7 +560,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_PKG_OPTIONS XBPS_CONFIG_FILE \
XBPS_KEEP_ALL XBPS_HOSTDIR XBPS_MASTERDIR XBPS_SRC_VERSION \
XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
- XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED
+ XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
+ XBPS_USE_GIT_COMMIT_DATE
for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
eval val="\$XBPS_$i"