From owner-svn-src-all@FreeBSD.ORG Mon Oct 22 02:12:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E79DC848; Mon, 22 Oct 2012 02:12:20 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CD7488FC16; Mon, 22 Oct 2012 02:12:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9M2CKLY008079; Mon, 22 Oct 2012 02:12:20 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9M2CKKP008069; Mon, 22 Oct 2012 02:12:20 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201210220212.q9M2CKKP008069@svn.freebsd.org> From: Eitan Adler Date: Mon, 22 Oct 2012 02:12:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241830 - in head/usr.sbin/pkg_install: add create delete info lib updating version X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Oct 2012 02:12:21 -0000 Author: eadler Date: Mon Oct 22 02:12:20 2012 New Revision: 241830 URL: http://svn.freebsd.org/changeset/base/241830 Log: 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 Added: head/usr.sbin/pkg_install/lib/pkgng.c (contents, props changed) Modified: head/usr.sbin/pkg_install/add/main.c head/usr.sbin/pkg_install/create/main.c head/usr.sbin/pkg_install/delete/main.c head/usr.sbin/pkg_install/info/main.c head/usr.sbin/pkg_install/lib/Makefile head/usr.sbin/pkg_install/lib/lib.h head/usr.sbin/pkg_install/updating/main.c head/usr.sbin/pkg_install/version/main.c Modified: head/usr.sbin/pkg_install/add/main.c ============================================================================== --- head/usr.sbin/pkg_install/add/main.c Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/add/main.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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 Modified: head/usr.sbin/pkg_install/create/main.c ============================================================================== --- head/usr.sbin/pkg_install/create/main.c Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/create/main.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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) { Modified: head/usr.sbin/pkg_install/delete/main.c ============================================================================== --- head/usr.sbin/pkg_install/delete/main.c Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/delete/main.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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) { Modified: head/usr.sbin/pkg_install/info/main.c ============================================================================== --- head/usr.sbin/pkg_install/info/main.c Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/info/main.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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); Modified: head/usr.sbin/pkg_install/lib/Makefile ============================================================================== --- head/usr.sbin/pkg_install/lib/Makefile Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/lib/Makefile Mon Oct 22 02:12:20 2012 (r241830) @@ -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 Modified: head/usr.sbin/pkg_install/lib/lib.h ============================================================================== --- head/usr.sbin/pkg_install/lib/lib.h Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/lib/lib.h Mon Oct 22 02:12:20 2012 (r241830) @@ -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 **); Added: head/usr.sbin/pkg_install/lib/pkgng.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pkg_install/lib/pkgng.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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 +__FBSDID("$FreeBSD$"); + +#include "lib.h" +#include + +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"); +} Modified: head/usr.sbin/pkg_install/updating/main.c ============================================================================== --- head/usr.sbin/pkg_install/updating/main.c Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/updating/main.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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': Modified: head/usr.sbin/pkg_install/version/main.c ============================================================================== --- head/usr.sbin/pkg_install/version/main.c Mon Oct 22 02:12:15 2012 (r241829) +++ head/usr.sbin/pkg_install/version/main.c Mon Oct 22 02:12:20 2012 (r241830) @@ -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"));