Page MenuHomeFreeBSD

Fix install-missing-packages when port is missing multiple dependencies
ClosedPublic

Authored by 0mp on Feb 22 2020, 8:49 PM.

Details

Summary
Fix install-missing-packages when port is missing multiple dependencies

The current implementation of install-missing-packages does not handle
correctly the situation when a port is missing multiple dependencies. pkg(8)
would only get the first missing origin as an argument. All the other origins
would be listed on new lines and would not be passed to pkg(8).

This patch replaces newlines with spaces to avoid this problem. An alternative
solution would be to replace ECHO_CMD with "printf %s" and unquote the _dirs
variable. The implemented solution is cleaner, however, in my opinion (less
magical).

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244215

Test Plan

Test with both default SU_CMD and SU_CMD= /usr/local/bin/sudo -E sh -c set in /etc/make.conf.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

0mp created this revision.Feb 22 2020, 8:49 PM
0mp edited the summary of this revision. (Show Details)Feb 22 2020, 8:50 PM
mat added inline comments.Feb 25 2020, 2:05 PM
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

I would use | ${XARGS} which will take care of that.

0mp planned changes to this revision.Feb 25 2020, 7:31 PM
0mp added inline comments.
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

Hmm, sure, although I think that tr is more explicit.

0mp updated this revision to Diff 68822.Feb 25 2020, 7:59 PM

Use XARGS instead of TR

tobik added a subscriber: tobik.Feb 26 2020, 6:49 AM
tobik added inline comments.
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

This should be

${SU_CMD} "${ECHO_CMD} \"$${_dirs}\" | ${SED} 's%${PORTSDIR}/%%g' | ${XARGS} ${PKG_BIN} install -A"

or even better push the su outwards as much as possible

${ECHO_CMD} "$${_dirs}" | ${SED} "s%${PORTSDIR}/%%g" | ${SU_CMD} "${XARGS} ${PKG_BIN} install -A"

0mp added inline comments.Feb 26 2020, 12:06 PM
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

We've tried that approach, @tobik.

The problem is that then you cannot have interactive prompts from pkg (stdin is taken by xargs).

tobik added inline comments.Feb 26 2020, 2:17 PM
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

I see. Luckily there seems to be an xargs(1) flag for exactly that, -o:

${ECHO_CMD} "$${_dirs}" | ${SED} "s%${PORTSDIR}/%%g" | ${SU_CMD} "${XARGS} -o ${PKG_BIN} install -A"
0mp updated this revision to Diff 68863.Feb 26 2020, 11:51 PM

Use xargs

0mp added inline comments.Feb 27 2020, 12:06 AM
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

Ha! I didn't know about this one! Thanks.

0mp marked 3 inline comments as done.Thu, Mar 12, 8:17 PM

Is it ready to be committed?

This revision was not accepted when it landed; it landed in state Needs Review.Tue, Mar 31, 8:31 AM
This revision was automatically updated to reflect the committed changes.