Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#61083 closed defect (fixed)

port info --depends repeats lines when more than one port specified

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone: MacPorts 2.6.4
Component: base Version: 2.6.99
Keywords: haspatch Cc:
Port:

Description

If port info --depends is invoked on a single port, the output is fine:

$ port info --depends zlib
depends_fetch:
depends_extract: xz
depends_patch:
depends_build:
depends_lib:
depends_run:
depends_test:

If info is requested for two ports, the first port's output is fine, but the second port's output is printed twice:

$ port info --depends zlib xz
depends_fetch:
depends_extract: xz
depends_patch:
depends_build:
depends_lib:
depends_run:
depends_test:
--
depends_fetch:
depends_extract: lbzip2
depends_patch:
depends_build:
depends_lib: libiconv, gettext
depends_run:
depends_test:
depends_fetch:
depends_extract: lbzip2
depends_patch:
depends_build:
depends_lib: libiconv, gettext
depends_run:
depends_test:

With three ports, the second port's output is printed twice and the third port's output is printed three times:

$ port info --depends zlib xz libiconv
depends_fetch:
depends_extract: xz
depends_patch:
depends_build:
depends_lib:
depends_run:
depends_test:
--
depends_fetch:
depends_extract: lbzip2
depends_patch:
depends_build:
depends_lib: libiconv, gettext
depends_run:
depends_test:
depends_fetch:
depends_extract: lbzip2
depends_patch:
depends_build:
depends_lib: libiconv, gettext
depends_run:
depends_test:
--
depends_fetch:
depends_extract:
depends_patch:
depends_build: gperf
depends_lib:
depends_run:
depends_test:
depends_fetch:
depends_extract:
depends_patch:
depends_build: gperf
depends_lib:
depends_run:
depends_test:
depends_fetch:
depends_extract:
depends_patch:
depends_build: gperf
depends_lib:
depends_run:
depends_test:

Change History (5)

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

The relevant code is in src/port/port.tcl in the proc action_info where it says:

        # Interpret a convenient field abbreviation
        if {[info exists options(ports_info_depends)] && $options(ports_info_depends) eq "yes"} {
            array unset options ports_info_depends
            set all_depends_options [list ports_info_depends_fetch ports_info_depends_extract \
                ports_info_depends_patch ports_info_depends_build ports_info_depends_lib \
                ports_info_depends_run ports_info_depends_test]
            foreach depends_option $all_depends_options {
                set options($depends_option) yes
            }
            # insert the expanded options into the ordering info
            set order_pos [lsearch -exact $global_options(options_${action}_order) ports_info_depends]
            set global_options(options_${action}_order) [lreplace $global_options(options_${action}_order) \
                $order_pos $order_pos {*}$all_depends_options]
        }

This is inside a loop over each port. It looks like the intention is that this only be executed for the first port, since the first thing it does is to unset options(ports_info_depends). However, every time through the loop, options appears to have been reset to its previous value. I don't know where or how options gets set. Is that what's happening in src/macports1.0/macports.tcl in proc mportinit where it says:

    ditem_key $mport options $options

It seems like there is a lot of code (creating the arrays list_map, pretty_label, pretty_wrap) that could be brought out of the foreachport loop.

comment:2 in reply to:  1 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to ryandesign
Status: newaccepted

Replying to ryandesign:

However, every time through the loop, options appears to have been reset to its previous value. I don't know where or how options gets set. Is that what's happening in src/macports1.0/macports.tcl

Ah no, it's happening in src/port/port.tcl in proc foreachport, and it's intentional.

So we need to check and only replace the option in global_options if the old option was actually found there (i.e. if order_pos != -1).

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

Keywords: haspatch added
Milestone: MacPorts 2.7.0

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

Resolution: fixed
Status: acceptedclosed

In a7cf423c9c054d225b563cb6f34d8baa5c869818/macports-base (master):

Fix port info --depends with multiple ports

Closes: #61083

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

Milestone: MacPorts 2.7.0MacPorts 2.6.4
Note: See TracTickets for help on using tickets.