Subject: bin/29687: pkg_add cannot pass the empty view to pkg_view
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Joachim Kuebart <kuebart@mathematik.uni-ulm.de>
List: netbsd-bugs
Date: 03/13/2005 10:14:01
>Number: 29687
>Category: bin
>Synopsis: when pkg_add is called with -w "", pkg_view complains about its usage
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 13 10:14:01 +0000 2005
>Originator: Joachim Kuebart
>Release: NetBSD 2.99.16
>Organization:
>Environment:
System: NetBSD jaja 2.99.16 NetBSD 2.99.16 (ALPHA-$Revision: 1.201 $) #0: Fri Mar 11 19:29:41 CET 2005 joki@jaja:/usr/obj/usr/src/sys/arch/alpha/compile/JAJA alpha
Architecture: alpha
Machine: alpha
>Description:
Whenn installing a depoted package with pkg_add and passing the
empty view explicitly via -w "", pkg_view gets called with the -w
option, but without an argument. It consequently complains with a
usage message.
>How-To-Repeat:
Use a depoted package, for example, digest-20021220, and run
pkg_add -w "" digest-20021220
pkg_add will then call pkg_view with the following arguments:
pkg_view -w add digest-20021220
and the package is not added to the default (empty) view.
>Fix:
This patch also fixes additional blanks as noted by me in
<http://mail-index.netbsd.org/tech-pkg/2005/03/12/0004.html>.
This solution uses
1) no -w argument to pkg_view if -w was not specified on
the pkg_add command line (View == NULL)
2) an argument of --view= if -w "" was specified on the
pkg_add command line. This is necessary to bypass argument
deletion by fexec_skipempty().
3) arguments -w <View> if a non-empty view was specified on
the pkg_add command line.
If the nested ?: construct is deemed too convoluted, I'm happy to
think of another solution.
cvs diff: Diffing .
Index: perform.c
===================================================================
RCS file: /pub/NetBSD-CVS/src/usr.sbin/pkg_install/add/perform.c,v
retrieving revision 1.106
diff -u -p -r1.106 perform.c
--- perform.c 4 Feb 2005 09:03:02 -0000 1.106
+++ perform.c 13 Mar 2005 10:08:46 -0000
@@ -936,9 +936,10 @@ ignore_replace_depends_check:
}
fexec_skipempty(BINDIR "/pkg_view", "-d", dbdir,
- View ? "-w " : "", View ? View : "",
- Viewbase ? "-W " : "", Viewbase ? Viewbase : "",
- Verbose ? "-v " : "", "add", PkgName, NULL);
+ View ? (View[0] ? "-w" : "--view=") : "",
+ View && View[0] ? View : "",
+ Viewbase ? "-W" : "", Viewbase ? Viewbase : "",
+ Verbose ? "-v" : "", "add", PkgName, NULL);
}
goto success;