[PATCH v2 3/3] scripts: Support custom Git URLs in build-many-glibcs.py

Carlos O'Donell carlos@redhat.com
Wed Nov 26 17:14:01 GMT 2025


On 11/26/25 8:39 AM, Joseph Myers wrote:
> On Wed, 26 Nov 2025, Yury Khrustalev wrote:
> 
>> On Wed, Nov 26, 2025 at 01:18:48PM +0000, Joseph Myers wrote:
>>> On Wed, 26 Nov 2025, Yury Khrustalev wrote:
>>>
>>>> If there is a need to do a clean checkout of sources, then I would just
>>>> remove the folder and re-run the 'checkout' step again. Why do we need
>>>> --replace-sources? It's rhetorical, since we already have it, we have
>>>> to deal with the consequences of maintaining it, but I think it was a
>>>> mistake to add it.
>>>
>>> A bot is supposed to keep running automatically, even when the default
>>> versions / branches change.
>>
>> Default is not changed in this version of the patch.
> 
> The point is that the default versions *do* change over time, as new
> versions of the components are released, and so --replace-sources is key
> functionality to keep using the script, both with bots and with long-lived
> checkouts, as such changes occur.
> 

Example:

$ GLIBC_GIT_MIRROR=https://gitlab.com/gnutools/glibc.git ~/src/glibc-review/scripts/build-many-glibcs.py . checkout
error: origin url has changed from https://sourceware.org/git/glibc.git to https://gitlab.com/gnutools/glibc.git, use --replace-sources to check out again

$ GLIBC_GIT_MIRROR=https://gitlab.com/gnutools/glibc.git ~/src/glibc-review/scripts/build-many-glibcs.py --replace-sources . checkout

$ cd src/glibc
$ git remote get-url origin
https://gitlab.com/gnutools/glibc.git
$ cd ../../

$ ~/src/glibc-review/scripts/build-many-glibcs.py . checkout
error: origin url has changed from https://gitlab.com/gnutools/glibc.git to https://sourceware.org/git/glibc.git, use --replace-sources to check out again

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 5a02c4bf73..2aaeca71c3 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -971,8 +971,20 @@ class Context(object):
              subprocess.run(['git', 'remote', 'prune', 'origin'],
                             cwd=self.component_srcdir(component), check=True)
              if self.replace_sources:
+                subprocess.run(['git', 'remote', 'set-url', 'origin', git_url],
+                               cwd=self.component_srcdir(component), check=True)
                  subprocess.run(['git', 'clean', '-dxfq'],
                                 cwd=self.component_srcdir(component), check=True)
+            else:
+                r = subprocess.run(['git', 'remote', 'get-url', 'origin'],
+                                   cwd=self.component_srcdir(component),
+                                   stdout=subprocess.PIPE,
+                                   check=True, universal_newlines=True).stdout
+                if r.rstrip() != git_url:
+                    print('error: origin url has changed from %s to %s, '
+                          'use --replace-sources to check out again' %
+                          (r.rstrip(), git_url))
+                    exit(1)
              subprocess.run(['git', 'pull', '-q'],
                             cwd=self.component_srcdir(component), check=True)
          else:
---

This works for me.

I think this is all you would need to integrate your last changes.

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list