Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Apr 2010 11:07:43 +0000 (UTC)
From:      Florent Thoumie <flz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r207113 - in head: . lib lib/libpkg share/mk usr.sbin/pkg_install usr.sbin/pkg_install/add usr.sbin/pkg_install/create usr.sbin/pkg_install/delete usr.sbin/pkg_install/info usr.sbin/pkg...
Message-ID:  <201004231107.o3NB7h2a080365@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: flz
Date: Fri Apr 23 11:07:43 2010
New Revision: 207113
URL: http://svn.freebsd.org/changeset/base/207113

Log:
  - Take libinstall.a out of pkg_install and make it a proper shared library.
  - Rework the wrapper support to check libpkg version as well as pkg_install
  version.
  - Add libfetch to _prebuild_libs.
  - There are no new features introduced.
  
  Notes: the API is not stable, so basically, do not use libpkg in your
  projects for now. Also there's no manpage for libpkg yet, because the API
  will change drastically. I repeat, do not use libpkg for now.

Added:
  head/lib/libpkg/
     - copied from r206135, head/usr.sbin/pkg_install/lib/
  head/lib/libpkg/pkg.h
     - copied, changed from r206135, head/usr.sbin/pkg_install/lib/lib.h
Deleted:
  head/lib/libpkg/lib.h
  head/usr.sbin/pkg_install/lib/
