build: store granular timestamps in packages
authorPaul Spooren <mail@aparcar.org>
Sat, 15 Aug 2020 20:57:02 +0000 (10:57 -1000)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 31 Aug 2020 10:18:06 +0000 (11:18 +0100)
With the new `SOURCE` argument of `get_source_date_epoch` it is possible
to set package timestamps based on actual package changes rather thane
$TOPDIR changes.

This commit adds a new variable PKG_SOURCE_DATE_EPOCH which is used by
the `ipkg` build script. As a fallback the existing SOURCE_DATE_EPOCH is
used or as last resort the current time.

The redundant checks for `.git/` and `.svn/` are removed.

Signed-off-by: Paul Spooren <mail@aparcar.org>
include/package-ipkg.mk
scripts/ipkg-build

index d8b65433c2a7a2bdbed15bb87528d401ea488ead..808ac1c6e31d21795371e5758c76e5df3891ac23 100644 (file)
@@ -192,6 +192,7 @@ $(_endef)
     $$(IPKG_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL)
     $$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description)
     $$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG)
+    $$(IPKG_$(1)) : export PKG_SOURCE_DATE_EPOCH=$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh $(SOURCE))
     $(PKG_INFO_DIR)/$(1).provides $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk
        @rm -rf $$(IDIR_$(1)); \
                $$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_ipkg_wildcard,$(1))))
index 0cbab9074e98f5294b597c4169a33be193e6cd50..e3a9a882cf29d980eed3120fd2240720b04705fe 100755 (executable)
@@ -16,16 +16,10 @@ TAR="${TAR:-$(command -v tar)}"
 GZIP="$(command -v gzip)"
 
 # try to use fixed source epoch
-if [ -n "$SOURCE_DATE_EPOCH" ]; then
+if [ -n "$PKG_SOURCE_DATE_EPOCH" ]; then
+       TIMESTAMP=$(date --date="@$PKG_SOURCE_DATE_EPOCH")
+elif [ -n "$SOURCE_DATE_EPOCH" ]; then
        TIMESTAMP=$(date --date="@$SOURCE_DATE_EPOCH")
-
-# look up date of last commit
-elif [ -d "$TOPDIR/.git" ]; then
-       GIT="$(command -v git)"
-       TIMESTAMP=$(cd $TOPDIR; $GIT log -1 -s --format=%ci)
-elif [ -d "$TOPDIR/.svn" ]; then
-       SVN="$(command -v svn)"
-       TIMESTAMP=$($SVN info "$TOPDIR" | sed -n "s/^Last Changed Date: \(.*\)/\1/p")
 else
        TIMESTAMP=$(date)
 fi