Handling GNU flags for tar & SOURCE_DATE_EPOCH

Mojca Miklavec mojca at macports.org
Thu May 1 21:16:56 UTC 2025


Hi,

I ran into software doing the following:

set( TARFLAGS cfz )
if( DEFINED ENV{SOURCE_DATE_EPOCH} )
    set( TARFLAGS --sort=name --mtime=@$ENV{SOURCE_DATE_EPOCH}
--clamp-mtime --owner=0 --group=0 --numeric-owner
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
-czf )
endif()

Basically: if SOURCE_DATE_EPOCH is defined, run
    tar --sort=name --mtime=...
which fails on macOS because --sort, --mtime etc. are all GNU extensions.

What's the best way to handle this?

1.) Can the code be rewritten in such a way that it will work with
native tar, and yet result in reproducible builds?

2.) If that is not possible, I guess that using gnu tar as build
dependency is the best bet?

3.) Can SOURCE_DATE_EPOCH be easily unset during configure/build step?

Thank you,
    Mojca


More information about the macports-dev mailing list