multiple distfiles from multiple sources and with multiple compression types

Rainer Müller raimue at
Thu Mar 31 09:35:46 PDT 2016

On 2016-03-31 03:16, Ryan Schmidt wrote:
> libmagic should be used to determine the compression format; filename extension should not be used.

Was there ever a case with a .tar.gz that was actually compressed with
bzip2 or something like this? The current approach of 'use_* yes' also
assumes ${extract.suffix} and ${extract.cmd} to match...

Even then, ports could still overwrite the extract phase. We could also
still allow to set an explicit extract.cmd to overwrite the guessed
extract command.

I do not want to complicate this more than needed.

Using magic bytes would even result in wrong results in some cases. For
example for scapy, the distfile is intentionally a polyglot. It is both
a valid shell script and a zip file:

$ file -b /opt/local/var/macports/distfiles/scapy/
POSIX shell script executable (binary data)


PS: For the curious, I found the scapy example with the following shell

find /opt/local/var/macports/distfiles -type f -exec file -i {} \; \
|perl -nle 'if (/^[a-zA-Z0-9.\/-]+\.(.*): .*\/x-(.*);/) {
  ($m = $2) =~ s/^gzip$/gz/; $m =~ s/^bzip2$/bz2/;
  if ($1 ne $2) { print $_; }

More information about the macports-dev mailing list