diff options
author | Paul Spooren <mail@aparcar.org> | 2021-06-18 09:57:21 -1000 |
---|---|---|
committer | Paul Spooren <mail@aparcar.org> | 2021-08-05 22:53:37 +0200 |
commit | f03457831cf5ed0a643053f44a025d1671429bdc (patch) | |
tree | bac704f368ca9282cf4cafb62d7972248eae72c6 | |
parent | a259345d7ecfe3286db693327122f43b4af7404a (diff) |
main/busybox: show reproducible timestamp
This backports a patch which uses a reproducible timestamp in the
version/help/login message. It's based on SOURCE_DATE_EPOCH.
The added patch is already part of upstream.
Signed-off-by: Paul Spooren <mail@aparcar.org>
-rw-r--r-- | main/busybox/0013-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch | 80 | ||||
-rw-r--r-- | main/busybox/APKBUILD | 7 |
2 files changed, 83 insertions, 4 deletions
diff --git a/main/busybox/0013-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch b/main/busybox/0013-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch new file mode 100644 index 00000000000..af473622ed2 --- /dev/null +++ b/main/busybox/0013-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch @@ -0,0 +1,80 @@ +From 59f773ee81a8945321f4aa20abc5e9577e6483e4 Mon Sep 17 00:00:00 2001 +From: Paul Spooren <mail@aparcar.org> +Date: Thu, 13 May 2021 11:25:34 +0200 +Subject: [PATCH] use SOURCE_DATE_EPOCH for timestamp if available + +The SOURCE_DATE_EPOCH is an effort of the Reproducible Builds +organization to make timestamps/build dates in compiled tools +deterministic over several repetitive builds. + +Busybox shows by default the build date timestamp which changes whenever +compiled. To have a reasonable accurate build date while staying +reproducible, it's possible to use the *date of last source +modification* rather than the current time and date. + +Further information on SOURCE_DATE_EPOCH are available online [1]. + +This patch modifies `confdata.c` so that the content of the +SOURCE_DATE_EPOCH env variable is used as timestamp. + +To be independent of different timezones between builds, whenever +SOURCE_DATE_EPOCH is defined the GMT time is used. + +[1]: https://reproducible-builds.org/docs/source-date-epoch/ + +Signed-off-by: Paul Spooren <mail@aparcar.org> +--- + scripts/kconfig/confdata.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index b05b96e45..73c25e3a8 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -342,6 +342,8 @@ int conf_write(const char *name) + time_t now; + int use_timestamp = 1; + char *env; ++ char *source_date_epoch; ++ struct tm *build_time; + + dirname[0] = 0; + if (name && name[0]) { +@@ -378,7 +380,16 @@ int conf_write(const char *name) + } + sym = sym_lookup("KERNELVERSION", 0); + sym_calc_value(sym); +- time(&now); ++ ++ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch && *source_date_epoch) { ++ now = strtoull(source_date_epoch, NULL, 10); ++ build_time = gmtime(&now); ++ } else { ++ time(&now); ++ build_time = localtime(&now); ++ } ++ + env = getenv("KCONFIG_NOTIMESTAMP"); + if (env && *env) + use_timestamp = 0; +@@ -398,14 +409,14 @@ int conf_write(const char *name) + if (use_timestamp) { + size_t ret = \ + strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " +- "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now)); ++ "\"%Y-%m-%d %H:%M:%S %Z\"\n", build_time); + /* if user has Factory timezone or some other odd install, the + * %Z above will overflow the string leaving us with undefined + * results ... so let's try again without the timezone. + */ + if (ret == 0) + strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " +- "\"%Y-%m-%d %H:%M:%S\"\n", localtime(&now)); ++ "\"%Y-%m-%d %H:%M:%S\"\n", build_time); + } else { /* bbox */ + strcpy(buf, "#define AUTOCONF_TIMESTAMP \"\"\n"); + } +-- +2.30.2 + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index ecf9a3ce1e5..c9026f95585 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -4,7 +4,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=busybox pkgver=1.33.1 -pkgrel=4 +pkgrel=5 pkgdesc="Size optimized toolbox of many common UNIX utilities" url="https://busybox.net/" arch="all" @@ -35,6 +35,7 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2 0009-depmod-support-generating-kmod-binary-index-files.patch 0010-Add-flag-for-not-following-symlinks-when-recursing.patch 0012-udhcpc-Don-t-background-if-n-is-given.patch + 0013-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch 0001-echo-do-not-assume-that-free-leaves-errno-unmodified.patch 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch @@ -89,9 +90,6 @@ build() { ${CC:-${CROSS_COMPILE}gcc} ${CPPFLAGS} ${CFLAGS} $(pkg-config --cflags libtls) \ "$srcdir"/ssl_client.c -o "$_dyndir"/ssl_client ${LDFLAGS} $(pkg-config --libs libtls) - # no timestamp in build - export KCONFIG_NOTIMESTAMP=1 - # build dynamic cd "$_dyndir" msg "Building dynamic busybox" @@ -251,6 +249,7 @@ ecbe5c890d966f09280c7eb534109f785c68e292765f17ed7ff62fcc61d20f61443c4155add0a1eb d12246f1134bbd3993462d27172c4739cc601b251d57ce8e088745773afa965551236e8cb8b9013dfc142fd055e369a771d86c7c54615c89bd30393400bfa390 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch 6f8fa4ec190d64d6c3d5377994be933885ed0b40361c99ca35881684db3b1b79664d6eab56a389df290b9f6c4db502c617ec8e4ffa6d5284bd41cea1f478b26c 0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch 97109be04445b7b887c402b7072c1da57212ef11f2eca6d34c24d5a4e3b2866ee79aca7a0ca41043726293d9bed1b2fa8aab100501569f00b8670c280a87a01c 0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch +aebb6bbce0ebd0b3eb090ef379ddc43d7fffb8da7c1dfebed046ddd40e4c5666ab7653c416dca34e1ddd8a788888cb783ab21e8e9734ce48ead9403b0c3b4163 0013-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate 9fc6424fb28e1fb5d6fba7a389ced7b8fdedb20ba418db22b5092de0db3faee9cedbccb14f9e9e1ff5f173e58ddc2d92417241bde0006fbdb99986f3fc397e01 busyboxconfig 470a646505887dbf20dd8c3c3b5c8ab25f363f3a0bfbca577de115b8ec61f28e9843f4f3a7978c634e863dbf28bae987f20e7fa1aa529450ff6c17bc188cae53 busyboxconfig-extras |