Page MenuHomeFreeBSD

Fix install-missing-packages
ClosedPublic

Authored by 0mp on Feb 3 2020, 4:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 18, 10:50 AM
Unknown Object (File)
Jan 21 2024, 3:58 AM
Unknown Object (File)
Jan 14 2024, 3:47 PM
Unknown Object (File)
Dec 20 2023, 3:59 AM
Unknown Object (File)
Nov 12 2023, 8:16 AM
Unknown Object (File)
Nov 11 2023, 2:21 PM
Unknown Object (File)
Nov 10 2023, 8:13 AM
Unknown Object (File)
Nov 8 2023, 10:07 PM
Subscribers

Details

Reviewers
bapt
Group Reviewers
O5: Ports Framework(Owns No Changed Paths)
portmgr
Commits
rP525138: Fix install-missing-packages
Summary
Fix install-missing-packages

r519284 introduced a new target, install-missing-packages, which is meant to
allow users to install dependencies via pkg(8) instead of building them
themselves locally.

The target was producing errors when the dependencies were already available on
the system. This commit adjusts this behavior to just silently do nothing if
everything is fine.

Also, remove some trailing whitespace introduced in the original commit.

Other considerations:

  • In the past users were using one-liners like make missing | xargs pkg install --automatic --yes to install dependencies from packages (as documented in ports(7)). Unfortunately, the both the implementation of install-missing-packages and the one-liner install all the packages associated with the origin, which is usually not desired. I wonder if there is a way to, for example, install only the required flavor of a Python port instead of all the available ones when installing a Python dependency this way.
  • The manual page for ports has to be updated. I'll do it soon.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 29136
Build 27072: arc lint + arc unit

Event Timeline

Actually it should also be surrounded by SU_CMD while you are at it ;)

In D23484#515324, @bapt wrote:

Actually it should also be surrounded by SU_CMD while you are at it ;)

Sure!

Wrap pkg call with SU_CMD

0mp planned changes to this revision.Feb 3 2020, 5:22 PM
  1. We cannnot use xargs here as it breaks interactive input.
  2. SU_CMD cannot be used this way.

I do not fully understand what this is fixing. It looks like you are just moving things around to use a pipe instead of a temporary variable.

  • Revert to the original implementation of install-missing-packages.
  • Do not call pkg-install(8) if there is nothing to install.
  • Wrap the pkg command with SU_CMD for better user experience.

@mat, you are somewhat right, haha. I thought that using xargs is going to be an elegant way of covering the case when there is nothing to install (no origins being passed to pkg-install(8)). It quickly turned out that I broke the interactivity of this command.

Now I reverted to the original implementation and improved it. Sorry for the noise.

  • Add a missing period at the end of the description of the target.
This revision is now accepted and ready to land.Feb 4 2020, 9:25 AM
This revision was automatically updated to reflect the committed changes.

Points 1, 2 and 5 of https://en.wikipedia.org/wiki/The_Elements_of_Programming_Style :

  1. Write clearly -- don't be too clever.
  2. Say what you mean, simply and directly.
  1. Write clearly -- don't sacrifice clarity for efficiency.
head/Mk/bsd.port.mk
4335–4336 ↗(On Diff #67768)

Ok, so, this is wrong.
The correct way to write it is:

if [ -n "$${_dirs}" ]; then \
    ${SU_CMD}...; \
fi

Because:

  1. using [ ] || is akin to using a unless or if !, but worse
  2. if you are using if ! [ -z might as make it easier to read, if [ -n.
adamw added inline comments.
head/Mk/bsd.port.mk
4336 ↗(On Diff #67768)

Also, you have quotes within quotes. It'll break if PORTSDIR has a space in it. Probably better to turn the sed arg into single quotes.

head/Mk/bsd.port.mk
4335–4336 ↗(On Diff #67768)

@mat

You are right. Thank you for the suggestion. I'll send another patch shorty.

4336 ↗(On Diff #67768)

@adamw,

hmmm, I think that this is not a problem because the second pair of quotes is inside a subshell.

For example, the following code works as I expect:

export VAR="foo bar"
ls "$(echo "/foo bar" | sed "s/$VAR//g")"
# Expected result is to run "ls /"

Am I missing something?

head/Mk/bsd.port.mk
4336 ↗(On Diff #67768)

You are correct. I missed the subshell there. Thanks for setting me straight!