[PATCH v2] contrib: Allow overriding download_prerequisites base URL

Даниил Гусев <[email protected]> Sat, 1 Aug 2026 22:57:04 +0300
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
From d58fc7889f5d2e8b6f12117e60181efeb7be1a40 Mon Sep 17 00:00:00 2001
From: Daniil-Gusev <[email protected]>
Date: Sat, 1 Aug 2026 22:50:41 +0300
Subject: [PATCH v2] contrib: Allow overriding download_prerequisites base URL

Add support for GCC_PREREQUISITES_BASE_URL, so packages can be
fetched from a local mirror instead of gcc.gnu.org every time.

contrib/ChangeLog:

	* download_prerequisites (base_url): Allow overriding via the
	GCC_PREREQUISITES_BASE_URL environment variable.  Document it
	in --help output.
---
v2:
* accept the URL with or without a trailing slash (strip, then re-add)
* shortened --help wording per your suggestion

Not sure if you meant literally showing the current value in brackets,
or just marking it optional - went with the former. Also wrapped it to
a second line to stay under 80 columns.

 contrib/download_prerequisites | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
index 2e6693a2aa6..68a384b96be 100755
--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -33,7 +33,8 @@ mpc='mpc-1.3.1.tar.gz'
 isl='isl-0.24.tar.bz2'
 gettext='gettext-1.0.tar.gz'
 
-base_url='https://gcc.gnu.org/pub/gcc/infrastructure/'
+base_url="${GCC_PREREQUISITES_BASE_URL:-https://gcc.gnu.org/pub/gcc/infrastructure/}"
+base_url="${base_url%/}/"
 
 echo_archives() {
     echo "${gettext}"
@@ -86,6 +87,11 @@ The following options are available:
  --only-gettext   inhibit downloading any package but gettext
  --help           show this text and exit
  --version        show version information and exit
+
+Environment variables:
+
+ GCC_PREREQUISITES_BASE_URL  URL to download from
+  [${base_url}]
 "
 
 versiontext="${program} ${version}
-- 
2.55.0