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
This commit is contained in:
parent
31cc468089
commit
e5f518a9dd
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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 **);
|
||||
|
38
usr.sbin/pkg_install/lib/pkgng.c
Normal file
38
usr.sbin/pkg_install/lib/pkgng.c
Normal file
@ -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");
|
||||
}
|
@ -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':
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user