pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files pkg_install-20090817:
details: https://anonhg.NetBSD.org/pkgsrc/rev/4fa64ccb8986
branches: trunk
changeset: 397637:4fa64ccb8986
user: joerg <joerg%pkgsrc.org@localhost>
date: Sun Aug 16 21:10:14 2009 +0000
description:
pkg_install-20090817:
Add a new command for pkg_admin: findbest. It takes one or more patterns
and searches for the best match in PKG_PATH, just like pkg_add would.
It prints the URLs of the best match for each pattern to stdout.
Rewrite the config file parser to read the file only once.
diffstat:
pkgtools/pkg_install/files/admin/main.c | 31 ++++++++-
pkgtools/pkg_install/files/admin/pkg_admin.1 | 10 ++-
pkgtools/pkg_install/files/admin/pkg_admin.cat1 | 10 ++-
pkgtools/pkg_install/files/delete/pkg_delete.1 | 10 ++-
pkgtools/pkg_install/files/delete/pkg_delete.cat1 | 7 +-
pkgtools/pkg_install/files/lib/lib.h | 3 +-
pkgtools/pkg_install/files/lib/parse-config.c | 62 +++++++++++++++++---
pkgtools/pkg_install/files/lib/pkg_io.c | 69 ++++++++++++----------
pkgtools/pkg_install/files/lib/version.h | 4 +-
9 files changed, 149 insertions(+), 57 deletions(-)
diffs (truncated from 436 to 300 lines):
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/admin/main.c
--- a/pkgtools/pkg_install/files/admin/main.c Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/admin/main.c Sun Aug 16 21:10:14 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.54 2009/08/02 17:56:44 joerg Exp $ */
+/* $NetBSD: main.c,v 1.55 2009/08/16 21:10:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,10 +7,10 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: main.c,v 1.54 2009/08/02 17:56:44 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.55 2009/08/16 21:10:14 joerg Exp $");
/*-
- * Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -74,6 +74,7 @@
#ifndef BOOTSTRAP
#include <archive.h>
+#include <fetch.h>
#endif
#include "admin.h"
@@ -500,7 +501,6 @@
argv++;
}
-
} else if (strcasecmp(argv[0], "list") == 0 ||
strcasecmp(argv[0], "dump") == 0) {
@@ -559,7 +559,28 @@
}
}
#ifndef BOOTSTRAP
- else if (strcasecmp(argv[0], "fetch-pkg-vulnerabilities") == 0) {
+ else if (strcasecmp(argv[0], "findbest") == 0) {
+ struct url *url;
+ char *output;
+ int rc;
+
+ process_pkg_path();
+
+ rc = 0;
+ for (++argv; *argv != NULL; ++argv) {
+ url = find_best_package(NULL, *argv, 1);
+ if (url == NULL) {
+ rc = 1;
+ continue;
+ }
+ output = fetchStringifyURL(url);
+ puts(output);
+ fetchFreeURL(url);
+ free(output);
+ }
+
+ return rc;
+ } else if (strcasecmp(argv[0], "fetch-pkg-vulnerabilities") == 0) {
fetch_pkg_vulnerabilities(--argc, ++argv);
} else if (strcasecmp(argv[0], "check-pkg-vulnerabilities") == 0) {
check_pkg_vulnerabilities(--argc, ++argv);
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/admin/pkg_admin.1
--- a/pkgtools/pkg_install/files/admin/pkg_admin.1 Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/admin/pkg_admin.1 Sun Aug 16 21:10:14 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_admin.1,v 1.25 2009/06/03 20:03:40 joerg Exp $
+.\" $NetBSD: pkg_admin.1,v 1.26 2009/08/16 21:10:14 joerg Exp $
.\"
.\" Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 25, 2009
+.Dd August 16, 2009
.Dt PKG_ADMIN 1
.Os
.Sh NAME
@@ -205,6 +205,12 @@
.Fl u
is given, the fetch is conditional and the file transfer is only done if
the remote version is newer than the one in pkgdb.
+.It Cm findbest Ar pattern ...
+Search the entries of PKG_PATH for packages matching
+.Ar pattern .
+Print the URL of the best matching package to stdout for each pattern.
+If a pattern is not matched, it is skipped and the command will return
+a failure.
.It Cm lsall Ar /dir/pkgpattern
.It Cm lsbest Ar /dir/pkgpattern
List all/best package matching pattern in the given directory
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/admin/pkg_admin.cat1
--- a/pkgtools/pkg_install/files/admin/pkg_admin.cat1 Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/admin/pkg_admin.cat1 Sun Aug 16 21:10:14 2009 +0000
@@ -101,7 +101,7 @@
cchheecckk--ssiiggnnaattuurree _f_i_l_e _._._.
Reports if _f_i_l_e is a correctly signed package.
- cchheecckk--ssiinnggllee--lliicceennssee _l_i_c_c_e_n_s_e
+ cchheecckk--ssiinnggllee--lliicceennssee _l_i_c_e_n_s_e
Check if _l_i_c_e_n_s_e is a valid license name and if it is in the set
of acceptable licenses. Prints either yes or no to stdout if the
condition can be parsed, otherwise it exits with error.
@@ -127,6 +127,12 @@
transfer is only done if the remote version is newer than the one
in pkgdb.
+ ffiinnddbbeesstt _p_a_t_t_e_r_n _._._.
+ Search the entries of PKG_PATH for packages matching _p_a_t_t_e_r_n.
+ Print the URL of the best matching package to stdout for each
+ pattern. If a pattern is not matched, it is skipped and the com-
+ mand will return a failure.
+
llssaallll _/_d_i_r_/_p_k_g_p_a_t_t_e_r_n
llssbbeesstt _/_d_i_r_/_p_k_g_p_a_t_t_e_r_n
@@ -236,4 +242,4 @@
AAUUTTHHOORRSS
The ppkkgg__aaddmmiinn command was written by Hubert Feyrer.
-NetBSD 5.0 April 25, 2009 NetBSD 5.0
+NetBSD 5.0 August 16, 2009 NetBSD 5.0
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/delete/pkg_delete.1
--- a/pkgtools/pkg_install/files/delete/pkg_delete.1 Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.1 Sun Aug 16 21:10:14 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_delete.1,v 1.22 2009/08/06 18:15:27 wiz Exp $
+.\" $NetBSD: pkg_delete.1,v 1.23 2009/08/16 21:10:15 joerg Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -17,7 +17,7 @@
.\"
.\" from FreeBSD: @(#)pkg_delete.1
.\"
-.Dd August 6, 2009
+.Dd August 16, 2009
.Dt PKG_DELETE 1
.Os
.Sh NAME
@@ -127,6 +127,9 @@
.Cm preserved
package.
Note that this is a dangerous operation.
+See also the
+.Fl k
+option.
.It Fl K Ar pkg_dbdir
Set
.Ar pkg_dbdir
@@ -136,6 +139,9 @@
.Ev PKG_DBDIR
if it's set, otherwise it defaults to
.Pa /var/db/pkg .
+.It Fl k
+Silently skip all packages that are marked as
+.Cm preserved .
.It Fl N
Remove the package's registration and its entries from the package database,
but leave the files installed.
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/delete/pkg_delete.cat1
--- a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 Sun Aug 16 21:10:14 2009 +0000
@@ -58,7 +58,8 @@
the deinstall script fails.
--ffff Force removal of the package, even if the package is marked as a
- pprreesseerrvveedd package. Note that this is a dangerous operation.
+ pprreesseerrvveedd package. Note that this is a dangerous operation. See
+ also the --kk option.
--KK _p_k_g___d_b_d_i_r
Set _p_k_g___d_b_d_i_r as the package database directory. If this option
@@ -66,6 +67,8 @@
from the value of the environment variable PKG_DBDIR if it's set,
otherwise it defaults to _/_v_a_r_/_d_b_/_p_k_g.
+ --kk Silently skip all packages that are marked as pprreesseerrvveedd.
+
--NN Remove the package's registration and its entries from the pack-
age database, but leave the files installed. Don't run any dein-
stall scripts or @unexec lines either.
@@ -169,4 +172,4 @@
Rewrote most of the code to compute correct order of deinstalla-
tion and to improve error handling.
-NetBSD 5.0 August 6, 2009 NetBSD 5.0
+NetBSD 5.0 August 16, 2009 NetBSD 5.0
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/lib/lib.h
--- a/pkgtools/pkg_install/files/lib/lib.h Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/lib.h Sun Aug 16 21:10:14 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.57 2009/08/06 16:53:34 joerg Exp $ */
+/* $NetBSD: lib.h,v 1.58 2009/08/16 21:10:15 joerg Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -324,6 +324,7 @@
struct archive *open_archive(const char *);
struct archive *find_archive(const char *, int);
void process_pkg_path(void);
+struct url *find_best_package(const char *, const char *, int);
/* Packing list */
plist_t *new_plist_entry(void);
diff -r 36b53e5716ac -r 4fa64ccb8986 pkgtools/pkg_install/files/lib/parse-config.c
--- a/pkgtools/pkg_install/files/lib/parse-config.c Sun Aug 16 20:31:29 2009 +0000
+++ b/pkgtools/pkg_install/files/lib/parse-config.c Sun Aug 16 21:10:14 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse-config.c,v 1.7 2009/08/16 14:26:46 joerg Exp $ */
+/* $NetBSD: parse-config.c,v 1.8 2009/08/16 21:10:15 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,10 +7,10 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: parse-config.c,v 1.7 2009/08/16 14:26:46 joerg Exp $");
+__RCSID("$NetBSD: parse-config.c,v 1.8 2009/08/16 21:10:15 joerg Exp $");
/*-
- * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#if HAVE_ERR_H
#include <err.h>
#endif
+#include <errno.h>
#if HAVE_STRING_H
#include <string.h>
#endif
@@ -99,17 +100,58 @@
{ NULL, NULL }
};
+char *config_tmp_variables[sizeof config_variables/sizeof config_variables[0]];
+
+static void
+parse_pkg_install_conf(void)
+{
+ struct config_variable *var;
+ FILE *fp;
+ char *line, *value;
+ size_t len, var_len, i;
+
+ fp = fopen(config_file, "r");
+ if (!fp) {
+ if (errno != ENOENT)
+ warn("Can't open '%s' for reading", config_file);
+ return;
+ }
+
+ while ((line = fgetln(fp, &len)) != (char *) NULL) {
+ if (line[len - 1] == '\n')
+ --len;
+ for (i = 0; (var = &config_variables[i])->name != NULL; ++i) {
+ var_len = strlen(var->name);
+ if (strncmp(var->name, line, var_len) != 0)
+ continue;
+ if (line[var_len] != '=')
+ continue;
+ line += var_len + 1;
+ len -= var_len + 1;
+ if (config_tmp_variables[i])
+ value = xasprintf("%s\n%.*s",
+ config_tmp_variables[i], (int)len, line);
+ else
+ value = xasprintf("%.*s", (int)len, line);
+ free(config_tmp_variables[i]);
+ config_tmp_variables[i] = value;
+ break;
+ }
+ }
+
+ for (i = 0; (var = &config_variables[i])->name != NULL; ++i) {
+ if (config_tmp_variables[i] == NULL)
+ continue;
+ *var->var = config_tmp_variables[i];
+ config_tmp_variables[i] = NULL;
+ }
+}
+
void
pkg_install_config(void)
{
char *value;
- struct config_variable *var;
-
Home |
Main Index |
Thread Index |
Old Index