Subject: bug#74133: Some minor patches for the python script

From: Nikolaos Chatzikonstantinou <[email-masked]>
Date: Thu, 13 Feb 2025 10:47:28 -0500

On Thu, Feb 13, 2025 at 9:58 AM Stefan Kangas <[email-masked]> wrote:
>
> Nikolaos Chatzikonstantinou <[email-masked]> writes:
>
> > I had forgotten, but I'm taking a look today. I'll try to contact
> > Corwin on IRC too.
>
> Thanks!

Here's a patch that will download zst and if it fails it will download
tarball for *every archive* that download_sources() is used on.

Also Corwin let me know if you need something else, but I think this
is what we had discussed in the past.

Regards,
Nikolaos Chatzikonstantinou
From 0336f20ec72a03f0404b6d5597c54ed5bffb9327 Mon Sep 17 00:00:00 2001
From: Nikolaos Chatzikonstantinou <[email-masked]>
Date: Thu, 13 Feb 2025 10:41:11 -0500
Subject: [PATCH] download zst msys2 sources before gzip

admin/nt/dist-build/build-dep-zips.py (gather_source): The previous
version assumed that all source tarballs outside of those specified in
SRC_EXT were gzip compressed. Instead, we prioritize zst compression for
all archives and only if it is not available we attempt to download the
gzip tarball. The SRC_EXT table is not needed so we remove it.
---
 admin/nt/dist-build/build-dep-zips.py | 80 +++------------------------
 1 file changed, 8 insertions(+), 72 deletions(-)

diff --git a/admin/nt/dist-build/build-dep-zips.py b/admin/nt/dist-build/build-dep-zips.py
index af3036eb8e6..353dc9b0e67 100755
--- a/admin/nt/dist-build/build-dep-zips.py
+++ b/admin/nt/dist-build/build-dep-zips.py
@@ -180,69 +180,6 @@ def ntldd_munge(out):
     "mingw-w64-x86_64-libwinpthread":"mingw-w64-x86_64-libwinpthread-git",
     "mingw-w64-x86_64-libtre": "mingw-w64-x86_64-libtre-git",
 }
-SRC_EXT={
-    "mingw-w64-freetype": ".src.tar.zst",
-    "mingw-w64-fribidi": ".src.tar.zst",
-    "mingw-w64-glib2": ".src.tar.zst",
-    "mingw-w64-harfbuzz": ".src.tar.zst",
-    "mingw-w64-libunistring": ".src.tar.zst",
-    "mingw-w64-winpthreads-git": ".src.tar.zst",
-    "mingw-w64-ca-certificates": ".src.tar.zst",
-    "mingw-w64-libxml2": ".src.tar.zst",
-    "mingw-w64-ncurses": ".src.tar.zst",
-    "mingw-w64-openssl": ".src.tar.zst",
-    "mingw-w64-pango": ".src.tar.zst",
-    "mingw-w64-python": ".src.tar.zst",
-    "mingw-w64-sqlite3": ".src.tar.zst",
-    "mingw-w64-xpm-nox": ".src.tar.zst",
-    "mingw-w64-xz": ".src.tar.zst",
-    "mingw-w64-bzip2": ".src.tar.zst",
-    "mingw-w64-cairo": ".src.tar.zst",
-    "mingw-w64-expat": ".src.tar.zst",
-    "mingw-w64-fontconfig":  ".src.tar.zst",
-    "mingw-w64-gdk-pixbuf2":  ".src.tar.zst",
-    "mingw-w64-giflib":  ".src.tar.zst",
-    "mingw-w64-gmp":  ".src.tar.zst",
-    "mingw-w64-gnutls":  ".src.tar.zst",
-    "mingw-w64-graphite2":  ".src.tar.zst",
-    "mingw-w64-jbigkit":  ".src.tar.zst",
-    "mingw-w64-lcms2":  ".src.tar.zst",
-    "mingw-w64-lerc":  ".src.tar.zst",
-    "mingw-w64-libdatrie":  ".src.tar.zst",
-    "mingw-w64-libffi":  ".src.tar.zst",
-    "mingw-w64-libiconv":  ".src.tar.zst",
-    "mingw-w64-libiconv":  ".src.tar.zst",
-    "mingw-w64-libpng":  ".src.tar.zst",
-    "mingw-w64-librsvg": ".src.tar.zst",
-    "mingw-w64-libsystre": ".src.tar.zst",
-    "mingw-w64-libtasn": ".src.tar.zst",
-    "mingw-w64-libthai": ".src.tar.zst",
-    "mingw-w64-libtiff": ".src.tar.zst",
-    "mingw-w64-libtre-git": ".src.tar.zst",
-    "mingw-w64-libwebp": ".src.tar.zst",
-    "mingw-w64-mpdecimal": ".src.tar.zst",
-    "mingw-w64-nettle": ".src.tar.zst",
-    "mingw-w64-p11-kit": ".src.tar.zst",
-    "mingw-w64-pcre": ".src.tar.zst",
-    "mingw-w64-pixman": ".src.tar.zst",
-    "mingw-w64-python-packaging": ".src.tar.zst",
-    "mingw-w64-readline": ".src.tar.zst",
-    "mingw-w64-tcl": ".src.tar.zst",
-    "mingw-w64-termcap": ".src.tar.zst",
-    "mingw-w64-tk": ".src.tar.zst",
-    "mingw-w64-tree-sitter": ".src.tar.zst",
-    "mingw-w64-tzdata": ".src.tar.zst",
-    "mingw-w64-wineditline": ".src.tar.zst",
-    "mingw-w64-zlib": ".src.tar.zst",
-    "mingw-w64-zstd": ".src.tar.zst",
-    "mingw-w64-brotli": ".src.tar.zst",
-    "mingw-w64-gettext": ".src.tar.zst",
-    "mingw-w64-libdeflate": ".src.tar.zst",
-    "mingw-w64-libidn2": ".src.tar.zst",
-    "mingw-w64-libjpeg-turbo": ".src.tar.zst",
-    "mingw-w64-libtasn1": ".src.tar.zst",
-    "mingw-w64-pcre2": ".src.tar.zst",
-}
 
 ## Currently no packages seem to require this!
 ARCH_PKGS=[]
@@ -329,15 +266,14 @@ def gather_source(deps):
         ## Switch names if necessary
         pkg_name = MUNGE_SRC_PKGS.get(pkg_name,pkg_name)
 
-        ## src archive is usually a .tar.gz
-        if pkg_name in SRC_EXT.keys():
-            src_ext = SRC_EXT[pkg_name]
-        else:
-            src_ext = ".src.tar.gz"
-
-        tarball = "{}-{}{}".format(pkg_name,pkg_version,src_ext)
-
-        download_source(tarball)
+        ## We prefer .zst but will use tarballs instead if the .zst is
+        ## not available on the server for download.
+        zstarchive = "{}-{}.src.tar.zst".format(pkg_name,pkg_version)
+        tarball = "{}-{}.src.tar.gz".format(pkg_name,pkg_version)
+        try:
+            download_source(zstarchive)
+        except CalledProcessError:
+            download_source(tarball)
 
     srczip="../emacs-{}-{}deps-mingw-w64-src.zip".format(EMACS_MAJOR_VERSION,DATE)
     tmpzip="{}.tmp".format(srczip)
-- 
2.39.5