Page MenuHomeFreeBSD

Makefile.inc1: Conditionalize some package related variables
ClosedPublic

Authored by jhb on Mar 7 2025, 4:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 16, 11:34 AM
Unknown Object (File)
Sun, Apr 6, 9:47 AM
Unknown Object (File)
Thu, Mar 27, 4:40 AM
Unknown Object (File)
Mar 25 2025, 1:37 PM
Unknown Object (File)
Mar 22 2025, 3:05 AM
Unknown Object (File)
Mar 20 2025, 5:04 AM
Unknown Object (File)
Mar 13 2025, 7:14 AM
Unknown Object (File)
Mar 10 2025, 11:23 PM
Subscribers

Details

Summary

In particular, don't invoke git to compute SOURCE_DATE_EPOCH for
unrelated targets like check-old or delete-old. If the git invocation
fails (e.g. when using a git worktree mounted over NFS) it can
generate a lot of irrelevant warning spam.

Fixes: 8a3537aaf7c1 ("Makefile.inc1: Make package timestamps reproducible by default")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Mar 7 2025, 4:55 PM

On a NFS-mounted git worktree without this change:

root@head:/usr/src # make check-old
make[1]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[1]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
>>> Checking for old files
make[2]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[2]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
make[3]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[3]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
>>> Checking for old libraries
make[2]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[2]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
make[3]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[3]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
/usr/lib32/libdevinfo.so.6
/usr/lib/debug/usr/lib32/libdevinfo.so.6.debug
>>> Checking for old directories
make[2]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[2]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
make[3]: warning: /usr/src/: Read-only file system.
fatal: not a git repository: /usr/home/john/work/git/freebsd/.git/worktrees/main
make[3]: "/usr/src/Makefile.inc1" line 601: warning: Command "/usr/local/bin/git -C /usr/src show -s --format=%ct HEAD" exited with status 128
To remove old files and directories run 'make delete-old'.
To remove old libraries run 'make delete-old-libs'.

After this change:

root@head:/usr/src # make check-old
make[1]: warning: /usr/src/: Read-only file system.
>>> Checking for old files
make[2]: warning: /usr/src/: Read-only file system.
make[3]: warning: /usr/src/: Read-only file system.
>>> Checking for old libraries
make[2]: warning: /usr/src/: Read-only file system.
make[3]: warning: /usr/src/: Read-only file system.
/usr/lib32/libdevinfo.so.6
/usr/lib/debug/usr/lib32/libdevinfo.so.6.debug
>>> Checking for old directories
make[2]: warning: /usr/src/: Read-only file system.
make[3]: warning: /usr/src/: Read-only file system.
To remove old files and directories run 'make delete-old'.
To remove old libraries run 'make delete-old-libs'.

Note that this also shows how many times we were forking to exec git which is overhead it might be nice to avoid when not needed for other targets in general.

The bogus EROFS warnings are still annoying (and have been around for a few years now). I think @jrtc27 might have some WIP changes to quiet those.

Makes sense, thanks.

My end goal is to store a timestamp in some file and use that for package timestamps -- propose using vers.c in D48718.

This revision is now accepted and ready to land.Mar 7 2025, 5:28 PM

@emaste would you be able to test that this works correctly for building base packages?

I won't be able to try it out until after the weekend, but something like make -V SOURCE_DATE_EPOCH -f Makefile.inc1 TARGET=amd64 TARGET_ARCH=amd64 packages should confirm it