portextract: add file_extract command#402
portextract: add file_extract command#402herbygillot wants to merge 1 commit intomacports:masterfrom
Conversation
|
Thank you! Is this intended to replace the use_* options for all distfiles or be used in addition to them for supplemental distfiles? Who calls How can a port override the extraction method for distfiles with unknown extensions (like .jar which is a .zip file or .crate which is a .tar.gz file) or whose extension is wrong for the type of data it contains (yes, we've encountered that)? How can a port extract individual files from an archive, rather than the whole archive? curl-ca-bundle is small an example port that does this; php is a big one. Look for |
You are very welcome. We can change this PR to go in any direction that folks prefer and agree upon. As of right now, the As of right now, the intention in the future would be to continue keeping the
Right now, nothing calls
The command doesn't support this right now, but if that's the desire, then how do you think the command should look like? As it is right now, each additional argument to a) -or b) ? |
fa7cc83 to
964a12d
Compare
Add a new file_extract command that extracts archive files with automatic format detection from file suffixes. Supports gzip, bzip2, xz, lzma, lzip, zstd, compress, tar, zip, 7z, and dmg. Accepts -dirname to override the extraction directory and -type to override suffix-based detection. Relative filenames are resolved in filespath then distpath, and distfile tags are stripped before lookup. This is intended to eventually replace the use_* extraction switches internally, while the use_* options remain available to Portfile authors. Includes unit and integration tests, and portfile(7) man page documentation. Fixes: https://trac.macports.org/ticket/50969 Co-Authored-By: Claude Opus 4.6 <[email protected]>
964a12d to
e2b0ffc
Compare
|
One notable change I've made for this command: no matter where it is specified, it will only run during the The option exists to change it into an on-demand "instant" command that extracts the moment it's parsed, but it seems to me like that could cause issues. |
|
On master I've made some changes to allow automatic extraction of multiple distfiles out of the box when they use different archive formats. As part of that I refactored a bit to make the filename suffix the primary source of information about how each file should be extracted, but also added a way to override this choice to allow correctly handling archives that are named incorrectly or just unusually. This is basically Rainer's idea from the ML post linked in #50969. I'm not quite sure where this leaves the original idea of the ticket. The main motivation for the generic extract command seems to have been handling mixed file types, but maybe there are other situations where it's useful? |
Is it necessary to do everything via "command line" options, or would it be better to use dedicated
This is one where a One thought that crosses my mind: some form of sandboxing - overridable if an direct-callable version ( |
Add a new file_extract command that extracts archive files with automatic format detection from file suffixes. Supports gzip, bzip2, xz, lzma, lzip, zstd, compress, tar, zip, 7z, and dmg. Accepts -dirname to override the extraction directory and -type to override suffix-based detection. Relative filenames are resolved in filespath then distpath, and distfile tags are stripped before lookup.
This is intended to eventually replace the use_* extraction switches internally, while the use_* options remain available to Portfile authors.
Includes unit and integration tests, and portfile(7) man page documentation.
Fixes: https://trac.macports.org/ticket/50969