Handling GNU flags for tar & SOURCE_DATE_EPOCH
Ryan Carsten Schmidt
ryandesign at macports.org
Thu May 8 20:51:23 UTC 2025
On May 1, 2025, at 16:16, Mojca Miklavec wrote:
>
> 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
Report to the developers of that software that they have GNU-tar-specific assumptions in their code and ask them to rewrite it in a portable way that will also work with BSD tar.
More information about the macports-dev
mailing list