Opened 14 years ago

Last modified 9 years ago

#28640 new enhancement

port lint should warn when *-append should be used

Reported by: l2g@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.9.2
Keywords: Cc: ryandesign (Ryan Carsten Schmidt), kurthindenburg (Kurt Hindenburg)
Port:

Description

It would be nice if the lint command could warn when *-append should be used but isn't being used. This is mainly important for PortGroups, where an accidental setting in a portfile like depends_lib instead of depends_lib-append may wipe out defaults already set in the PortGroup (as recently pointed out to me by Brad "pixilla" Giesbrecht).

Attachments (1)

portlint2.diff (2.5 KB) - added by kurthindenburg (Kurt Hindenburg) 10 years ago.

Download all attachments as: .zip

Change History (5)

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

Cc: ryandesign@… added

One solution would be to suggest that users always use depends_*-append to add to dependencies, and never set depends_* -- for all ports. In the majority of ports, which don't use portgroups, this wouldn't make a difference, and would result in lots of lint warnings that people would get annoyed by.

This could be refined to only print this warning if the port uses a portgroup. This would cut down on the unnecessary warnings, but not eliminate them; many portgroups don't add dependencies (xcode, xcodeversion, archcheck), or at least, don't add to all of the dependency types.

To "do it right", lint would have to notice the use of a portgroup, evaluate it to see what dependencies it is declaring, and only print its warning if the port sets a dependency type the portgroup is already setting.

A further case to consider is "use_autoconf yes" and "use_autoreconf yes". These appends to depends_build; if the port sets depends_build on a subsequent line, it overwrites the needed autoconf dependencies. Ports must therefore either use depends_build-append in these cases, or set their depends_build on a line before they request the use of autoconf or autoreconf.

comment:2 Changed 10 years ago by kurthindenburg (Kurt Hindenburg)

Cc: khindenburg@… added

Cc Me!

Changed 10 years ago by kurthindenburg (Kurt Hindenburg)

Attachment: portlint2.diff added

comment:3 Changed 10 years ago by kurthindenburg (Kurt Hindenburg)

Here's a first attempt at the depends part - it appears to work though I'm not sure this is the best/correct way.

Some examples:

--->  Verifying Portfile for aubio
Error: PortGroup waf uses depends_build, so use depends_build-append
--->  Verifying Portfile for ocaml-flac
Error: PortGroup ocaml uses depends_lib, so use depends_lib-append
Error: PortGroup ocaml uses depends_build, so use depends_build-append

comment:4 Changed 9 years ago by raimue (Rainer Müller)

What if a PortGroup has a depends_lib statement in a conditonal block? This regex would always match although using depends_lib in the Portfile would not be incorrect. Although it would be harmless to use depends_lib-append in this case.

Note: See TracTickets for help on using tickets.