NetBSD Problem Report #32827

From plunky@rya-online.net  Mon Feb 13 21:48:24 2006
Return-Path: <plunky@rya-online.net>
Received: from mail12.svc.cra.dublin.eircom.net (mail12.svc.cra.dublin.eircom.net [159.134.118.28])
	by narn.netbsd.org (Postfix) with SMTP id C0E7A63B879
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 13 Feb 2006 21:48:18 +0000 (UTC)
Message-Id: <1139867228.402365.3291.nullmailer@galant.ukfsn.org>
Date: Mon, 13 Feb 2006 21:47:08 +0000
From: plunky@rya-online.net
Reply-To: plunky@rya-online.net
To: gnats-bugs@netbsd.org
Subject: pkg_info improvement
X-Send-Pr-Version: 3.95

>Number:         32827
>Category:       pkg
>Synopsis:       add -A option to pkg_info to make it only show Application packages (that are not required by anybody)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    joerg
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 13 21:50:00 +0000 2006
>Closed-Date:    Sun Mar 07 18:39:16 +0000 2010
>Last-Modified:  Sun Mar 07 18:39:16 +0000 2010
>Originator:     Iain Hibbert
>Release:        NetBSD 3.99.15
>Organization:
http://maps.google.com/maps?q=ireland&ll=52.2711,-9.8630&spn=0.0244,0.0822&t=k
>Environment:


System: NetBSD galant 3.99.15 NetBSD 3.99.15 (GALANT) #52: Mon Feb 13 10:28:09 GMT 2006 plunky@galant:/home/plunky/src/sys/arch/i386/compile/GALANT i386
Architecture: i386
Machine: i386
>Description:
Using 'pkg_info -u' to get a list of packages to install does not always
work well when the stupid user has been updating packages manually. This
patch adds an -A for Application option that causes pkg_info to only print
packages that do not have any other packages depending on them (ie Apps)

This patch doesnt work completely either, since build dependencies show
up in the list but that could be a feature if you look at it hard enough..

% pkg_info -A | wc -l
      64
% pkg_info -a | wc -l
     260
% pkg_info -u | wc -l
     169

iain
>How-To-Repeat:

>Fix:
Index: usr.sbin/pkg_install/info/info.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/info.h,v
retrieving revision 1.21
diff -u -r1.21 info.h
--- usr.sbin/pkg_install/info/info.h	3 Nov 2005 21:16:41 -0000	1.21
+++ usr.sbin/pkg_install/info/info.h	13 Feb 2006 21:32:38 -0000
@@ -56,6 +56,7 @@
 enum which {
     WHICH_ALL,
     WHICH_USER,
+    WHICH_APPS,
     WHICH_LIST
 };

Index: usr.sbin/pkg_install/info/main.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/main.c,v
retrieving revision 1.47
diff -u -r1.47 main.c
--- usr.sbin/pkg_install/info/main.c	5 Nov 2005 13:11:02 -0000	1.47
+++ usr.sbin/pkg_install/info/main.c	13 Feb 2006 21:32:38 -0000
@@ -50,7 +50,7 @@
 #include "lib.h"
 #include "info.h"

-static const char Options[] = ".aBbcDde:fFhIiK:kLl:mNnpQ:qRrsSuvV";
+static const char Options[] = ".AaBbcDde:fFhIiK:kLl:mNnpQ:qRrsSuvV";

 int     Flags = 0;
 enum which Which = WHICH_LIST;
@@ -88,6 +88,10 @@
 		case '.':	/* for backward compatibility */
 			break;

+		case 'A':
+			Which = WHICH_APPS;
+			break;
+
 		case 'a':
 			Which = WHICH_ALL;
 			break;
@@ -218,13 +222,13 @@
 	if (argc == 0 && !Flags && !CheckPkg) {
 		/* No argument or relevant flags specified - assume -I */
 		Flags = SHOW_INDEX;
-		/* assume -a if neither -u nor -a is given */
+		/* assume -a if none of -u, -A nor -a is given */
 		if (Which == WHICH_LIST)
 			Which = WHICH_ALL;
 	}

 	if (argc != 0 && Which != WHICH_LIST) {
-		warnx("can't use both -a/-u and package name");
+		warnx("can't use both -A/-a/-u and package name");
 		usage();
 	}

Index: usr.sbin/pkg_install/info/perform.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/perform.c,v
retrieving revision 1.67
diff -u -r1.67 perform.c
--- usr.sbin/pkg_install/info/perform.c	23 Nov 2005 04:59:14 -0000	1.67
+++ usr.sbin/pkg_install/info/perform.c	13 Feb 2006 21:32:40 -0000
@@ -386,6 +386,16 @@
 	exit(1);
 }

