bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reproducible built files


From: Simon Josefsson
Subject: Re: reproducible built files
Date: Sat, 28 Dec 2024 11:54:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Bruno Haible <bruno@clisp.org> writes:

> Simon Josefsson wrote:
>> I'm not sure I follow what you actually plan to do wrt multiple files
>> X1, X2, ... Xn.  Can you give some code example?  Maybe I understand
>> that better...
>
> Roughly like this (untested).

Oh, that is neat!  But is there any advantage compared to simply using a
global mtime for all files in the tarball?  Is there any useful use of
mtime except for dependency tracking triggering 'make' rebuilds?  Using
the same mtime for all files in a tarball is a lot easier than curate
another mapping of source-to-build dependency list, which seems needed
to figure out what is the most "relevant" mtime for each individual
generated file inside a tarball.

/Simon

> # func_file_vmtime returns the virtual modification time of a file,
> # as a number of seconds since the epoch. (*)
> func_file_vmtime ()
> {
>   if test -n "$(git ls-files "$1")" && git diff --quiet HEAD "$1"; then
>     # file is under version control and is unmodified.
>     git log -1 --format=%ct "$1"
>   else
>     # file has been created or modified by the user.
>     stat --format=%Y "$1"
>   fi
> }
>
> for file in X1 ... Xn; do
>   func_file_vmtime "$file"
> done | LC_ALL=C sort -n | tail -n 1
>
> (*) To compensate for fractional seconds, 1 second may need to be added
>     at the end.
>
>
> Examples:
>   - Y = po/hello.pot, {X1, ..., Xn} = { po/POTFILES.in, src/hello.c }
>   - Y = lib/parse-datetime.c, {X1, ..., Xn} = { lib/parse-datetime.y }
>   - Y = package.tar, {X1, ..., Xn} = $(find package -type f)
>
> Bruno
>
>
>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]