Opened 14 years ago

Closed 13 years ago

#28084 closed defect (fixed)

Use of composite version specs should be avoided

Reported by: ken@… Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts 2.0.0
Component: base Version: 1.9.2
Keywords: registry version Cc:
Port:

Description

If a port has an underscore ('_') in its version, then any attempt to install it will result in a registry error:

Error: Target org.macports.activate returned: Registry error: No port of <port> installed.

Examples include aspell-dict-it, whose version is 2.2_20050523-0, and aspell-dict-pl, whose version is 6.0_20061121-0.

I have worked around this problem by editing the Portfile to a) manually substitute the original value of version into the distname, and b) changing the underscore in the version to a dash ('-').

I suspect that something in the registry lookup is scanning for the "_${revision}" that's appended to the port version, but it is scanning forward for the underscore starting at the beginning of the string instead of scanning backward from the end.

Change History (12)

comment:1 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Component: portsbase

comment:2 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Are you using the flat registry or the sql registry? (See portdbformat in macports.conf)

comment:3 in reply to:  2 Changed 14 years ago by ken@…

Replying to ryandesign@…:

Are you using the flat registry or the sql registry? (See portdbformat in macports.conf)

The SQL registry.

comment:4 Changed 14 years ago by jmroot (Joshua Root)

Works for me (I maintain iozone, for example). This sounds a lot like #23966. Are you sure you're using the 1.9.2 release and not some old pre-1.9 trunk version?

comment:5 in reply to:  4 Changed 14 years ago by ken@…

Replying to jmr@…:

Works for me (I maintain iozone, for example). This sounds a lot like #23966. Are you sure you're using the 1.9.2 release and not some old pre-1.9 trunk version?

I did a "sudo port selfupdate" immediately before encountering this issue. This is from just now:

$ port version
Version: 1.9.2

Would it help if I revert my edit to the Portfiles and collect a log?

comment:6 Changed 14 years ago by jmroot (Joshua Root)

Actually I do see this for the ports you mention, but not for all ports with an underscore in the version.

comment:7 Changed 14 years ago by jmroot (Joshua Root)

Using a full version spec when activating or deactivating works, so something is not figuring out the version from the registry correctly when no version is given.

comment:8 in reply to:  6 Changed 14 years ago by ken@…

Replying to jmr@…:

Actually I do see this for the ports you mention, but not for all ports with an underscore in the version.

I believe I have identified the issue. It's the underscore and the dash in "2.2_20050523-0". iozone's version is 3_373, which has no dash.

Now, look at proc decode_spec (/opt/local/share/macports/Tcl/registry2.0/registry_util.tcl:55):

proc decode_spec {specifier version revision variants} {
    upvar 1 $version ver $revision rev $variants var
    return [regexp {^([^+]+?)(_(\d+)(([-+][^-+]+)*))?$} $specifier - ver - rev v
ar]
}

Experimenting interactively with that regexp:

$ tclsh
% echo [regexp {^([^+]+?)(_(\d+)(([-+][^-+]+)*))?$} "2.2_20050523-0_0" - ver - rev var]
1
% echo $ver
2.2
% echo $rev
20050523
% echo $var
-0_0
% echo [regexp {^([^+]+?)(_(\d+)(([-+][^-+]+)*))?$} "3_373_0" - ver - rev var]
1
% echo $ver
3_373
% echo $rev
0
% echo $var

%

comment:9 Changed 14 years ago by jmroot (Joshua Root)

simul-posted with the above :-)

So, this is interpreting the version spec 2.2_20050523-0_0 obtained from the registry as version 2.2, revision 20050523, and variants -0_0. I believe this is a genuine ambiguity in the syntax. We can probably make it better by requiring variant names to have at least one letter, but the possibility of misinterpretation remains for ports with letters in their version.

comment:10 Changed 14 years ago by jmroot (Joshua Root)

Summary: Registry error for ports with underscore ('_') in versionUse of composite version specs should be avoided

So basically we want to be passing around separate version,revision,variants values whenever possible. The use of composite versions is a holdover from the flat registry, which ironically avoided this problem by actually storing the values this way. (So it would only run into trouble if there actually were two versions of a port installed at the same time where a different possible interpretation was correct for each.)

comment:11 Changed 14 years ago by jmroot (Joshua Root)

Added at-least-one-letter requirement to variant name parsing in r75336.

comment:12 Changed 13 years ago by jmroot (Joshua Root)

Milestone: MacPorts 2.0.0
Resolution: fixed
Status: newclosed

This should be taken care of on the registry side by r79167. The front end could potentially need some more work, since it accepts composite version specs as user input, but we'll see how this goes.

Note: See TracTickets for help on using tickets.