pkgng.c revision 243554
1243553Seadler/*-
2243553Seadler * Copyright (c) 2012 Eitan Adler
3243553Seadler * All rights reserved.
4241830Seadler *
5241830Seadler * Redistribution and use in source and binary forms, with or without
6241830Seadler * modification, are permitted provided that the following conditions
7241830Seadler * are met:
8241830Seadler * 1. Redistributions of source code must retain the above copyright
9241830Seadler *    notice, this list of conditions and the following disclaimer.
10241830Seadler * 2. Redistributions in binary form must reproduce the above copyright
11241830Seadler *    notice, this list of conditions and the following disclaimer in the
12241830Seadler *    documentation and/or other materials provided with the distribution.
13241830Seadler *
14243553Seadler * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15243553Seadler * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16243553Seadler * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17243553Seadler * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18243553Seadler * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19243553Seadler * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20243553Seadler * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21243553Seadler * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22243553Seadler * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23243553Seadler * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24243553Seadler * SUCH DAMAGE.
25241830Seadler *
26243553Seadler * $FreeBSD: head/usr.sbin/pkg_install/lib/pkgng.c 243554 2012-11-26 05:11:07Z eadler $
27241830Seadler */
28241830Seadler
29241830Seadler#include <sys/cdefs.h>
30241830Seadler
31241830Seadler#include "lib.h"
32241830Seadler#include <err.h>
33241830Seadler
34243553Seadlerstatic const char message[] = "You appear to be using the newer pkg(1) tool on \
35243553Seadlerthis system for package management, rather than the legacy package \
36243553Seadlermanagement tools (pkg_*).  The legacy tools should no longer be used on \
37243553Seadlerthis system.";
38243553Seadler
39243553Seadlervoid warnpkgng(void)
40243553Seadler{
41241830Seadler	char pkgngpath[MAXPATHLEN];
42241830Seadler	char *pkgngdir;
43243554Seadler	char *dontwarn;
44241830Seadler
45243554Seadler	dontwarn = getenv("PKG_OLD_NOWARN");
46243554Seadler	if (dontwarn != NULL)
47243554Seadler		return;
48241830Seadler	pkgngdir = getenv("PKG_DBDIR");
49241830Seadler	if (pkgngdir == NULL)
50241830Seadler		pkgngdir = "/var/db/pkg";
51241830Seadler	strcpy(pkgngpath, pkgngdir);
52241830Seadler	strcat(pkgngpath, "/local.sqlite");
53241830Seadler
54241830Seadler	if (access(pkgngpath, F_OK) == 0)
55243553Seadler		warnx(message);
56241830Seadler}
57