pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/49117: new pkg_info file list option



>Number:         49117
>Category:       pkg
>Synopsis:       new pkg_info file list option
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 15 09:25:00 +0000 2014
>Originator:     Rémy Chibois
>Release:        2013Q4
>Organization:
>Environment:
Darwin macbook 14.0.0 Darwin Kernel Version 14.0.0: Wed Jul 16 00:46:31 PDT 
2014; root:xnu-2782.1.43.0.2~2/RELEASE_X86_64 x86_64
>Description:
There is currently no way to search for non-installed packages containing a 
file. A simple (compressed) file in the spirit of pkg_summary.gz and stored in 
binary package repositories would allow this. This file is a collection of 
lines like:

PACKAGE_NAME: /path/to/file

The suggested new pkg_info option, -Y, would be used like:

pkg_info -qY *.tgz | gzip -9 > pkg_files.gz

I already contacted pkgin's author and proposed a new 'search-file' command 
implementation with cached download of a per-repository pkg_files.gz
(please see https://github.com/chybz/pkgin for details).

Please find below a patch against pkg_install that implements this option.
A working implementation is available in this pkgsrc tree:

https://github.com/yrmt/pkgsrc

Thank you.
>How-To-Repeat:
non relevant -- change request
>Fix:
diff --git a/pkgtools/pkg_install/files/info/info.h 
b/pkgtools/pkg_install/files/info/info.h
index f8b6b4d..6912ba9 100644
--- a/pkgtools/pkg_install/files/info/info.h
+++ b/pkgtools/pkg_install/files/info/info.h
@@ -101,6 +101,7 @@ struct pkg_meta {
 #define SHOW_BI_VAR            0x40000
 #define SHOW_SUMMARY           0x80000
 #define SHOW_FULL_REQBY                0x100000
+#define SHOW_PKG_FILES         0x200000
 
 enum which {
     WHICH_ALL,
@@ -123,6 +124,7 @@ void        show_file(const char *, const char *, Boolean);
 void   show_var(const char *, const char *);
 void   show_plist(const char *, package_t *, pl_ent_t);
 void   show_files(const char *, package_t *);
+void   show_pkg_files(const char *, package_t *);
 void   show_depends(const char *, package_t *);
 void   show_bld_depends(const char *, package_t *);
 void   show_index(const char *, const char *);
diff --git a/pkgtools/pkg_install/files/info/main.c 
b/pkgtools/pkg_install/files/info/main.c
index 82b0e1d..16a7c38 100644
--- a/pkgtools/pkg_install/files/info/main.c
+++ b/pkgtools/pkg_install/files/info/main.c
@@ -41,7 +41,7 @@ __RCSID("$NetBSD: main.c,v 1.31 2012/12/17 04:34:02 agc Exp 
$");
 #include "lib.h"
 #include "info.h"
 
-static const char Options[] = ".aBbcDde:E:fFhIiK:kLl:mNnpQ:qrRsSuvVX";
+static const char Options[] = ".aBbcDde:E:fFhIiK:kLl:mNnpQ:qrRsSuvVXY";
 
 int     Flags = 0;
 enum which Which = WHICH_LIST;
@@ -55,7 +55,7 @@ static void
 usage(void)
 {
        fprintf(stderr, "%s\n%s\n%s\n%s\n",
-           "usage: pkg_info [-BbcDdFfhIikLmNnpqRrSsVvX] [-E pkg-name] [-e 
pkg-name]",
+           "usage: pkg_info [-BbcDdFfhIikLmNnpqRrSsVvXY] [-E pkg-name] [-e 
pkg-name]",
            "                [-K pkg_dbdir] [-l prefix] pkg-name ...",
            "       pkg_info [-a | -u] [flags]",
            "       pkg_info [-Q variable] pkg-name ...");
@@ -202,6 +202,10 @@ main(int argc, char **argv)
                        Flags |= SHOW_SUMMARY;
                        break;
 
+               case 'Y':
+                       Flags |= SHOW_PKG_FILES;
+                       break;
+
                case 'h':
                case '?':
                default:
diff --git a/pkgtools/pkg_install/files/info/perform.c 
b/pkgtools/pkg_install/files/info/perform.c
index 8278158..f68afee 100644
--- a/pkgtools/pkg_install/files/info/perform.c
+++ b/pkgtools/pkg_install/files/info/perform.c
@@ -473,6 +473,9 @@ pkg_do(const char *pkg)
                if (Flags & SHOW_FILES) {
                        show_files("Files:\n", &plist);
                }
+               if (Flags & SHOW_PKG_FILES) {
+                       show_pkg_files("Files:\n", &plist);
+               }
                if ((Flags & SHOW_BUILD_VERSION) && meta->meta_build_version) {
                        show_file(meta->meta_build_version, "Build version:\n",
                                  TRUE);
diff --git a/pkgtools/pkg_install/files/info/pkg_info.1 
b/pkgtools/pkg_install/files/info/pkg_info.1
index 16f5fd8..f094432 100644
--- a/pkgtools/pkg_install/files/info/pkg_info.1
+++ b/pkgtools/pkg_install/files/info/pkg_info.1
@@ -25,7 +25,7 @@
 .Nd a utility for displaying information on software packages
 .Sh SYNOPSIS
 .Nm
-.Op Fl BbcDdFfhIikLmNnpqRrSsVvX
+.Op Fl BbcDdFfhIikLmNnpqRrSsVvXY
 .Op Fl E Ar pkg-name
 .Op Fl e Ar pkg-name
 .Op Fl K Ar pkg_dbdir
@@ -210,6 +210,12 @@ described in
 .Xr pkg_summary 5 .
 Its primary use is to contain all information about the contents of a
 (remote) binary package repository needed by package managing software.
+.It Fl Y
+Similar as
+.Fl L .
+, but prefixes each line with package name.
+Its primary use is to provide a global searchable file list of a
+(remote) binary package repository needed by package managing software.
 .El
 .Sh TECHNICAL DETAILS
 Package info is either extracted from package files named on the
diff --git a/pkgtools/pkg_install/files/info/show.c 
b/pkgtools/pkg_install/files/info/show.c
index daf3bdb..accb6d3 100644
--- a/pkgtools/pkg_install/files/info/show.c
+++ b/pkgtools/pkg_install/files/info/show.c
@@ -247,6 +247,48 @@ show_files(const char *title, package_t *plist)
 }
 
 /*
+ * Show all files in the packing list (except ignored ones) for pkg_files.txt
+ * 
+ */
+void
+show_pkg_files(const char *title, package_t *plist)
+{
+       plist_t *p;
+       Boolean ign;
+       const char *dir = ".";
+       const char *pkgname = "PKG";
+
+       if (!Quiet) {
+               printf("%s%s", InfoPrefix, title);
+       }
+       for (ign = FALSE, p = plist->head; p; p = p->next) {
+               if (p->type == PLIST_NAME) {
+                       pkgname = p->name;
+                       break;
+               }
+        }
+       for (ign = FALSE, p = plist->head; p; p = p->next) {
+               switch (p->type) {
+               case PLIST_FILE:
+                       if (!ign) {
+                               printf("%s: %s%s%s\n", pkgname, dir,
+                                       (strcmp(dir, "/") == 0) ? "" : "/", 
p->name);
+                       }
+                       ign = FALSE;
+                       break;
+               case PLIST_CWD:
+                       dir = p->name;
+                       break;
+               case PLIST_IGNORE:
+                       ign = TRUE;
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+/*
  * Show dependencies (packages this pkg requires)
  */
 void



Home | Main Index | Thread Index | Old Index