pkg_rolling-replace: catch permission errors from pkg_admin
and print a friendlier warning message instead (only once). Document that the mismatch state may not persist if permissions are insufficient.
This commit is contained in:
parent
c40b549999
commit
5b2c612bfe
3 changed files with 16 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.47 2021/01/15 10:56:52 tnn Exp $
|
||||
# $NetBSD: Makefile,v 1.48 2021/04/13 17:51:21 rhialto Exp $
|
||||
|
||||
PKGNAME= pkg_rolling-replace-0.24.10
|
||||
PKGNAME= pkg_rolling-replace-0.24.11
|
||||
CATEGORIES= pkgtools
|
||||
|
||||
MAINTAINER= gdt@NetBSD.org
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: pkg_rolling-replace.8,v 1.21 2021/01/09 19:12:46 rhialto Exp $
|
||||
.\" $NetBSD: pkg_rolling-replace.8,v 1.22 2021/04/13 17:51:21 rhialto Exp $
|
||||
.Dd February 1, 2010
|
||||
.Dt PKG_ROLLING-REPLACE 8
|
||||
.Os
|
||||
|
@ -133,6 +133,9 @@ Use
|
|||
to check for mismatched packages, mark them with 'mismatch=YES',
|
||||
and replace those too.
|
||||
Otherwise, consider packages marked 'mismatch=YES' to be mismatched.
|
||||
Marking with 'mismatch=YES' only occurs if the calling user can write
|
||||
to the package database. It is not an error if this fails; it just does not
|
||||
persist the status.
|
||||
.It Fl v
|
||||
Verbose output.
|
||||
.It Fl X Ar pkgs
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $NetBSD: pkg_rolling-replace.sh,v 1.42 2021/01/15 10:56:52 tnn Exp $
|
||||
# $NetBSD: pkg_rolling-replace.sh,v 1.43 2021/04/13 17:51:21 rhialto Exp $
|
||||
#<license>
|
||||
# Copyright (c) 2006 BBN Technologies Corp. All rights reserved.
|
||||
#
|
||||
|
@ -152,6 +152,8 @@ OPC='rr>' # continuation
|
|||
# supported. Newer versions may or may not work (patches welcome).
|
||||
check_packages_mismatched()
|
||||
{
|
||||
warned_once=""
|
||||
|
||||
${PKG_CHK} -u -q $opt_B | egrep -v missing | while read line; do
|
||||
# duplicate output of pkg_chk to stderr (bypass $(...) or `...`)
|
||||
echo "${OPC} $line" 1>&2
|
||||
|
@ -160,7 +162,13 @@ check_packages_mismatched()
|
|||
for word in $line; do
|
||||
if [ "$(echo $word | egrep '^[^/]+-[0-9][^-/]*$')" ]; then
|
||||
if [ -z "$opt_F" ]; then
|
||||
${PKG_ADMIN} set mismatch=YES "$word" 1>&2
|
||||
${PKG_ADMIN} set mismatch=YES "$word" 2>&1 >/dev/null || {
|
||||
if [ -z "$warned_once" ]; then
|
||||
echo 1>&2 "$OPC WARNING: mismatch variable not set due to permissions;"
|
||||
echo 1>&2 "$OPC mismatch status will not persist."
|
||||
warned_once=1
|
||||
fi
|
||||
}
|
||||
fi
|
||||
echo $word | sed 's/-[0-9][^-]*$//'
|
||||
break #done with this line
|
||||
|
|
Loading…
Reference in a new issue