bug-gnulib
[Top][All Lists]
Advanced

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

Re: reproducible built files


From: Bruno Haible
Subject: Re: reproducible built files
Date: Sat, 28 Dec 2024 11:46:09 +0100

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

# 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






reply via email to

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