+static Boolean
+is_orphan(const char *path)
+{
+	char	buf[MaxPathSize];
+
+	(void)snprintf(buf, sizeof(buf), "%s/%s", path, REQUIRED_BY_FNAME);
+
+	return isemptyfile(buf);
+}
+
 int
 pkg_perform(lpkg_head_t *pkghead)
 {
@@ -426,7 +436,8 @@
 						continue;

 					if (Which == WHICH_ALL
-					    || !is_automatic_installed(tmp2))
+					    || (Which == WHICH_USER && !is_automatic_installed(tmp2))
+					    || (Which == WHICH_APPS && is_orphan(tmp2)))
 						err_cnt += pkg_do(dp->d_name);
 				}
 				(void) closedir(dirp);
Index: usr.sbin/pkg_install/info/pkg_info.1
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/pkg_info.1,v
retrieving revision 1.50
diff -u -r1.50 pkg_info.1
--- usr.sbin/pkg_install/info/pkg_info.1	3 Nov 2005 21:16:41 -0000	1.50
+++ usr.sbin/pkg_install/info/pkg_info.1	13 Feb 2006 21:32:40 -0000
@@ -31,7 +31,7 @@
 .Op Fl l Ar prefix
 .Ar pkg-name ...
 .Nm
-.Op Fl a | Fl u
+.Op Fl A | Fl a | Fl u
 .Op flags
 .Nm
 .Op Fl Q Ar variable
@@ -58,6 +58,9 @@
 .Pp
 The following command-line options are supported:
 .Bl -tag -width indent
+.It Fl A
+Show information for packages which have no other packages depending on
+them.
 .It Fl a
 Show information for all currently installed packages.
 See also

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->joerg
Responsible-Changed-By: joerg@netbsd.org
Responsible-Changed-When: Sat, 03 Nov 2007 14:30:09 +0000
Responsible-Changed-Why:
Assign to maintainer^Wme.


State-Changed-From-To: open->feedback
State-Changed-By: joerg@NetBSD.org
State-Changed-When: Wed, 21 May 2008 22:02:22 +0000
State-Changed-Why:
Does pkgtools/pkg_leaves fill this hole?


From: Iain Hibbert <plunky@rya-online.net>
To: gnats-bugs@NetBSD.org
Cc: pkgsrc-bugs@netbsd.org, gnats-admin@netbsd.org, joerg@NetBSD.org
Subject: Re: pkg/32827 (add -A option to pkg_info to make it only show
 Application packages (that are not required by anybody))
Date: Mon, 23 Jun 2008 16:24:15 +0100 (BST)

 On Wed, 21 May 2008, joerg@NetBSD.org wrote:

 > Synopsis: add -A option to pkg_info to make it only show Application packages (that are not required by anybody)
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: joerg@NetBSD.org
 > State-Changed-When: Wed, 21 May 2008 22:02:22 +0000
 > State-Changed-Why:
 > Does pkgtools/pkg_leaves fill this hole?

 yes it does

 (I have no objection to the PR being closed, though I think adding a
 switch to pkg_info would be simpler :)

 iain

State-Changed-From-To: feedback->analyzed
State-Changed-By: joerg@NetBSD.org
State-Changed-When: Sat, 11 Oct 2008 21:52:29 +0000
State-Changed-Why:
A package provides this option and targets the requirements of the
submitter. Open question whether this should be in pkg_info itself
remains.


From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: joerg@NetBSD.org, plunky@rya-online.net
Subject: Re: pkg/32827 (add -A option to pkg_info to make it only show
	Application packages (that are not required by anybody))
Date: Sun, 7 Mar 2010 05:17:01 +0000

 On Sat, Oct 11, 2008 at 09:52:30PM +0000, joerg@NetBSD.org wrote:
  > Synopsis: add -A option to pkg_info to make it only show Application packages (that are not required by anybody)
  > 
  > State-Changed-From-To: feedback->analyzed
  > State-Changed-By: joerg@NetBSD.org
  > State-Changed-When: Sat, 11 Oct 2008 21:52:29 +0000
  > State-Changed-Why:
  > A package provides this option and targets the requirements of the
  > submitter. Open question whether this should be in pkg_info itself
  > remains.

 ...after nearly a year and a half, have we reached a decision?

 (IMO, adding a million special-case queries as options to pkg_info
 doesn't scale; if we really want all these queries to be answered
 directly by pkg_info it should grow a real query language of some
 kind.)

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: analyzed->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 07 Mar 2010 18:39:16 +0000
State-Changed-Why:
joerg says no, if anyone has a strong opinion otherwise let's take it up on
tech-pkg.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.