Opened 3 years ago

Last modified 3 weeks ago

#64960 new defect

use_7z, use_bzip2, use_lzip, use_lzma, use_tar, use_xz, use_zip cannot be undone

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by:
Priority: Normal Milestone:
Component: base Version: 2.7.2
Keywords: Cc: kurthindenburg (Kurt Hindenburg)
Port:

Description

MacPorts defaults to using .tar.gz distfiles. This can be changed by setting use_7z, use_bzip2, use_lzip, use_lzma, use_tar, use_xz, or use_zip to yes (which change both extract.suffix and the extraction commands and arguments) but once that's done, there's no way to undo it. Presumably when these were designed it was assumed that there would be no reason for a Portfile to set one of these and then set another of these; the Portfile should just set the single option that it needs.

However, a portgroup may wish to use one of these as a default, as indeed the gitlab-1.0 portgroup currently does by setting use_bzip2 yes the moment that gitlab.setup is called. This is terrible because it means that once I run gitlab.setup I'm required to download a bzip2 file, even if I actually want to download a different kind of file from a different download location. Neither setting e.g. use_xz yes before calling gitlab.setup nor setting it afterward nor setting it in both places works. It effectively means that if I want to download a non-bzip2 file I have to forgo the benefits of using the gitlab portgroup entirely or manually fix up the extraction commands and arguments.

Ultimately (#50969) I would like for these use_ options to become wrappers that do nothing more than set extract.suffix, and eventually be retired entirely, and have MacPorts base be able to extract any distfile by inferring the commands to use based on what type of file it is. But until then, maybe there is a way to improve the use_ options so that they can be fully undone if needed.

Change History (3)

comment:1 Changed 16 months ago by kurthindenburg (Kurt Hindenburg)

Cc: kurthindenburg added

To be clear, the fetch part works. It is the extract that fails.

It seems the easiest way to fix this is just to remove all the "use_" from portextract.tcl and just do a switch on extract.suffix.

In my quick testing, it seems to work.

comment:2 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

Filename suffixes are sometimes wrong so I would not favor basing extraction decisions on the filename suffix. A format-agnostic extractor should base its decision on the file's magic number (i.e. using file or libmagic to identify it). It is also important that such an extractor have the ability to do partial extractions. Ports currently do partial extractions by modifying extract.post_args with arguments that are specific to whatever extractor is being used. (The php port is an example of this.) Any implementation of #50969 would have to not break this feature used by existing ports.

As I said, since those are bigger issues to consider, this ticket is about the smaller task of allowing the use_* options to be undone once set. If #50969 gets implemented first, then this ticket can be closed.

comment:3 Changed 3 weeks ago by ryandesign (Ryan Carsten Schmidt)

The difficulty with a format-agnostic extractor is that we need to know ahead of time what extract dependencies, if any, to add, since dependencies get installed before the port's phases get run. We need to know what dependencies to add before the file that would tell us what format it is has been downloaded.

Note: See TracTickets for help on using tickets.