Modified:
  head/Makefile.inc1
  head/lib/Makefile
  head/lib/libpkg/Makefile
  head/lib/libpkg/deps.c
  head/lib/libpkg/exec.c
  head/lib/libpkg/file.c
  head/lib/libpkg/global.c
  head/lib/libpkg/match.c
  head/lib/libpkg/msg.c
  head/lib/libpkg/pen.c
  head/lib/libpkg/pkgwrap.c
  head/lib/libpkg/plist.c
  head/lib/libpkg/str.c
  head/lib/libpkg/url.c
  head/lib/libpkg/version.c
  head/share/mk/bsd.libnames.mk
  head/usr.sbin/pkg_install/Makefile
  head/usr.sbin/pkg_install/Makefile.inc
  head/usr.sbin/pkg_install/add/Makefile
  head/usr.sbin/pkg_install/add/extract.c
  head/usr.sbin/pkg_install/add/futil.c
  head/usr.sbin/pkg_install/add/main.c
  head/usr.sbin/pkg_install/add/perform.c
  head/usr.sbin/pkg_install/create/Makefile
  head/usr.sbin/pkg_install/create/main.c
  head/usr.sbin/pkg_install/create/perform.c
  head/usr.sbin/pkg_install/create/pl.c
  head/usr.sbin/pkg_install/delete/Makefile
  head/usr.sbin/pkg_install/delete/main.c
  head/usr.sbin/pkg_install/delete/perform.c
  head/usr.sbin/pkg_install/info/Makefile
  head/usr.sbin/pkg_install/info/info.h
  head/usr.sbin/pkg_install/info/main.c
  head/usr.sbin/pkg_install/info/perform.c
  head/usr.sbin/pkg_install/info/show.c
  head/usr.sbin/pkg_install/updating/Makefile
  head/usr.sbin/pkg_install/updating/main.c
  head/usr.sbin/pkg_install/version/Makefile
  head/usr.sbin/pkg_install/version/main.c
  head/usr.sbin/pkg_install/version/perform.c

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/Makefile.inc1	Fri Apr 23 11:07:43 2010	(r207113)
@@ -1111,7 +1111,7 @@ _prebuild_libs=	${_kerberos5_lib_libasn1
 		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
 		${_kerberos5_lib_libroken} \
 		lib/libbz2 lib/libcom_err lib/libcrypt \
-		lib/libexpat \
+		lib/libexpat lib/libfetch \
 		${_lib_libgssapi} ${_lib_libipx} \
 		lib/libkiconv lib/libkvm lib/libmd \
 		lib/ncurses/ncurses lib/ncurses/ncursesw \
@@ -1138,6 +1138,7 @@ _cddl_lib= cddl/lib
 _secure_lib_libcrypto= secure/lib/libcrypto
 _secure_lib_libssl= secure/lib/libssl
 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
+lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L
 .if ${MK_OPENSSH} != "no"
 _secure_lib_libssh= secure/lib/libssh
 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
@@ -1173,7 +1174,7 @@ _lib_libypclnt=	lib/libypclnt
 .endif
 
 .if ${MK_OPENSSL} == "no"
-lib/libradius__L: lib/libmd__L
+lib/libfetch__L lib/libradius__L: lib/libmd__L
 .endif
 
 .for _lib in ${_prereq_libs}

Modified: head/lib/Makefile
==============================================================================
--- head/lib/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/lib/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -85,6 +85,7 @@ SUBDIR=	${SUBDIR_ORDERED} \
 	libopie \
 	libpam \
 	libpcap \
+	${_libpkg} \
 	${_libpmc} \
 	libproc \
 	librt \
@@ -197,6 +198,10 @@ _libmp=		libmp
 _libpmc=	libpmc
 .endif
 
+.if ${MK_PKGTOOLS} != "no"
+_libpkg=	libpkg
+.endif
+
 .if ${MK_SENDMAIL} != "no"
 _libmilter=	libmilter
 _libsm=		libsm

Modified: head/lib/libpkg/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/lib/Makefile	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -1,11 +1,47 @@
 # $FreeBSD$
 
-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
+.include <bsd.own.mk>
 
-WARNS?=	3
-WFORMAT?=	1
+LIB=		pkg
+
+SHLIBDIR?=	/usr/lib
+SHLIB_MAJOR=	0
+
+SRCS=		deps.c		\
+		exec.c		\
+		file.c		\
+		global.c	\
+		match.c		\
+		msg.c		\
+		pen.c		\
+		pkgwrap.c	\
+		plist.c		\
+		str.c		\
+		url.c		\
+		version.c
+INCS=		pkg.h
+
+CFLAGS+=	-DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE
+
+DPADD=		${LIBFETCH} ${LIBMD} ${LIBUTIL}
+LDADD=		-lfetch -lmd -lutil
+
+.if ${MK_OPENSSL} != "no"
+DPADD+=         ${LIBSSL} ${LIBCRYPTO}
+LDADD+=         -lssl -lcrypto
+.endif
+
+WARNS?=		3
+
+DATE!= grep LIBPKG_VERSION ${.CURDIR}/pkg.h | sed 's|.*[      ]||'
+
+distfile: clean
+	@(cd ${.CURDIR}/..; \
+		cp -r libpkg libpkg-${DATE}; \
+		tar -czf libpkg/libpkg-${DATE}.tar.gz \
+			--exclude .#* --exclude *~ --exclude CVS \
+			--exclude .svn --exclude libpkg-*.tar.gz \
+			libpkg-${DATE}; \
+		rm -rf libpkg-${DATE})
 
 .include <bsd.lib.mk>

Modified: head/lib/libpkg/deps.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/deps.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/deps.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -22,7 +22,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <stdio.h>
 

Modified: head/lib/libpkg/exec.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/exec.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/exec.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 
 /*

Modified: head/lib/libpkg/file.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/file.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/file.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <pwd.h>
 #include <time.h>

Modified: head/lib/libpkg/global.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/global.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/global.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -22,7 +22,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 
 /* These are global for all utils */
 Boolean	Quiet		= FALSE;

Modified: head/lib/libpkg/match.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/match.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/match.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <fnmatch.h>
 #include <fts.h>
@@ -292,7 +292,7 @@ matchallbyorigin(const char **origins, i
 		break;
 	    }
 	}
-	if (cmd != PLIST_ORIGIN && ( Verbose || 0 != strncmp("bsdpan-", installed[i], 7 ) ) )
+	if (cmd != PLIST_ORIGIN && 0 != strncmp("bsdpan-", installed[i], 7))
 	    warnx("package %s has no origin recorded", installed[i]);
 	fclose(fp);
     }

Modified: head/lib/libpkg/msg.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/msg.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/msg.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <paths.h>
 
