summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-10-22 02:12:20 +0000
committereadler <eadler@FreeBSD.org>2012-10-22 02:12:20 +0000
commite5f518a9dd260cb94bcfbdd98fbe683711e64da9 (patch)
tree4e0f1821028021b1a63d6187f93efe43cb81b143
parent31cc468089c6b473ff4b45e12a56b670af20fbfc (diff)
downloadFreeBSD-src-e5f518a9dd260cb94bcfbdd98fbe683711e64da9.zip
FreeBSD-src-e5f518a9dd260cb94bcfbdd98fbe683711e64da9.tar.gz
Warn users when using pkg tools if it looks like they
be be pkgng users. Reviewed by: bapt (earlier version) Reviewed by: kwm Approved by: cperciva MFC after: 3 days
-rw-r--r--usr.sbin/pkg_install/add/main.c1
-rw-r--r--usr.sbin/pkg_install/create/main.c1
-rw-r--r--usr.sbin/pkg_install/delete/main.c1
-rw-r--r--usr.sbin/pkg_install/info/main.c1
-rw-r--r--usr.sbin/pkg_install/lib/Makefile2
-rw-r--r--usr.sbin/pkg_install/lib/lib.h1
-rw-r--r--usr.sbin/pkg_install/lib/pkgng.c38
-rw-r--r--usr.sbin/pkg_install/updating/main.c1
-rw-r--r--usr.sbin/pkg_install/version/main.c1
9 files changed, 46 insertions, 1 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 5932e1a..94ef127 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -135,6 +135,7 @@ main(int argc, char **argv)
static char temppackageroot[MAXPATHLEN];
static char pkgaddpath[MAXPATHLEN];
+ warnpkgng();
if (*argv[0] != '/' && strchr(argv[0], '/') != NULL)
PkgAddCmd = realpath(argv[0], pkgaddpath);
else
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index 5b5ecb2..4f68697 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -72,6 +72,7 @@ main(int argc, char **argv)
int ch;
char **pkgs, **start, *tmp;
+ warnpkgng();
pkgs = start = argv;
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c
index 7cd4677..0b97ddd 100644
--- a/usr.sbin/pkg_install/delete/main.c
+++ b/usr.sbin/pkg_install/delete/main.c
@@ -67,6 +67,7 @@ main(int argc, char **argv)
const char *tmp;
struct stat stat_s;
+ warnpkgng();
pkgs = start = argv;
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 6692148..ff2ea79 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -68,6 +68,7 @@ main(int argc, char **argv)
char **pkgs, **start;
char *pkgs_split;
+ warnpkgng();
whead = malloc(sizeof(struct which_head));
if (whead == NULL)
err(2, NULL);
diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile
index 84a41b8..12cc307 100644
--- a/usr.sbin/pkg_install/lib/Makefile
+++ b/usr.sbin/pkg_install/lib/Makefile
@@ -3,7 +3,7 @@
LIB= install
INTERNALLIB=
SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c match.c \
- deps.c version.c pkgwrap.c url.c
+ deps.c version.c pkgwrap.c url.c pkgng.c
WARNS?= 3
WFORMAT?= 1
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index a6935ad..88fcf34 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -157,6 +157,7 @@ const char *make_playpen(char *, off_t);
char *where_playpen(void);
int leave_playpen(void);
off_t min_free(const char *);
+void warnpkgng(void);
/* String */
char *get_dash_string(char **);
diff --git a/usr.sbin/pkg_install/lib/pkgng.c b/usr.sbin/pkg_install/lib/pkgng.c
new file mode 100644
index 0000000..76c8ad8
--- /dev/null
+++ b/usr.sbin/pkg_install/lib/pkgng.c
@@ -0,0 +1,38 @@
+/*
+ * FreeBSD install - a package for the installation and maintenance
+ * of non-core utilities.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Eitan Adler
+ *
+ * detect pkgng's existence and warn
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "lib.h"
+#include <err.h>
+
+void warnpkgng(void) {
+ char pkgngpath[MAXPATHLEN];
+ char *pkgngdir;
+
+ pkgngdir = getenv("PKG_DBDIR");
+ if (pkgngdir == NULL)
+ pkgngdir = "/var/db/pkg";
+ strcpy(pkgngpath, pkgngdir);
+ strcat(pkgngpath, "/local.sqlite");
+
+ if (access(pkgngpath, F_OK) == 0)
+ warnx("Don't use the pkg_ tools if you are using pkgng");
+}
diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c
index e7a840f..4a36e22 100644
--- a/usr.sbin/pkg_install/updating/main.c
+++ b/usr.sbin/pkg_install/updating/main.c
@@ -87,6 +87,7 @@ main(int argc, char *argv[])
DIR *dir;
FILE *fd;
+ warnpkgng();
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch (ch) {
case 'd':
diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c
index 39c603e..dd67e63 100644
--- a/usr.sbin/pkg_install/version/main.c
+++ b/usr.sbin/pkg_install/version/main.c
@@ -58,6 +58,7 @@ main(int argc, char **argv)
{
int ch, cmp = 0;
+ warnpkgng();
if (argc == 4 && !strcmp(argv[1], "-t")) {
cmp = version_cmp(argv[2], argv[3]);
printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n"));
OpenPOWER on IntegriCloud