Page MenuHomeFreeBSD

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

Authored by 0mp on Feb 22 2020, 8:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 3:23 PM
Unknown Object (File)
Thu, Apr 11, 2:15 PM
Unknown Object (File)
Tue, Apr 9, 3:08 AM
Unknown Object (File)
Tue, Apr 2, 11:52 PM
Unknown Object (File)
Sun, Mar 31, 2:12 PM
Unknown Object (File)
Mar 10 2024, 11:33 PM
Unknown Object (File)
Feb 14 2024, 8:52 PM
Unknown Object (File)
Dec 20 2023, 4:41 AM
Subscribers

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
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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.

Use XARGS instead of TR

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"

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).

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"
Mk/bsd.port.mk
4338 ↗(On Diff #68683)

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

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

Is it ready to be committed?

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