[Midnightbsd-cvs] src [6779] trunk/usr.sbin/mport: teach mport command about cpe
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 21 14:02:06 EDT 2014
Revision: 6779
http://svnweb.midnightbsd.org/src/?rev=6779
Author: laffer1
Date: 2014-09-21 14:02:05 -0400 (Sun, 21 Sep 2014)
Log Message:
-----------
teach mport command about cpe
Modified Paths:
--------------
trunk/usr.sbin/mport/mport.1
trunk/usr.sbin/mport/mport.c
Modified: trunk/usr.sbin/mport/mport.1
===================================================================
--- trunk/usr.sbin/mport/mport.1 2014-09-21 17:47:19 UTC (rev 6778)
+++ trunk/usr.sbin/mport/mport.1 2014-09-21 18:02:05 UTC (rev 6779)
@@ -34,6 +34,8 @@
.Nm
.Cm clean
.Nm
+.Cm cpe
+.Nm
.Cm list
.Ar updates
.Nm
@@ -71,6 +73,8 @@
.It Cm clean
Clean up old packages not found in the index and perform maintenence on the
database.
+.It Cm cpe
+List all CPE information for each installed package
.It Cm list
List all currently installed packages
.It Cm info
Modified: trunk/usr.sbin/mport/mport.c
===================================================================
--- trunk/usr.sbin/mport/mport.c 2014-09-21 17:47:19 UTC (rev 6778)
+++ trunk/usr.sbin/mport/mport.c 2014-09-21 18:02:05 UTC (rev 6779)
@@ -43,6 +43,7 @@
static mportIndexEntry ** lookupIndex(mportInstance *, const char *);
static int install_depends(mportInstance *, const char *, const char *);
static int install(mportInstance *, const char *);
+static int cpeList(mportInstance *);
static int delete(const char *);
static int deleteAll(mportInstance *);
static int download(mportInstance *, const char *);
@@ -144,6 +145,8 @@
free(searchQuery);
} else if (!strcmp(argv[1], "clean")) {
resultCode = clean(mport);
+ } else if (!strcmp(argv[1], "cpe")) {
+ resultCode = cpeList(mport);
} else if (!strcmp(argv[1], "deleteall")) {
resultCode = deleteAll(mport);
} else if (!strcmp(argv[1], "verify")) {
@@ -163,6 +166,7 @@
fprintf(stderr,
"usage: mport <command> args:\n"
" mport clean\n"
+ " mport cpe\n"
" mport delete [package name]\n"
" mport deleteall\n"
" mport download [package name]\n"
@@ -235,6 +239,7 @@
mportPackageMeta **packs;
char *status, *origin;
char *os_release;
+ char *cpe;
if (packageName == NULL) {
warnx("%s", "Specify package name");
@@ -256,13 +261,15 @@
status = strdup("N/A");
origin = strdup("");
os_release = strdup("");
+ cpe = strdup("");
} else {
status = (*packs)->version;
origin = (*packs)->origin;
os_release = (*packs)->os_release;
+ cpe = (*packs)->cpe;
}
- printf("%s\nlatest: %s\ninstalled: %s\nlicense: %s\norigin: %s\nos: %s\n\n%s\n",
+ printf("%s\nlatest: %s\ninstalled: %s\nlicense: %s\norigin: %s\nos: %s\n\n%s\ncpe: %s\n",
(*indexEntry)->pkgname,
(*indexEntry)->version,
status,
@@ -269,11 +276,14 @@
(*indexEntry)->license,
origin,
os_release,
- (*indexEntry)->comment);
+ (*indexEntry)->comment,
+ cpe);
if (packs == NULL) {
free(status);
free(origin);
+ free(os_release);
+ free(cpe);
} else
mport_pkgmeta_vec_free(packs);
@@ -485,6 +495,31 @@
}
int
+cpeList(mportInstance *mport) {
+ mportPackageMeta **packs;
+
+ if (mport_pkgmeta_list(mport, &packs) != MPORT_OK) {
+ warnx("%s", mport_err_string());
+ return mport_err_code();
+ }
+
+ if (packs == NULL) {
+ warnx("No packages installed.");
+ return (1);
+ }
+
+ while (*packs != NULL) {
+ if ((*packs)->cpe != NULL)
+ printf("%s\n", (*packs)->cpe);
+ packs++;
+ }
+
+ mport_pkgmeta_vec_free(packs);
+
+ return (0);
+}
+
+int
verify(mportInstance *mport) {
mportPackageMeta **packs;
int total = 0;
More information about the Midnightbsd-cvs
mailing list