Opened 11 years ago

Last modified 6 months ago

#36957 new enhancement

Guide: Document the "subport" command

Reported by: dave@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: guide Version:
Keywords: Cc: cooljeanius (Eric Gallager), larryv (Lawrence Velázquez), nonstop.server@…, petrrr, ctreleaven (Craig Treleaven), robertoschwald (Robert Oschwald), JDLH (Jim DeLaHunt), jrjsmrtn
Port:

Description

I find it used in a few of the official ports, but can't find anything about it on the portfile manpage (or any of the others).

Change History (19)

comment:1 Changed 11 years ago by cooljeanius (Eric Gallager)

I think this was also mentioned in the discussion thread for Issue #126

comment:2 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

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

Usage:

subport <subname> { body }

Body is executed iff the portfile has been opened as the port name <subname>. This allows defining multiple ports in a single portfile, which avoids redundancy in cases where you would otherwise need to have several almost identical portfiles.

If someone wants to write this up nicely and add it to the guide and portfile(7) before I get to it, please go ahead.

comment:4 Changed 11 years ago by larryv (Lawrence Velázquez)

Cc: larryv@… added

Cc Me!

comment:5 in reply to:  3 Changed 11 years ago by cooljeanius (Eric Gallager)

Replying to jmr@…:

Usage:

subport <subname> { body }

Body is executed iff the portfile has been opened as the port name <subname>. This allows defining multiple ports in a single portfile, which avoids redundancy in cases where you would otherwise need to have several almost identical portfiles.

If someone wants to write this up nicely and add it to the guide and portfile(7) before I get to it, please go ahead.

OK, so that's the usage of subports in portfiles, how about the command-line usage of the subport: and subportof: pseudo-portnames added in r100059? So far they're only documented in the changelog (r100060)...

comment:6 Changed 11 years ago by nonstop.server@…

Cc: nonstop.server@… added

Cc Me!

comment:7 Changed 10 years ago by petrrr

Cc: petr@… added

Cc Me!

comment:8 Changed 10 years ago by petrrr

I recently stepped across this as well and therefore would like to rebump this ticket.

comment:9 Changed 10 years ago by ctreleaven (Craig Treleaven)

Cc: ctreleaven@… added

Cc Me!

comment:10 Changed 10 years ago by mf2k (Frank Schima)

Owner: changed from markd@… to macports-tickets@…
Summary: "subport" is undocumentedGuide: Document the "subport" command
Type: defectenhancement
Version: 2.1.2

markd has retired. See #44782.

comment:11 Changed 9 years ago by coke (Will Coleda)

Cc: will@… added

Cc Me!

comment:12 Changed 9 years ago by robertoschwald (Robert Oschwald)

Cc: robertoschwald@… added

Cc Me!

comment:13 Changed 3 years ago by JDLH (Jim DeLaHunt)

Cc: JDLH added

comment:14 Changed 3 years ago by JDLH (Jim DeLaHunt)

To help the future author of this documentation: a lot of the implementation of the "subport" command appears to be in changeset r78062 .

See also macports-dev thread, Newbie Portfile writer question: what does "subport" do? https://lists.macports.org/pipermail/macports-dev/2021-July/043627.html .

comment:15 Changed 3 years ago by JDLH (Jim DeLaHunt)

It looks like the implementation of the "subport" command, from changeset r78062, is identified in the git history as commit 916b477b077b383a17099329aaeddacb52c0b341 dated 2011-04-21 14:07:51. I can see this commit in the Git repo I cloned from GitHub, but not in the GitHub UI, and trac appears to be unable to find this commit as a changeset link.

Last edited 6 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:16 Changed 3 years ago by JDLH (Jim DeLaHunt)

I think I found the code which implements the subport directive: macports-base/src/port1.0/portutil.tcl:844-857 [1]

# Portfiles may define more than one port.
# This executes the given code in 'body' if we were opened as the specified
# subport, and also adds it to the list of subports that are defined.
proc subport {subname body} {
    global subport name PortInfo
    if {$subport eq $name && $subname ne $name && 
        (![info exists PortInfo(subports)] || $subname ni $PortInfo(subports))} {
        lappend PortInfo(subports) $subname
    }
    if {[string equal -nocase $subname $subport]} {
        set PortInfo(name) $subname
        uplevel 1 $body
    }
}

That might be helpful to the person writing this documentation.

[1] https://github.com/macports/macports-base/blob/2c6fc24ddd1d6961afa83c5b35be12224b6850f6/src/port1.0/portutil.tcl#L844-L857

Last edited 6 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:17 Changed 3 years ago by coke (Will Coleda)

Cc: coke removed

comment:18 Changed 2 years ago by jrjsmrtn

Cc: jrjsmrtn added

comment:19 Changed 15 months ago by Zweihorn (@Zweihorn)

Got you apparently ... ;)

New section on 'subport'

AFAIK the Chapter 4. Portfile Development lacks sufficient documentary on the 'subport' excellent opportunities both for new Portfile development and port mainentance, unfortunately.

macports-guide: adoc/ content list #53

However, supposedly we could discuss if I ever can become the person writing this documentation. At your deliberation naturally.

Note: See TracTickets for help on using tickets.