Subject: Re: bug#74413: [PATCH] Allow to store and read repository information of VCS builds

From: Björn Bidar <[email-masked]>
Date: Mon, 18 Nov 2024 23:48:38 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Björn Bidar <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Mon, 18 Nov 2024 21:31:43 +0200
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> >> From: Björn Bidar <[email-masked]>
>> >> Cc: Stefan Kangas <[email-masked]>,  [email-masked],
>> >>   [email-masked]
>> >> Date: Mon, 18 Nov 2024 18:54:26 +0200
>> >> 
>> >> Eli Zaretskii <[email-masked]> writes:
>> >> 
>> >> > This is already available if Emacs is built in a Git repository, and
>> >> > the information is stored in the dumped Emacs.  So what is gained by
>> >> > also recording the repository version on a disk file external to
>> >> > Emacs?
>> >> 
>> >> The information is only stored if the worker already had git installed
>> >> and checked out the sources with git inside the worker.
>> >> Also the function currently fails unless the system the user uses also happens to
>> >> have git installed and the sources if the are installed also contain the
>> >> VCS metadata.
>> >> Storing the VCS metadata in the sources doesn't happen usually as it
>> >> increases the size of a good chunk. In my case e.g. from 188MB to 788MB.
>> >> Why not have the same feature for other platforms too?
>> >
>> > Sorry, I don't understand this explanation; I'm probably missing
>> > something.
>> >
>> > The feature you propose requires to build Emacs inside a Git
>> > repository, is that correct?  Because otherwise "git rev-parse" will
>> > not work, right?  If that is correct, then building Emacs inside a Git
>> > repository already calls this Git command and records the result in 2
>> > Emacs Lisp variables.
>> >
>> > So why do you also want to record the same
>> > information on a file?  What kind of scenario do you have in mind in
>> > which building Emacs with its current code will not record the branch
>> > and the revision, but your additions to Makefile will record that?
>> 
>> The additions to the make file are so that if the worker contains git
>> the file can be generated so that the related functions will still work
>> after the built or to generate them prior the built. The latter probably
>> makes less sense except to maybe avoid having autotools in the built
>> dependency chain.
>> 
>> If the Make recipe isn't used to generate the version file it can be
>> generated by the CI, e.g. in my case I take the information from the
>> open build source service. For others such as Fedora the sources can be
>> retrieved in a similar manner.
>> 
>> The file can be added before the built starts and package  so that the pdump
>> will contain the repository information and the VCS function will also
>> work afterwards. 
>
> I still don't think I understand, sorry.  Do you mean the file is
> generated from a Git repository, but then Emacs is somehow built from
> a directory that is not under Git?

The file can be generated from the git repository outside of the Emacs
builder.

E.g. in my case the obs source service store's the git revision used in
the service 

In my case the file looks like this:
name: emacs
version: 31.0.50.9794.eee0ed8442a
mtime: 1731883844
commit: eee0ed8442aa78320a3e578ab290df145fb49624

sed -n -e 's/^commit: \(.*\)/\1/p' emacs.obsinfo > etc/version

> But if this is the scenario, how can you be sure the produced Emacs binary was made from that revision
> on that branch?  This is only guaranteed if you actually build from
> Git when you record this information.
>
> What am I missing?

If the source is generated by the CI it can also store this information
in the build source which then can be extracted from the ci metadata to
the Emacs sources on the builder.

I can be sure that Emacs was built from that revision as much as I can
trust the CI to use the sources I told it to use. If I can't trust one,
I can't trust the other.