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)
Sun, Mar 10, 11:33 PM
Unknown Object (File)
Feb 14 2024, 8:52 PM
Unknown Object (File)
Dec 20 2023, 4:41 AM
Unknown Object (File)
Dec 13 2023, 6:54 AM
Unknown Object (File)
Nov 18 2023, 9:15 AM
Unknown Object (File)
Nov 18 2023, 9:03 AM
Unknown Object (File)
Nov 18 2023, 8:41 AM
Unknown Object (File)
Nov 18 2023, 8:01 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
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 29632
Build 27490: arc lint + arc unit

Event Timeline

Mk/bsd.port.mk
4336–4337

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
4336–4337

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

Use XARGS instead of TR

tobik added inline comments.
Mk/bsd.port.mk
4336–4337

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
4336–4337

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
4336–4337

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
4336–4337

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.