[OpenWrt-Devel] [PATCH 05/13] include/image: introduce SOURCE_DATE_EPOCH variable in image context
Alexander Couzens
lynxis at fe80.eu
Mon Jan 25 15:49:27 EST 2016
SOURCE_DATE_EPOCH is the date of the last modified file using git/svn
as date source.
See https://reproducible-builds.org/specs/source-date-epoch/
Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
include/image.mk | 1 +
scripts/getsource_date_epoch.sh | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100755 scripts/getsource_date_epoch.sh
diff --git a/include/image.mk b/include/image.mk
index 4eee4ad..a53bea8 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -14,6 +14,7 @@ include $(INCLUDE_DIR)/version.mk
override MAKE:=$(_SINGLE)$(SUBMAKE)
override NO_TRACE_MAKE:=$(_SINGLE)$(NO_TRACE_MAKE)
+export SOURCE_DATE_EPOCH:=$(shell $(TOPDIR)/scripts/getsource_date_epoch.sh)
KDIR=$(KERNEL_BUILD_DIR)
KDIR_TMP=$(KDIR)/tmp
DTS_DIR:=$(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts
diff --git a/scripts/getsource_date_epoch.sh b/scripts/getsource_date_epoch.sh
new file mode 100755
index 0000000..bfe9c4b
--- /dev/null
+++ b/scripts/getsource_date_epoch.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+export LANG=C
+export LC_ALL=C
+[ -n "$TOPDIR" ] && cd $TOPDIR
+
+try_version() {
+ [ -f version.date ] || return 1
+ SOURCE_DATE_EPOCH="$(cat version.date)"
+ [ -n "$SOURCE_DATE_EPOCH" ]
+}
+
+try_svn() {
+ [ -d .svn ] || return 1
+ SOURCE_DATE_EPOCH="$(date -d "$(svn info svn://svn.openwrt.org/openwrt/ --show-item last-changed-date)" +%s)"
+ [ -n "$SOURCE_DATE_EPOCH" ]
+}
+
+try_git() {
+ [ -e .git ] || return 1
+ SOURCE_DATE_EPOCH="$(git log -1 --format=format:%ct)"
+ [ -n "$SOURCE_DATE_EPOCH" ]
+}
+
+try_hg() {
+ [ -d .hg ] || return 1
+ SOURCE_DATE_EPOCH=""
+ [ -n "$SOURCE_DATE_EPOCH" ]
+}
+
+try_version || try_svn || try_git || try_hg || SOURCE_DATE_EPOCH=""
+echo "$SOURCE_DATE_EPOCH"
--
2.7.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list