#50969: Provide a generic extract (and compress) commands in base --------------------------+---------------------- Reporter: mojca@… | Owner: raimue@… Type: enhancement | Status: new Priority: Normal | Milestone: Component: base | Version: 2.3.4 Resolution: | Keywords: Port: | --------------------------+---------------------- Comment (by rjvbertin@…):
At the moment MacPorts supports fetching distfiles from different mirrors, but it doesn't support extracting different filetypes, so all the "hard work" of extracting the proper file has to be repeated manually in the Portfile.
Shouldn't that read "would have to be repeated manually in the Portfile if an error wasn't raised by the automatic extraction process" and you don't rewrite the extract block yourself? I'd add a nice-to-have feature, at least until "base" provides an integrated way of fetching files in multiple formats: `file_fetch <name> [site]` that would do an on-demand fetch of the named file, looking it up on the `master_sites` or else from the given `site`. The site argument might be redundant if adding unused sites to master_sites has no negative side- effects. As far as I can see that would mostly require refactoring portfetch::fetchfiles from `portfetch.tcl` slightly, and exporting the procedure for extracting a single file. Here's an example from a work-in-progress Portfile of mine where such a function would come in handy: {{{ post-fetch { if {![file exists ${distpath}/${qtwkdistfile}]} { ui_msg "---> Fetching qtwebkit" # find a better way to fetch the archive with some form of optional progress # report that doesn't scroll system -W ${distpath} "wget --progress=bar:force:noscroll --quiet --show-progress https://github.com/qtproject/qtwebkit/archive/${qtwebkit_commit}/qtwebkit- snapshot.tar.gz" # give the file a more evocative name file rename ${distpath}/qtwebkit-snapshot.tar.gz ${distpath}/${qtwkdistfile} } } }}} I don't see how the automatic fetch/extract mechanism could achieve this - it would require syntax to tell fetch to save a given distfile under a different name, and extract to use that new name. I'd still need a manual extract, but that's probably required anyway (and not just because using hfsCompression really makes a difference here): {{{ post-extract { if {![file exists ${distpath}/${qtwkdistfile}]} { ui_error "This shouldn't happen" } elseif {![file exists ${worksrcpath}/qtwebkit/.git] && [file exists ${distpath}/${qtwkdistfile}]} { ui_msg "---> Extracting ${qtwkdistfile}" if {[file exists ${prefix}/bin/bsdtar]} { system -W ${worksrcpath} "bsdtar -x -k --hfsCompression -f ${distpath}/${qtwkdistfile}" } else { system -W ${worksrcpath} "tar -xf ${distpath}/${qtwkdistfile}" } file rename ${worksrcpath}/qtwebkit-${qtwebkit_commit} ${worksrcpath}/qtwebkit file mkdir ${worksrcpath}/qtwebkit/.git } } }}} -- Ticket URL: <https://trac.macports.org/ticket/50969#comment:2> MacPorts <https://www.macports.org/> Ports system for OS X