diff mbox series

base-files: add SOURCE_DATE_EPOCH /usr/lib/os-release

Message ID 20240618132343.3740920-1-fe@dev.tdt.de
State New
Headers show
Series base-files: add SOURCE_DATE_EPOCH /usr/lib/os-release | expand

Commit Message

Florian Eckert June 18, 2024, 1:23 p.m. UTC
The variable 'SOURCE_DATE_EPOCH' is used in the build system to have a
defined build time for the entire software. This information is discovered
with the script '/scripts/get_source_date_epoch.sh'.

This information is used to generate reproducible binary builds and should
therefore be available in the file '/usr/lib/os-release' on the target.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
 include/version.mk                          | 3 ++-
 package/base-files/files/usr/lib/os-release | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Etienne Champetier June 18, 2024, 2:56 p.m. UTC | #1
Hello Florian,

Le mar. 18 juin 2024 à 15:25, Florian Eckert <fe@dev.tdt.de> a écrit :
>
> The variable 'SOURCE_DATE_EPOCH' is used in the build system to have a
> defined build time for the entire software. This information is discovered
> with the script '/scripts/get_source_date_epoch.sh'.
>
> This information is used to generate reproducible binary builds and should
> therefore be available in the file '/usr/lib/os-release' on the target.

Why not set SOURCE_DATE_EPOCH to 1 and never change it again ?
(setting it to 0 might break stuff)
Having the last commit date in os-release is still interesting

Best
Etienne
Florian Eckert June 19, 2024, 7:48 a.m. UTC | #2
Hello Etienne,

>> The variable 'SOURCE_DATE_EPOCH' is used in the build system to have a
>> defined build time for the entire software. This information is 
>> discovered
>> with the script '/scripts/get_source_date_epoch.sh'.
>> 
>> This information is used to generate reproducible binary builds and 
>> should
>> therefore be available in the file '/usr/lib/os-release' on the 
>> target.
> 
> Why not set SOURCE_DATE_EPOCH to 1 and never change it again ?

Unfortunately, I don't understand what you're trying to tell me. The
'SOURCE_DATE_EPOCH' is the last commit time in OpenWrt git repo. This
is discovered with the script '/scripts/get_source_date_epoch.sh' [1].


> Having the last commit date in os-release is still interesting

:+1:

Best regards

Florian

[1] 
https://github.com/openwrt/openwrt/blob/main/scripts/get_source_date_epoch.sh
Etienne Champetier June 19, 2024, 8:30 a.m. UTC | #3
Le mer. 19 juin 2024 à 09:49, Florian Eckert <fe@dev.tdt.de> a écrit :
>
> Hello Etienne,
>
> >> The variable 'SOURCE_DATE_EPOCH' is used in the build system to have a
> >> defined build time for the entire software. This information is
> >> discovered
> >> with the script '/scripts/get_source_date_epoch.sh'.
> >>
> >> This information is used to generate reproducible binary builds and
> >> should
> >> therefore be available in the file '/usr/lib/os-release' on the
> >> target.
> >
> > Why not set SOURCE_DATE_EPOCH to 1 and never change it again ?
>
> Unfortunately, I don't understand what you're trying to tell me. The
> 'SOURCE_DATE_EPOCH' is the last commit time in OpenWrt git repo. This
> is discovered with the script '/scripts/get_source_date_epoch.sh' [1].

This is not directly related to your patch, what I'm trying to say is
why spend cpu cycles
getting the last commit date for each package and not just hardcode it ?

> > Having the last commit date in os-release is still interesting
>
> :+1:
>
> Best regards
>
> Florian
>
> [1]
> https://github.com/openwrt/openwrt/blob/main/scripts/get_source_date_epoch.sh
diff mbox series

Patch

diff --git a/include/version.mk b/include/version.mk
index cdee0976da..1ac29b629a 100644
--- a/include/version.mk
+++ b/include/version.mk
@@ -104,5 +104,6 @@  VERSION_SED_SCRIPT:=$(SED) 's,%U,$(call sed_escape,$(VERSION_REPO)),g' \
 	-e 's,%u,$(call sed_escape,$(VERSION_HOME_URL)),g' \
 	-e 's,%s,$(call sed_escape,$(VERSION_SUPPORT_URL)),g' \
 	-e 's,%P,$(call sed_escape,$(VERSION_PRODUCT)),g' \
-	-e 's,%h,$(call sed_escape,$(VERSION_HWREV)),g'
+	-e 's,%h,$(call sed_escape,$(VERSION_HWREV)),g' \
+	-e 's,%B,$(call sed_escape,$(SOURCE_DATE_EPOCH)),g'
 
diff --git a/package/base-files/files/usr/lib/os-release b/package/base-files/files/usr/lib/os-release
index c39913d54f..12db2c0ac6 100644
--- a/package/base-files/files/usr/lib/os-release
+++ b/package/base-files/files/usr/lib/os-release
@@ -16,3 +16,4 @@  OPENWRT_DEVICE_MANUFACTURER_URL="%m"
 OPENWRT_DEVICE_PRODUCT="%P"
 OPENWRT_DEVICE_REVISION="%h"
 OPENWRT_RELEASE="%D %V %C"
+OPENWRT_BUILD_DATE="%B"