change build scripts to make reproducible builds possible

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 85c1ff8667f276f586f98de9546f6c3d5bec2049
Author: Skye <[email protected]>
Date:   Fri Aug 7 22:27:45 2026 +0900

    change build scripts to make reproducible builds possible
    
    - makes SOURCE_DATE_EPOCH affect BUILDDATE and version string
    - makes wpsbuild.pl output deterministic
    - omits unnecessary extended metadata from zip files
    - runs strip-nondeterminism on zip files if REPRODUCIBLE_ZIP is set
    
    Change-Id: I1617e3f5233b2bc356fcfa6457be1a7785c303f9

diff --git a/apps/lang/lang.make b/apps/lang/lang.make
index 2952ac5aef..5923597e86 100644
--- a/apps/lang/lang.make
+++ b/apps/lang/lang.make
@@ -62,7 +62,10 @@ $(BUILDDIR)/apps/lang/lang-enum.txt: $(BUILDDIR)/lang_enum.h
 
 $(BUILDDIR)/apps/lang/voicestrings.zip: $(VOICEOBJ) $(wildcard $(BUILDDIR)/apps/lang/*.talk) $(BUILDDIR)/apps/lang/voice-corrections.txt $(BUILDDIR)/apps/lang/lang-enum.txt
 	$(call PRINTS,ZIP $(subst $(BUILDDIR)/,,$@))
-	$(SILENT)zip -9 -q $@ $(subst $(BUILDDIR)/,,$^)
+	$(SILENT)zip -X -9 -q $@ $(subst $(BUILDDIR)/,,$^)
+ifneq ($(REPRODUCIBLE_ZIP),)
+	$(SILENT)strip-nondeterminism $@
+endif
 
 #copy any included talk files to the /lang directory
 $(BUILDDIR)/apps/lang/%.talk: $(ROOTDIR)/apps/lang/%.talk
diff --git a/tools/buildzip.pl b/tools/buildzip.pl
index 0613be1484..8f546db270 100755
--- a/tools/buildzip.pl
+++ b/tools/buildzip.pl
@@ -259,7 +259,7 @@ GetOptions ( 'r|root=s'      => \$ROOT,
 # Thus we use the ":" for those for which we use a default value in case of ""
 # and assign the default value afterwards
 if ($ziptool eq '') {
-    $ziptool = "zip -r9";
+    $ziptool = "zip -r9 -X";
 }
 if ($output eq '') {
     $output = "rockbox.zip"
diff --git a/tools/configure b/tools/configure
index ff19ab75ab..608f783763 100755
--- a/tools/configure
+++ b/tools/configure
@@ -4915,7 +4915,11 @@ export BUILDDIR=${pwd}
 export RBCODEC_BLD=${pwd}/lib/rbcodec
 export VOICELANGUAGE=${voicelanguage}
 export MEMORYSIZE=${memory}
+ifeq (\$(SOURCE_DATE_EPOCH),)
 export BUILDDATE:=\$(shell date -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d')
+else
+export BUILDDATE:=\$(shell date -d "@\$(SOURCE_DATE_EPOCH)" -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d')
+endif
 export MKFIRMWARE=${tool}
 export BMP2RB_MONO=${bmp2rb_mono}
 export BMP2RB_NATIVE=${bmp2rb_native}
diff --git a/tools/root.make b/tools/root.make
index 11540a0a39..46acf85e78 100644
--- a/tools/root.make
+++ b/tools/root.make
@@ -351,6 +351,9 @@ $(BUILDDIR)/rockbox.zip: build
 endif
 	$(call PRINTS,ZIP rockbox$(ZIPFILESUFFIX).zip)
 	$(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o $(BUILDDIR)/rockbox$(ZIPFILESUFFIX).zip -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(BUILDZIPOPTS) $(TARGET) $(BINARY)
+ifneq ($(REPRODUCIBLE_ZIP),)
+	$(SILENT)strip-nondeterminism $(BUILDDIR)/rockbox$(ZIPFILESUFFIX).zip
+endif
 
 mapzip:
 	$(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
diff --git a/tools/version.sh b/tools/version.sh
index 2fcdcd02c4..f2b2196ee5 100755
--- a/tools/version.sh
+++ b/tools/version.sh
@@ -50,7 +50,11 @@ if [ -z $VERSION ]; then
         # Ok, we need to derive it from the Version Control system
 	    VER=`gitversion $TOP`
     fi
-VERSION=$VER-`date -u +%y%m%d`
+if [ -z $SOURCE_DATE_EPOCH ]; then
+	VERSION=$VER-`date -u +%y%m%d`
+else
+	VERSION=$VER-`date -d @$SOURCE_DATE_EPOCH -u +%y%m%d`
+fi
 fi
 echo $VERSION
 
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl
index e3e8c178ec..ccc4cad1f4 100755
--- a/wps/wpsbuild.pl
+++ b/wps/wpsbuild.pl
@@ -268,7 +268,7 @@ MOO
                      "rwps" => $rwps,
                      "rsbs" => $rsbs,
                      "rfms" => $rfms);
-    for my $skin (keys %skinfiles) {
+    for my $skin (sort keys %skinfiles) {
         my $val = $skinfiles{$skin};
         if (!defined($val)) {
             # dont put value if not defined (e.g. rwps when there's no remote)
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.