build: store granular timestamps in packages

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>
This commit is contained in:
Paul Spooren
2020-08-15 10:57:02 -10:00
committed by Daniel Golle
parent a83b2af47f
commit fd29f2bcd9
2 changed files with 4 additions and 9 deletions

View File

@@ -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