Just wondering what everyone would think of applying this patch? It enables a runtime test during activation to see if (1) bsdtar is in path and (2) if it supports the --hfsCompression option. (The version from libarchive does.)
The --hfsCompression does what you would expect: applies compression to the extracted files. The bsdtar implementation of this automatically becomes a no-op [1] on filesystems that do not support compression, as well as checking to make sure the compression is beneficial [2] and bailing (decompressing) otherwise. As such, we can just pass the flag, and if it can't be used, ~ no harm done. For systems where it can be used, however, large savings can be realized (3:1) on some of the largest (e.g. compilers w/ include files) packages. With more macs being sold with non-user-upgradable storage, this seems like a win. Since this is a run-time check, similar to the lbzip2 check a few lines later, it won't get tripped up on a 'port upgrade libarchive' action, for example. (By the same token, libarchive itself will never be HFS+ compressed, unless the user explicitly installs yet another modern-enough bsdtar in path. Direction could be given to users to install libarchive before activating ports if space is a concern. (Or perhaps we have a 'macports-extras' port group that installs libarchive and lbzip2; two things that really are nice to have installed, and improve the performance of MacPorts. We could also prompt during 'port upgrade' actions if it is not installed, perhaps with a persistent "don't bother me again" y/n/N option...) -- Eric [1] https://github.com/libarchive/libarchive/blob/c10875db78 b04fd730bb08245b7032baba906815/libarchive/archive_write_disk_posix.c#L710 [2] https://github.com/libarchive/libarchive/blob/c10875db78 b04fd730bb08245b7032baba906815/libarchive/archive_write_disk_posix.c#L1326 diff --git a/src/registry2.0/portimage.tcl b/src/registry2.0/portimage.tcl index 72dcdfd3..bdab6f8f 100644 --- a/src/registry2.0/portimage.tcl +++ b/src/registry2.0/portimage.tcl @@ -348,9 +348,18 @@ proc extract_archive_to_tmpdir {location} { t(ar|bz|lz|xz|gz) { set tar "tar" if {[catch {set tar [macports::findBinary $tar ${macports::autoconf::tar_path}]} errmsg] == 0} { - ui_debug "Using $tar" - set unarchive.cmd "$tar" - set unarchive.pre_args {-xvpf} + # Opportunistic HFS compression. bsdtar will automatically + # ignore if on non-HFS filesystem. + if {![catch {macports::binaryInPath bsdtar}] && + ![catch {exec bsdtar -x --hfsCompression < /dev/null >& /dev/null}]} { + ui_debug "Using bsdtar with HFS+ compression (if valid)" + set unarchive.cmd "bsdtar" + set unarchive.pre_args {-xvp --hfsCompression -f} + } else { + ui_debug "Using $tar" + set unarchive.cmd "$tar" + set unarchive.pre_args {-xvpf} + } if {[regexp {z2?$} ${unarchive.type}]} { set unarchive.args {-} if {[regexp {bz2?$} ${unarchive.type}]} {