[PATCH v2 3/3] scripts: Support custom Git URLs in build-many-glibcs.py
Carlos O'Donell
carlos@redhat.com
Mon Nov 24 17:19:31 GMT 2025
On 11/19/25 7:54 AM, Yury Khrustalev wrote:
> Use environment variables to provide mirror URLs to checkout
> sources from Git. Each component has a corresponding env var
> that will be used if it's present: <component>_GIT_MIRROR.
Arjun's comments stand.
Even with --replace-sources the URL is not updated, and so this change
might in the worst case checkout code from a repo you didn't intend to
reference.
Arjun provided a patch in the comment.
Structurally the rest of the changes are OK, but it needs the origin
url update code to be correct.
> ---
> scripts/build-many-glibcs.py | 29 +++++++++++++++++++++++------
> 1 file changed, 23 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index ddc47b243e..5a02c4bf73 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -104,6 +104,23 @@ except:
>
> subprocess.run = _run
>
> +def get_git_url(component):
> + """Return Git URL for the given component. Allow overrides via env var."""
> + git_urls = {
> + 'binutils': 'https://sourceware.org/git/binutils-gdb.git',
> + 'glibc': 'https://sourceware.org/git/glibc.git',
> + 'gcc': 'https://gcc.gnu.org/git/gcc.git',
> + 'gnumach': 'git://git.savannah.gnu.org/hurd/gnumach.git',
> + 'mig': 'git://git.savannah.gnu.org/hurd/mig.git',
> + 'hurd': 'git://git.savannah.gnu.org/hurd/hurd.git',
> + }
> + env_var = '%s_GIT_MIRROR' % component.upper()
> + if env_var in os.environ:
> + return os.environ[env_var]
> + if component in git_urls:
> + return git_urls[component]
> + else:
> + raise RuntimeError('unknown component')
>
> class Context(object):
> """The global state associated with builds in a given directory."""
> @@ -901,7 +918,7 @@ class Context(object):
> """Check out the given version of the given component from version
> control. Return a revision identifier."""
> if component == 'binutils':
> - git_url = 'https://sourceware.org/git/binutils-gdb.git'
> + git_url = get_git_url(component)
> if version == 'mainline':
> git_branch = 'master'
> else:
> @@ -915,7 +932,7 @@ class Context(object):
> branch = 'releases/gcc-%s' % version
> return self.gcc_checkout(branch, update)
> elif component == 'glibc':
> - git_url = 'https://sourceware.org/git/glibc.git'
> + git_url = get_git_url(component)
> if version == 'mainline':
> git_branch = 'master'
> else:
> @@ -924,21 +941,21 @@ class Context(object):
> self.fix_glibc_timestamps()
> return r
> elif component == 'gnumach':
> - git_url = 'git://git.savannah.gnu.org/hurd/gnumach.git'
> + git_url = get_git_url(component)
> git_branch = 'master'
> r = self.git_checkout(component, git_url, git_branch, update)
> subprocess.run(['autoreconf', '-i'],
> cwd=self.component_srcdir(component), check=True)
> return r
> elif component == 'mig':
> - git_url = 'git://git.savannah.gnu.org/hurd/mig.git'
> + git_url = get_git_url(component)
> git_branch = 'master'
> r = self.git_checkout(component, git_url, git_branch, update)
> subprocess.run(['autoreconf', '-i'],
> cwd=self.component_srcdir(component), check=True)
> return r
> elif component == 'hurd':
> - git_url = 'git://git.savannah.gnu.org/hurd/hurd.git'
> + git_url = get_git_url(component)
> git_branch = 'master'
> r = self.git_checkout(component, git_url, git_branch, update)
> subprocess.run(['autoconf'],
> @@ -1004,7 +1021,7 @@ class Context(object):
> shutil.rmtree(self.component_srcdir('gcc'))
> update = False
> if not update:
> - self.git_checkout('gcc', 'https://gcc.gnu.org/git/gcc.git',
> + self.git_checkout('gcc', get_git_url('gcc'),
> branch, update)
> subprocess.run(['contrib/gcc_update', '--silent'],
> cwd=self.component_srcdir('gcc'), check=True)
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list