]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
dist: fix reproducible build from release tarball
authorDaniel Stenberg <daniel@haxx.se>
Thu, 1 Aug 2024 11:51:43 +0000 (13:51 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 2 Aug 2024 06:28:56 +0000 (08:28 +0200)
Make it possible to rebuild an identical copy from a release tarball. It
was previously only possible from a checked out git repository.

- add release-tools.sh to dist
- keep Makefile.dist around to include it in dist
- regenerate tool_huge.c with the new version in dist
- fix the dist CI job to not do make clean like before

Closes #14336

.github/workflows/distcheck.yml
Makefile.am
maketgz
scripts/Makefile.am
scripts/managen

index 40c256712be5046f157608ea875046bae8ec53bc..61df59110ec3fa6959d69555a25eb48671157308 100644 (file)
@@ -35,8 +35,8 @@ jobs:
       - run: ./configure --without-ssl --without-libpsl
         name: 'configure'
 
-      - run: make V=1 && make V=1 clean
-        name: 'make and clean'
+      - run: make V=1
+        name: 'make'
 
       - name: 'maketgz'
         run: |
@@ -45,7 +45,7 @@ jobs:
       - name: 'maketgz reproducibility test'
         run: |
           mkdir run1; mv ./curl-99.98.97.* run1/
-          make V=1 && make V=1 clean
+          make V=1 clean && make V=1
           SOURCE_DATE_EPOCH=1711526400 ./maketgz 99.98.97
           mkdir run2; cp -p ./curl-99.98.97.* run2/
           diff run1 run2
index 62b35a53540344cd121b2d3a984ec4cf9c3ba825..74441402d81b744281829e1e7b3574faa24fcfa8 100644 (file)
@@ -101,8 +101,8 @@ include src/Makefile.inc
 
 dist-hook:
        rm -rf $(top_builddir)/tests/log
-       find $(distdir) -name "*.dist" -exec rm {} \;
-       (distit=`find $(srcdir) -name "*.dist" | grep -v ./ares/`; \
+       find $(distdir) -name "*.dist" -a \! -name Makefile.dist -exec rm {} \;
+       (distit=`find $(srcdir) -name "*.dist"`; \
        for file in $$distit; do \
          strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
          cp -p $$file $(distdir)$$strip; \
diff --git a/maketgz b/maketgz
index 18749448cf7090884246871b0a107857d0ffeb37..d24524345bc1616ce327a278f66975fc261319b4 100755 (executable)
--- a/maketgz
+++ b/maketgz
@@ -87,7 +87,7 @@ datestamp=$(date -d "@$timestamp" +"%F")
 filestamp=$(date -d "@$timestamp" +"%Y%m%d%H%M.%S")
 
 # Replace version number in header file:
-sed -i.bak \
+sed -i \
   -e "s/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION \"$libversion\"/g" \
   -e "s/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x$numeric/g" \
   -e "s/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR $major/g" \
@@ -95,11 +95,9 @@ sed -i.bak \
   -e "s/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH $patch/g" \
   -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
   "$HEADER"
-rm -f "$HEADER.bak"
 
 # Replace version number in header file:
-sed -i.bak "s/#define CURL_VERSION .*/#define CURL_VERSION \"$curlversion\"/g" "$CHEADER"
-rm -f "$CHEADER.bak"
+sed -i "s/#define CURL_VERSION .*/#define CURL_VERSION \"$curlversion\"/g" "$CHEADER"
 
 if test -n "$only"; then
   # done!
@@ -133,6 +131,11 @@ findprog() {
 echo "Re-running config.status"
 ./config.status --recheck >/dev/null
 
+echo "Recreate the built-in manual (with correct version)"
+export CURL_MAKETGZ_VERSION="$version"
+rm -f docs/cmdline-opts/curl.txt
+make -C src
+
 ############################################################################
 #
 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
index 772c7bd8dac456d6ee9c255258707fc8f83605eb..1b8c4e7366a1178c9abc36a7063b43573b636400 100644 (file)
@@ -24,7 +24,7 @@
 
 EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl    \
  mk-ca-bundle.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
- dmaketgz
+ dmaketgz release-tools.sh
 
 ZSH_FUNCTIONS_DIR = @ZSH_FUNCTIONS_DIR@
 FISH_FUNCTIONS_DIR = @FISH_FUNCTIONS_DIR@
index 7cdb6581782173cbe40680f7c6d566849177943b..65d23611f408cb9f7a55d76dc4ea19e82953ea47 100755 (executable)
@@ -1205,14 +1205,20 @@ elsif($cmd eq "-c") {
 
 my @files = @ARGV; # the rest are the files
 
-open(INC, "<$include/curl/curlver.h");
-while(<INC>) {
-    if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
-        $version = $1;
-        last;
+# can be overriden for releases
+if($ENV{'CURL_MAKETGZ_VERSION'}) {
+    $version = $ENV{'CURL_MAKETGZ_VERSION'};
+}
+else {
+    open(INC, "<$include/curl/curlver.h");
+    while(<INC>) {
+        if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
+            $version = $1;
+            last;
+        }
     }
+    close(INC);
 }
-close(INC);
 
 # learn all existing options
 indexoptions($dir, @files);