|
|
@@ -4,6 +4,8 @@
|
|
|
*
|
|
|
* Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
|
|
|
* Copyright © 2006,2008-2012 Guillem Jover <guillem@debian.org>
|
|
|
+ * Copyright © 2011 Linaro Limited
|
|
|
+ * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
|
|
|
*
|
|
|
* This is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
@@ -33,6 +35,7 @@
|
|
|
#include <dpkg/dpkg-db.h>
|
|
|
#include <dpkg/pkg-array.h>
|
|
|
#include <dpkg/pkg-show.h>
|
|
|
+#include <dpkg/pkg-spec.h>
|
|
|
#include <dpkg/options.h>
|
|
|
|
|
|
#include "filesdb.h"
|
|
|
@@ -72,15 +75,22 @@ getselections(const char *const *argv)
|
|
|
}
|
|
|
} else {
|
|
|
while ((thisarg= *argv++)) {
|
|
|
+ struct pkg_spec pkgspec;
|
|
|
+
|
|
|
found= 0;
|
|
|
+ pkg_spec_init(&pkgspec, psf_patterns | psf_arch_def_wildcard);
|
|
|
+ pkg_spec_parse(&pkgspec, thisarg);
|
|
|
+
|
|
|
for (i = 0; i < array.n_pkgs; i++) {
|
|
|
pkg = array.pkgs[i];
|
|
|
- if (fnmatch(thisarg, pkg->set->name, 0))
|
|
|
+ if (!pkg_spec_match_pkg(&pkgspec, pkg, &pkg->installed))
|
|
|
continue;
|
|
|
getsel1package(pkg); found++;
|
|
|
}
|
|
|
if (!found)
|
|
|
fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
|
|
|
+
|
|
|
+ pkg_spec_destroy(&pkgspec);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -97,7 +107,6 @@ setselections(const char *const *argv)
|
|
|
{
|
|
|
const struct namevalue *nv;
|
|
|
struct pkginfo *pkg;
|
|
|
- const char *e;
|
|
|
int c, lno;
|
|
|
struct varbuf namevb = VARBUF_INIT;
|
|
|
struct varbuf selvb = VARBUF_INIT;
|
|
|
@@ -109,6 +118,8 @@ setselections(const char *const *argv)
|
|
|
|
|
|
lno= 1;
|
|
|
for (;;) {
|
|
|
+ struct dpkg_error err;
|
|
|
+
|
|
|
do { c= getchar(); if (c == '\n') lno++; } while (c != EOF && isspace(c));
|
|
|
if (c == EOF) break;
|
|
|
if (c == '#') {
|
|
|
@@ -143,13 +154,14 @@ setselections(const char *const *argv)
|
|
|
if (!isspace(c))
|
|
|
ohshit(_("unexpected data after package and selection at line %d"),lno);
|
|
|
}
|
|
|
- e = pkg_name_is_illegal(namevb.buf);
|
|
|
- if (e) ohshit(_("illegal package name at line %d: %.250s"),lno,e);
|
|
|
+ pkg = pkg_spec_parse_pkg(namevb.buf, &err);
|
|
|
+ if (pkg == NULL)
|
|
|
+ ohshit(_("illegal package name at line %d: %.250s"), lno, err.str);
|
|
|
|
|
|
nv = namevalue_find_by_name(wantinfos, selvb.buf);
|
|
|
if (nv == NULL)
|
|
|
ohshit(_("unknown wanted status at line %d: %.250s"), lno, selvb.buf);
|
|
|
- pkg = pkg_db_find(namevb.buf);
|
|
|
+
|
|
|
pkg_set_want(pkg, nv->value);
|
|
|
if (c == EOF) break;
|
|
|
lno++;
|