New tool: stampdalf - A filesystem timestamp preservation tool
Luca Di Maio
luca.dimaio1 at gmail.com
Thu Dec 18 17:28:05 UTC 2025
On Thu, 2025-12-18 at 11:57 -0500, David A. Wheeler wrote:
>
>
> > On Dec 18, 2025, at 2:31 AM, Luca Di Maio <luca.dimaio1 at gmail.com>
> > wrote:
> >
> > Hi all,
> >
> > I would like to introduce a new tool I have developed that may be
> > of
> > interest to this community: stampdalf.
> >
> > Repository: https://github.com/89luca89/stampdalf
> >
> > stampdalf is a simple command-line utility written in Go that wraps
> > arbitrary commands and ensures filesystem timestamp
> > reproducibility.
> >
> > The tool addresses a common challenge in reproducible builds:
> > commands
> > that modify files often update their access and modification times
> > as a
> > side effect, even when the actual content remains unchanged or is
> > modified in a reproducible way (for example idempotent commands).
> > This
> > can lead to non-reproducible build artifacts.
> >
> > How it works:
> >
> > - Before executing the wrapped command, stampdalf scans the target
> > directory tree and records all file timestamps (atime/mtime)
> > - The specified command is then executed normally.
> > - After command completion, stampdalf restores the original
> > timestamps
> > for all pre-existing files. Any newly created files are set to Unix
> > epoch by default, or to SOURCE_DATE_EPOCH if the environment
> > variable
> > is set.
>
> Does it (1) *unilaterally* reset all original timestamps, or (2) only
> reset timestamps
> of pre-existing files that have the *same* contents (e.g., same
> length & cryptographic hash)?
> It's the option #2 that I want.
>
> Thanks!
>
> --- David A. Wheeler
It resets timestamps of files and directories that are changed,
for example:
echo hello > rootfs/etc/hosts-new
this is idempotent and reproducible, but will result in a new file,
that is set to SDE (or 0 if unspecified).
mkdir -p rootfs/etc/foo
is also idempotent and reproducible and will also change the timestamps
of rootfs/etc, so rootfs/etc/foo is set to SDE (or 0 if unspecified)
while rootfs/etc resets to the original timestamp recorded at the
beginning.
sed -i 's/foo/bar/g' /etc/hosts
will change the timestamp of that file, and it will be reset to the
original value recorded before the command execution.
*new* files directories and timestamps are set to 0 or SDE
*existing* ones are reset to the original value.
In case of (2) you would want a modified file to act like a new one?
L.
More information about the rb-general
mailing list