@@ -61,12 +61,7 @@ y_or_n(Boolean def, const char *msg, ...
 	else
 	    fprintf(stderr, " [no]? ");
 	fflush(stderr);
-	if (AutoAnswer) {
-	    ch = (AutoAnswer == YES) ? 'Y' : 'N';
-	    fprintf(stderr, "%c\n", ch);
-	}
-	else
-	    ch = toupper(fgetc(tty));
+	ch = toupper(fgetc(tty));
 	if (ch == '\n')
 	    ch = (def) ? 'Y' : 'N';
     }

Modified: head/lib/libpkg/pen.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/pen.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/pen.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <libutil.h>
 #include <libgen.h>
@@ -103,7 +103,7 @@ popPen(char *pen)
 const char *
 make_playpen(char *pen, off_t sz)
 {
-    char humbuf1[6], humbuf2[6];
+    char humbuf[6];
     char cwd[FILENAME_MAX];
 
     if (!find_play_pen(pen, sz))
@@ -114,22 +114,15 @@ make_playpen(char *pen, off_t sz)
 	errx(2, "%s: can't mktemp '%s'", __func__, pen);
     }
 
-    if (Verbose) {
-	if (sz) {
-	    humanize_number(humbuf1, sizeof humbuf1, sz, "", HN_AUTOSCALE,
-	        HN_NOSPACE);
-	    humanize_number(humbuf2, sizeof humbuf2, min_free(pen),
-	        "", HN_AUTOSCALE, HN_NOSPACE);
-	    fprintf(stderr, "Requested space: %s bytes, free space: %s bytes in %s\n", humbuf1, humbuf2, pen);
-	}
-    }
+    humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE, HN_NOSPACE);
 
     if (min_free(pen) < sz) {
 	rmdir(pen);
 	cleanup(0);
 	errx(2, "%s: not enough free space to create '%s'.\n"
 	     "Please set your PKG_TMPDIR environment variable to a location\n"
-	     "with more space and\ntry the command again", __func__, pen);
+	     "with at least %s and try the command again",
+	     __func__, humbuf, pen);
     }
 
     if (!getcwd(cwd, FILENAME_MAX)) {

Copied and modified: head/lib/libpkg/pkg.h (from r206135, head/usr.sbin/pkg_install/lib/lib.h)
==============================================================================
--- head/usr.sbin/pkg_install/lib/lib.h	Sat Apr  3 11:19:20 2010	(r206135, copy source)
+++ head/lib/libpkg/pkg.h	Fri Apr 23 11:07:43 2010	(r207113)
@@ -23,6 +23,10 @@
 #ifndef _INST_LIB_LIB_H_
 #define _INST_LIB_LIB_H_
 
+#ifndef YES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE
+#error "You obviously have no idea what you're doing."
+#endif
+
 /* Includes */
 #include <sys/param.h>
 #include <sys/file.h>
@@ -96,13 +100,12 @@
 #define PKG_PREFIX_VNAME	"PKG_PREFIX"
 
 /*
- * Version of the package tools - increase whenever you make a change
+ * Version of the package library - increase whenever you make a change
  * in the code that is not cosmetic only.
  */
-#define PKG_INSTALL_VERSION	20100403
+#define LIBPKG_VERSION 20100423
 
 #define PKG_WRAPCONF_FNAME	"/var/db/pkg_install.conf"
-#define main(argc, argv)	real_main(argc, argv)
 
 /* Version numbers to assist with changes in package file format */
 #define PLIST_FMT_VER_MAJOR	1
@@ -214,7 +217,7 @@ Boolean 	make_preserve_name(char *, int,
 
 /* For all */
 int		pkg_perform(char **);
-int		real_main(int, char **);
+void		pkg_wrap(long, char **);
 
 /* Query installed packages */
 char		**matchinstalled(match_t, char **, int *);
@@ -229,6 +232,7 @@ int		chkifdepends(const char *, const ch
 int		requiredby(const char *, struct reqr_by_head **, Boolean, Boolean);
 
 /* Version */
+int		libpkg_version(void);
 int		verscmp(Package *, int, int);
 int		version_cmp(const char *, const char *);
 

Modified: head/lib/libpkg/pkgwrap.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/pkgwrap.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/pkgwrap.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -19,71 +19,72 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
-#undef main
-
-#define SEPARATORS " \t"
-
 extern char **environ;
 
-int
-main(int argc, char **argv)
+void
+pkg_wrap(long curver, char **argv)
 {
-    FILE *f;
-    char buffer[FILENAME_MAX], *cp, *verstr;
-    int len;
+    FILE* f;
+    char ver[9];			/* Format is: 'YYYYMMDD\0' */
+    char buffer[FILENAME_MAX+10];	/* Format is: 'YYYYMMDD <path>' */
+    char cmd[FILENAME_MAX+5];		/* Format is: '<path> -PPq' */
+    char *path, *cp;
+    long ptver, lpver;
 
     if (getenv("PKG_NOWRAP") != NULL)
 	goto nowrap;
-    f = fopen(PKG_WRAPCONF_FNAME, "r");
-    if (f == NULL)
-	goto nowrap;
-    cp = fgets(buffer, 256, f);
-    fclose(f);
-    if (cp == NULL)
-	goto nowrap;
-    len = strlen(cp);
-    if (cp[len - 1] == '\n')
-	cp[len - 1] = '\0';
-    while (strchr(SEPARATORS, *cp) != NULL)
-	cp++;
-    verstr = cp;
-    cp = strpbrk(cp, SEPARATORS);
-    if (cp == NULL)
+
+    setenv("PKG_NOWRAP", "1", 1);
+
+    /* Get alternative location for package tools. */
+    if ((f = fopen(PKG_WRAPCONF_FNAME, "r")) == NULL) {
 	goto nowrap;
-    *cp = '\0';
-    for (cp = verstr; *cp != '\0'; cp++)
-	if (isdigit(*cp) == 0)
+    } else {
+	if (get_string(buffer, FILENAME_MAX+9, f) == NULL) {
 	    goto nowrap;
-    if (atoi(verstr) < PKG_INSTALL_VERSION)
-	goto nowrap;
-    cp++;
-    while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL)
-	cp++;
-    if (*cp == '\0')
-	goto nowrap;
-    bcopy(cp, buffer, strlen(cp) + 1);
-    cp = strpbrk(buffer, SEPARATORS);
-    if (cp != NULL)
-	*cp = '\0';
-    if (!isdir(buffer))
-	goto nowrap;
-    cp = strrchr(argv[0], '/');
-    if (cp == NULL)
+	} else {
+	    if ((path = strrchr(buffer, ' ')) == NULL) {
+		goto nowrap;
+	    } else {
+		*path++ = '\0';
+	    }
+	}
+    }
+
+    if ((cp = strrchr(argv[0], '/')) == NULL) {
 	cp = argv[0];
-    else
+    } else {
 	cp++;
-    strlcat(buffer, "/", sizeof(buffer));
-    strlcat(buffer, cp, sizeof(buffer));
-    setenv("PKG_NOWRAP", "1", 1);
-    execve(buffer, argv, environ);
+    }
+
+    /* Get version of the other pkg_install and libpkg */
+    snprintf(cmd, FILENAME_MAX+10, "%s/%s -PPq", path, cp);
+    if ((f = popen(cmd, "r")) == NULL) {
+	perror("popen()");
+	goto nowrap;
+    } else {
+	if (get_string(ver, 9, f) == NULL)
+	    goto nowrap; 
+	else
+	    ptver = strtol(ver, NULL, 10);
+	if (get_string(ver, 9, f) == NULL)
+	    goto nowrap;
+	else
+	    lpver = strtol(ver, NULL, 10);
+	pclose(f);
+    }
+
+    if ((lpver >= LIBPKG_VERSION) && (ptver > curver)) {
+	snprintf(cmd, FILENAME_MAX, "%s/%s", path, cp);
+	execve(cmd, argv, environ);
+    }
 
 nowrap:
     unsetenv("PKG_NOWRAP");
-    return(real_main(argc, argv));
 }

Modified: head/lib/libpkg/plist.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/plist.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/plist.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <md5.h>
 

Modified: head/lib/libpkg/str.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/str.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/str.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 
 char *
 strconcat(const char *s1, const char *s2)

Modified: head/lib/libpkg/url.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/url.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/url.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 #include <fetch.h>
 #include <libgen.h>
@@ -109,7 +109,7 @@ fileGetURL(const char *base, const char 
 	printf("Error: Unable to get %s: %s\n",
 	       fname, fetchLastErrString);
 	/* If the fetch fails, yank the package. */
-	if (keep_package && unlink(pkg) < 0 && Verbose) {
+	if (keep_package && unlink(pkg) < 0) {
 	    warnx("failed to remove partially fetched package: %s", pkg);
 	}
 	return NULL;

Modified: head/lib/libpkg/version.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/version.c	Sat Apr  3 11:19:20 2010	(r206135)
+++ head/lib/libpkg/version.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -19,10 +19,20 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include "pkg.h"
 #include <err.h>
 
 /*
+ * This routine could easily go somewhere else.
+ *
+ */
+int
+libpkg_version(void)
+{
+	return LIBPKG_VERSION;
+}
+
+/*
  * Routines to assist with PLIST_FMT_VER numbers in the packing
  * lists.
  *

Modified: head/share/mk/bsd.libnames.mk
==============================================================================
--- head/share/mk/bsd.libnames.mk	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/share/mk/bsd.libnames.mk	Fri Apr 23 11:07:43 2010	(r207113)
@@ -128,6 +128,7 @@ MINUSLPAM+=	-lypclnt
 
 LIBPANEL?=	${DESTDIR}${LIBDIR}/libpanel.a
 LIBPCAP?=	${DESTDIR}${LIBDIR}/libpcap.a
+LIBPKG?=	${DESTDIR}${LIBDIR}/libpkg.a
 LIBPMC?=	${DESTDIR}${LIBDIR}/libpmc.a
 LIBPROC?=	${DESTDIR}${LIBDIR}/libproc.a
 LIBPTHREAD?=	${DESTDIR}${LIBDIR}/libpthread.a

Modified: head/usr.sbin/pkg_install/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -2,11 +2,11 @@
 
 .include <bsd.own.mk>
 
-SUBDIR=	lib add create delete info updating version
+SUBDIR=	add create delete info updating version
 
 .include <bsd.subdir.mk>
 
-DATE!=	grep PKG_INSTALL_VERSION ${.CURDIR}/lib/lib.h | sed 's|.*[ 	]||'
+DATE!=	grep PKG_INSTALL_VERSION ${.CURDIR}/Makefile.inc | sed 's|.*=||'
 
 distfile: clean
 	@(cd ${.CURDIR}/..; \

Modified: head/usr.sbin/pkg_install/Makefile.inc
==============================================================================
--- head/usr.sbin/pkg_install/Makefile.inc	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/Makefile.inc	Fri Apr 23 11:07:43 2010	(r207113)
@@ -2,16 +2,11 @@
 
 .include <bsd.own.mk>
 
-LIBINSTALL=	${.OBJDIR}/../lib/libinstall.a
+CFLAGS+=	-DPKG_INSTALL_VERSION=20100423
+CFLAGS+=	-DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE
 
-DPADD+=		${LIBUTIL}
-LDADD+=		-lutil
-
-.if ${MK_OPENSSL} != "no" && \
-    defined(LDADD) && ${LDADD:M-lfetch} != ""
-DPADD+=		${LIBSSL} ${LIBCRYPTO}
-LDADD+=		-lssl -lcrypto
-.endif
+DPADD+=		${LIBPKG}
+LDADD+=		-lpkg
 
 # Inherit BINDIR from one level up.
 .include "../Makefile.inc"

Modified: head/usr.sbin/pkg_install/add/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/add/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/add/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -1,14 +1,11 @@
 # $FreeBSD$
 
+.include <bsd.own.mk>
+
 PROG=	pkg_add
 SRCS=	main.c perform.c futil.c extract.c
 
-CFLAGS+= -I${.CURDIR}/../lib
-
 WARNS?=	3
 WFORMAT?=	1
 
-DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD=	${LIBINSTALL} -lfetch -lmd
-
 .include <bsd.prog.mk>

Modified: head/usr.sbin/pkg_install/add/extract.c
==============================================================================
--- head/usr.sbin/pkg_install/add/extract.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/add/extract.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
 
 #include <ctype.h>
 #include <err.h>
-#include "lib.h"
+#include <pkg.h>
 #include "add.h"
 
 

Modified: head/usr.sbin/pkg_install/add/futil.c
==============================================================================
--- head/usr.sbin/pkg_install/add/futil.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/add/futil.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -22,7 +22,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <err.h>
-#include "lib.h"
+#include <pkg.h>
 #include "add.h"
 
 /*

Modified: head/usr.sbin/pkg_install/add/main.c
==============================================================================
--- head/usr.sbin/pkg_install/add/main.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/add/main.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$");
 #include <err.h>
 #include <getopt.h>
 
-#include "lib.h"
+#include <pkg.h>
 #include "add.h"
 
 char	*Prefix		= NULL;
@@ -128,6 +128,8 @@ main(int argc, char **argv)
     static char temppackageroot[MAXPATHLEN];
     static char pkgaddpath[MAXPATHLEN];
 
+    pkg_wrap(PKG_INSTALL_VERSION, argv);
+
     if (*argv[0] != '/' && strchr(argv[0], '/') != NULL)
 	PkgAddCmd = realpath(argv[0], pkgaddpath);
     else

Modified: head/usr.sbin/pkg_install/add/perform.c
==============================================================================
--- head/usr.sbin/pkg_install/add/perform.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/add/perform.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
 
 #include <err.h>
 #include <paths.h>
-#include "lib.h"
+#include <pkg.h>
 #include "add.h"
 
 #include <libgen.h>

Modified: head/usr.sbin/pkg_install/create/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/create/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/create/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -3,12 +3,10 @@
 PROG=	pkg_create
 SRCS=	main.c perform.c pl.c
 
-CFLAGS+= -I${.CURDIR}/../lib
-
 WARNS?=	3
 WFORMAT?=	1
 
-DPADD=	${LIBINSTALL} ${LIBMD}
-LDADD=	${LIBINSTALL} -lmd
+DPADD=	${LIBMD}
+LDADD=	-lmd
 
 .include <bsd.prog.mk>

Modified: head/usr.sbin/pkg_install/create/main.c
==============================================================================
--- head/usr.sbin/pkg_install/create/main.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/create/main.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -15,7 +15,7 @@ __FBSDID("$FreeBSD$");
 #include <getopt.h>
 #include <err.h>
 
-#include "lib.h"
+#include <pkg.h>
 #include "create.h"
 
 match_t	MatchType	= MATCH_GLOB;
@@ -72,6 +72,8 @@ main(int argc, char **argv)
     int ch;
     char **pkgs, **start, *tmp;
 
+    pkg_wrap(PKG_INSTALL_VERSION, argv);
+
     pkgs = start = argv;
     while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
 	switch(ch) {

Modified: head/usr.sbin/pkg_install/create/perform.c
==============================================================================
--- head/usr.sbin/pkg_install/create/perform.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/create/perform.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include <pkg.h>
 #include "create.h"
 
 #include <err.h>

Modified: head/usr.sbin/pkg_install/create/pl.c
==============================================================================
--- head/usr.sbin/pkg_install/create/pl.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/create/pl.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include <pkg.h>
 #include "create.h"
 #include <errno.h>
 #include <err.h>

Modified: head/usr.sbin/pkg_install/delete/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/delete/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/delete/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -3,11 +3,6 @@
 PROG=	pkg_delete
 SRCS=	main.c perform.c
 
-CFLAGS+= -I${.CURDIR}/../lib
-
 WFORMAT?=	1
 
-DPADD=	${LIBINSTALL} ${LIBMD}
-LDADD=	${LIBINSTALL} -lmd
-
 .include <bsd.prog.mk>

Modified: head/usr.sbin/pkg_install/delete/main.c
==============================================================================
--- head/usr.sbin/pkg_install/delete/main.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/delete/main.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$");
 #include <getopt.h>
 #include <err.h>
 
-#include "lib.h"
+#include <pkg.h>
 #include "delete.h"
 
 char	*Prefix		= NULL;
@@ -67,6 +67,8 @@ main(int argc, char **argv)
     const char *tmp;
     struct stat stat_s;
 
+    pkg_wrap(PKG_INSTALL_VERSION, argv);
+
     pkgs = start = argv;
     while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
 	switch(ch) {

Modified: head/usr.sbin/pkg_install/delete/perform.c
==============================================================================
--- head/usr.sbin/pkg_install/delete/perform.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/delete/perform.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -22,7 +22,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <err.h>
-#include "lib.h"
+#include <pkg.h>
 #include "delete.h"
 
 static int pkg_do(char *);

Modified: head/usr.sbin/pkg_install/info/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/info/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/info/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -3,11 +3,9 @@
 PROG=	pkg_info
 SRCS=	main.c perform.c show.c
 
-CFLAGS+= -I${.CURDIR}/../lib
-
 WFORMAT?=	1
 
-DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD=	${LIBINSTALL} -lfetch -lmd
+DPADD=	${LIBMD}
+LDADD=	-lmd
 
 .include <bsd.prog.mk>

Modified: head/usr.sbin/pkg_install/info/info.h
==============================================================================
--- head/usr.sbin/pkg_install/info/info.h	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/info/info.h	Fri Apr 23 11:07:43 2010	(r207113)
@@ -33,25 +33,26 @@
 #define MAXNAMESIZE  20
 #endif
 
-#define SHOW_COMMENT	0x00001
-#define SHOW_DESC	0x00002
-#define SHOW_PLIST	0x00004
-#define SHOW_INSTALL	0x00008
-#define SHOW_DEINSTALL	0x00010
-#define SHOW_REQUIRE	0x00020
-#define SHOW_PREFIX	0x00040
-#define SHOW_INDEX	0x00080
-#define SHOW_FILES	0x00100
-#define SHOW_DISPLAY	0x00200
-#define SHOW_REQBY	0x00400
-#define SHOW_MTREE	0x00800
-#define SHOW_SIZE	0x01000
-#define SHOW_ORIGIN	0x02000
-#define SHOW_CKSUM	0x04000
-#define SHOW_FMTREV	0x08000
-#define SHOW_PTREV	0x10000
-#define SHOW_DEPEND	0x20000
-#define SHOW_PKGNAME	0x40000
+#define SHOW_COMMENT	0x000001
+#define SHOW_DESC	0x000002
+#define SHOW_PLIST	0x000004
+#define SHOW_INSTALL	0x000008
+#define SHOW_DEINSTALL	0x000010
+#define SHOW_REQUIRE	0x000020
+#define SHOW_PREFIX	0x000040
+#define SHOW_INDEX	0x000080
+#define SHOW_FILES	0x000100
+#define SHOW_DISPLAY	0x000200
+#define SHOW_REQBY	0x000400
+#define SHOW_MTREE	0x000800
+#define SHOW_SIZE	0x001000
+#define SHOW_ORIGIN	0x002000
+#define SHOW_CKSUM	0x004000
+#define SHOW_FMTREV	0x008000
+#define SHOW_PTREV	0x010000
+#define SHOW_DEPEND	0x020000
+#define SHOW_PKGNAME	0x040000
+#define SHOW_LPREV	0x100000
 
 struct which_entry {
     TAILQ_ENTRY(which_entry) next;

Modified: head/usr.sbin/pkg_install/info/main.c
==============================================================================
--- head/usr.sbin/pkg_install/info/main.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/info/main.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$");
 #include <getopt.h>
 #include <err.h>
 
-#include "lib.h"
+#include <pkg.h>
 #include "info.h"
 
 int	Flags		= 0;
@@ -68,6 +68,8 @@ main(int argc, char **argv)
     char **pkgs, **start;
     char *pkgs_split;
 
+    pkg_wrap(PKG_INSTALL_VERSION, argv);
+
     whead = malloc(sizeof(struct which_head));
     if (whead == NULL)
 	err(2, NULL);
@@ -225,7 +227,10 @@ main(int argc, char **argv)
 	    }
 
 	case 'P':
-	    Flags = SHOW_PTREV;
+	    if (Flags & SHOW_PTREV)
+		Flags |= SHOW_LPREV;
+	    else
+		Flags = SHOW_PTREV;
 	    break;
 
 	case 'h':
@@ -242,6 +247,11 @@ main(int argc, char **argv)
 	if (!Quiet)
 	    printf("Package tools revision: ");
 	printf("%d\n", PKG_INSTALL_VERSION);
+	if (Flags & SHOW_LPREV) {
+	    if (!Quiet)
+		printf("Libpkg revision: ");
+	    printf("%d\n", libpkg_version());
+	}
 	exit(0);
     }
 

Modified: head/usr.sbin/pkg_install/info/perform.c
==============================================================================
--- head/usr.sbin/pkg_install/info/perform.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/info/perform.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include <pkg.h>
 #include "info.h"
 #include <err.h>
 #include <signal.h>

Modified: head/usr.sbin/pkg_install/info/show.c
==============================================================================
--- head/usr.sbin/pkg_install/info/show.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/info/show.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include <pkg.h>
 #include "info.h"
 #include <err.h>
 #include <stdlib.h>

Modified: head/usr.sbin/pkg_install/updating/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/updating/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/updating/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -3,11 +3,6 @@
 PROG=	pkg_updating
 SRCS=	main.c
 
-CFLAGS+= -I${.CURDIR}/../lib
-
 WFORMAT?= 1
 
-DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD=	${LIBINSTALL} -lfetch -lmd
-
 .include <bsd.prog.mk>

Modified: head/usr.sbin/pkg_install/updating/main.c
==============================================================================
--- head/usr.sbin/pkg_install/updating/main.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/updating/main.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -19,7 +19,7 @@ __FBSDID("$FreeBSD$");
 #include <sysexits.h>
 #include <getopt.h>
 
-#include "lib.h"
+#include <pkg.h>
 #include "pathnames.h"
 
 typedef struct installedport {
@@ -87,6 +87,8 @@ main(int argc, char *argv[])
 	DIR *dir;
 	FILE *fd;
 
+	pkg_wrap(PKG_INSTALL_VERSION, argv);
+
 	while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
 		switch (ch) {
 			case 'd':

Modified: head/usr.sbin/pkg_install/version/Makefile
==============================================================================
--- head/usr.sbin/pkg_install/version/Makefile	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/version/Makefile	Fri Apr 23 11:07:43 2010	(r207113)
@@ -3,13 +3,8 @@
 PROG=	pkg_version
 SRCS=	main.c perform.c
 
-CFLAGS+= -I${.CURDIR}/../lib
-
 WFORMAT?=	1
 
-DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD=	${LIBINSTALL} -lfetch -lmd
-
 test:
 	sh ${.CURDIR}/test-pkg_version.sh
 

Modified: head/usr.sbin/pkg_install/version/main.c
==============================================================================
--- head/usr.sbin/pkg_install/version/main.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/version/main.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$");
 #include <getopt.h>
 #include <err.h>
 
-#include "lib.h"
+#include <pkg.h>
 #include "version.h"
 
 char	*LimitChars = NULL;
@@ -58,6 +58,8 @@ main(int argc, char **argv)
 {
     int ch, cmp = 0;
 
+    pkg_wrap(PKG_INSTALL_VERSION, argv);
+
     if (argc == 4 && !strcmp(argv[1], "-t")) {
 	cmp = version_cmp(argv[2], argv[3]);
 	printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n"));

Modified: head/usr.sbin/pkg_install/version/perform.c
==============================================================================
--- head/usr.sbin/pkg_install/version/perform.c	Fri Apr 23 10:33:32 2010	(r207112)
+++ head/usr.sbin/pkg_install/version/perform.c	Fri Apr 23 11:07:43 2010	(r207113)
@@ -21,7 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "lib.h"
+#include <pkg.h>
 #include "version.h"
 #include <err.h>
 #include <fetch.h>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004231107.o3NB7h2a080365>