perl: Set build date to SOURCE_DATE_EPOCH
PATCH 1/1 perl: Set build date to SOURCE_DATE_EPOCH
Perl uses an internal #define called PERL_BUILD_DATE as the string for the date when perl was built. If undefined, it defaults to using __DATE__ and __TIME__, which is not reproducible. If SOURCE_DATE_EPOCH is set at do_configure time, use it to generate a reproducible string for PERL_BUILD_DATE.
--- meta/recipes-devtools/perl-sanity/perl_5.28.2.bb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
meta/recipes-devtools/perl-sanity/perl_5.28.2.bb +7 -1
@@ -34,7 +34,7 @@ S = "${WORKDIR}/perl-${PV}" inherit upstream-version-is-even -DEPENDS += "db gdbm zlib virtual/crypt" +DEPENDS += "db gdbm zlib virtual/crypt coreutils-native" PERL_LIB_VER = "${@'.'.join(d.getVar('PV').split('.')[0:2])}.0"
@@ -90,6 +90,12 @@ do_configure_class-native() { -Ui_xlocale } +do_configure_append() { + if [ -n "$SOURCE_DATE_EPOCH" ]; then + echo "#define PERL_BUILD_DATE \"$(date --utc --date="@$SOURCE_DATE_EPOCH")\"" >> config.h + fi +} + do_compile() { oe_runmake }
Signature · 1 line
2.21.0
Quoted 25 lines · Joshua Watt
Perl uses an internal #define called
PERL_BUILD_DATEas the string for the date when perl was built. If undefined, it defaults to using__DATE__and__TIME__, which is not reproducible. IfSOURCE_DATE_EPOCHis set atdo_configuretime, use it to generate a reproducible string forPERL_BUILD_DATE.Signed-off-by Joshua Watt <[email protected]>--- meta/recipes-devtools/perl-sanity/perl_5.28.2.bb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)meta/recipes-devtools/perl-sanity/perl_5.28.2.bb +1
-1@@ -34,7 +34,7 @@ S = "${WORKDIR}/perl-${PV}" inherit upstream-version-is-even -DEPENDS += "db gdbm zlib virtual/crypt" +DEPENDS += "db gdbm zlib virtual/crypt coreutils-native" PERL_LIB_VER = "${@'.'.join(d.getVar('PV').split('.')[0:2])}.0"
meta/recipes-devtools/perl-sanity/perl_5.28.2.bb do_configure_class-native() { · line 98
Quoted 9 lines
meta/recipes-devtools/perl-sanity/perl_5.28.2.bb +6
-0@@ -90,6 +90,12 @@ do_configure_class-native() { -Ui_xlocale } +do_configure_append() { + if [ -n "$SOURCE_DATE_EPOCH" ]; then + echo "#define PERL_BUILD_DATE \"$(date --utc --date="@$SOURCE_DATE_EPOCH")\"" >> config.h + fi +} +
As discussed on irc, lets see if we can avoid a coreutils-native dependency and use python to do the conversion (or similar).
Cheers,
Richard
PATCH v2 1/1 perl: Set build date to SOURCE_DATE_EPOCH
In reply to Joshua WattPerl uses an internal #define called PERL_BUILD_DATE as the string for the date when perl was built. If undefined, it defaults to using __DATE__ and __TIME__, which is not reproducible. If SOURCE_DATE_EPOCH is set at do_configure time, use it to generate a reproducible string for PERL_BUILD_DATE.
--- meta/recipes-devtools/perl-sanity/perl_5.28.2.bb | 10 ++++++++++ 1 file changed, 10 insertions(+)
meta/recipes-devtools/perl-sanity/perl_5.28.2.bb +10 -0
@@ -90,6 +90,16 @@ do_configure_class-native() { -Ui_xlocale } +do_configure_append() { + if [ -n "$SOURCE_DATE_EPOCH" ]; then + PERL_BUILD_DATE="$(${PYTHON} -c "\ +from datetime import datetime, timezone; \ +print(datetime.fromtimestamp($SOURCE_DATE_EPOCH, timezone.utc).strftime('%a %b %d %H:%M:%S %Y')) \ + ")" + echo "#define PERL_BUILD_DATE \"$PERL_BUILD_DATE\"" >> config.h + fi +} + do_compile() { oe_runmake }
Signature · 1 line
2.21.0