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

Yury Khrustalev yury.khrustalev@arm.com
Thu Nov 27 11:01:45 GMT 2025


On Wed, Nov 26, 2025 at 12:14:01PM -0500, Carlos O'Donell wrote:
> 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.

It looks like the --replace-sources behaviour should be the default: if
you happen to run the 'checkout' step, it is likely that you want your
sources to be fixed-up to the expected state.

If the main use case is to support repeatedly running 'checkout' to pull
updates in already existing working copy, then Git URL should just be
ignored because we already have some state and just want to pull updates.
We should have 'update-sources' action for this case. I think separation of
concerns would help here.

> 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

Thanks

> 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.

OK, I'm happy to include this change, however...

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

...As I said, I'm struggling to test all the scenarios supported by the
script (e.g. anything related to 'bot'), so I would need someone else
to verify that the updated script works.

Kind regards,
Yury



More information about the Libc-alpha mailing list