pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Ignore missing packages

Open vermaden opened this issue 1 year ago • 4 comments

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 avatar Oct 29 '23 12:10 vermaden

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

vermaden avatar Oct 29 '23 13:10 vermaden

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

bapt avatar Oct 31 '23 07:10 bapt

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?

emaste avatar Oct 31 '23 18:10 emaste

@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

vermaden avatar Nov 01 '23 00:11 vermaden