Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore missing packages #2195

Open
vermaden opened this issue Oct 29, 2023 · 6 comments
Open

Ignore missing packages #2195

vermaden opened this issue Oct 29, 2023 · 6 comments
Labels

Comments

@vermaden
Copy link

vermaden commented Oct 29, 2023

How to make pkg(8) ignore not available packages when installing multiple package?

Example:

# pkg install CATEGORY0/PORT0 CATEGORY1/PORT1 CATEGORY2/PORT2
(...)
pkg: No packages available to install matching 'CATEGORY1/PORT1' have been found in the repositories
(...)

As CATEGORY1/PORT1 is not a dependency for either CATEGORY0/PORT0 or CATEGORY2/PORT2 - how to make pkg(8) install both CATEGORY0/PORT0 and CATEGORY2/PORT2 and also ignore that CATEGORY1/PORT1 is not available?

Thanks,
vermaden

@vermaden
Copy link
Author

vermaden commented Oct 29, 2023

I currently overcome that with sed(1) removing the packages that are missing - but that requires 2 pkg(8) runs instead of just 1. One 'dry' run to get missing packages. One 'real' run with only packages that are available.

Solution below.

CHROOT=/var/tmp/14.0-RC2
PACKAGES="
sysutils/automount                                                      
sysutils/beadm
www/asdasdasd
www/bsdbsdbsd"

while read EXCLUDE
do
  [ "${EXCLUDE}" = "" ] && break
  PACKAGES=$( echo ${PACKAGES} | sed s.${EXCLUDE}..g )
done << EOF
$(
  chroot "${CHROOT}" \
    /usr/bin/env ASSUME_ALWAYS_YES=yes pkg install -y --ignore-missing ${PACKAGES} 2>&1 \
      | grep "No packages available to install matching" \
      | awk -F\' '{print $2}'
)
EOF

chroot "${CHROOT}" \
  /usr/bin/env ASSUME_ALWAYS_YES=yes pkg install -y --ignore-missing ${PACKAGES}

Regards,
vermaden

EDIT: Added [ "${EXCLUDE}" = "" ] && break if there are not EXCLUDES (all packages available).

@bapt bapt added the feature label Oct 31, 2023
@bapt
Copy link
Member

bapt commented Oct 31, 2023

I agree having a flag for this will be interesting...

@emaste
Copy link
Member

emaste commented Oct 31, 2023

Or what about something like:

pkg: No packages available to install matching 'CATEGORY1/PORT1' have been found in the repositories
Install other requested packages [Y/n]?

The flag could support yes/no/ask, with default to ask?

@vermaden
Copy link
Author

vermaden commented Nov 1, 2023

@emaste

Default can be ask like with Your proposal above.

I would just suggest if user added -y flag - then yes is assumed and no questions asked.

Regards,
vermaden

@bzfbd
Copy link

bzfbd commented Nov 8, 2024

I've hit this case while working on the installer this week. I am working around that for the limited case for firmware but finding that feature request was good. +1 from me for this feature.

freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Nov 8, 2024
Introduce -q to quieten other output (unless -v is also given).

pkg-install(8) currently has no option to allow skipping unavail
packages but it will just fail.
We would realy want to try to install as much firmware found as
possible from the installer.
Work around this by doing one firmware package at a time.
For that it is highly helpful to be able to query (or possibly re-query)
all outstanding fimrware packages.
-q together with -n only shows each package to be installed one by line.

Once freebsd/pkg#2195 will be implemented
we could undo this part of the change and future changes to the installer
and use the new option for pkg-install(8) there.

While here switch to getopts so -qn works and not just -q -n.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D47445
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Nov 14, 2024
Introduce -q to quieten other output (unless -v is also given).

pkg-install(8) currently has no option to allow skipping unavail
packages but it will just fail.
We would realy want to try to install as much firmware found as
possible from the installer.
Work around this by doing one firmware package at a time.
For that it is highly helpful to be able to query (or possibly re-query)
all outstanding fimrware packages.
-q together with -n only shows each package to be installed one by line.

Once freebsd/pkg#2195 will be implemented
we could undo this part of the change and future changes to the installer
and use the new option for pkg-install(8) there.

While here switch to getopts so -qn works and not just -q -n.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	manu
Differential Revision: https://reviews.freebsd.org/D47445

(cherry picked from commit 1eb3f15)
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Nov 19, 2024
Introduce -q to quieten other output (unless -v is also given).

pkg-install(8) currently has no option to allow skipping unavail
packages but it will just fail.
We would realy want to try to install as much firmware found as
possible from the installer.
Work around this by doing one firmware package at a time.
For that it is highly helpful to be able to query (or possibly re-query)
all outstanding fimrware packages.
-q together with -n only shows each package to be installed one by line.

Once freebsd/pkg#2195 will be implemented
we could undo this part of the change and future changes to the installer
and use the new option for pkg-install(8) there.

While here switch to getopts so -qn works and not just -q -n.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	manu
Approved by:    re (cperciva)
Differential Revision: https://reviews.freebsd.org/D47445

(cherry picked from commit 1eb3f15)
(cherry picked from commit 814a49d)
@bzfbd
Copy link

bzfbd commented Nov 21, 2024

And another use case for this:
https://cgit.FreeBSD.org/src/commit/?id=e8263ace39c8ecf11233c0a10d0b1839e6813046

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants