From 2eb4b00cbb86ee4591b3a60e96b94e51085c3939 Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Tue, 17 May 2011 19:11:47 +0000 Subject: [PATCH] Backout libinstall.a -> libpkg commit. Discussed with: erwin, brooks, bapt --- Makefile.inc1 | 5 +- lib/Makefile | 5 -- lib/libpkg/Makefile | 47 ---------- lib/libpkg/pkgwrap.c | 90 ------------------- share/mk/bsd.libnames.mk | 1 - usr.sbin/pkg_install/Makefile | 4 +- usr.sbin/pkg_install/Makefile.inc | 13 ++- usr.sbin/pkg_install/add/Makefile | 7 +- usr.sbin/pkg_install/add/extract.c | 2 +- usr.sbin/pkg_install/add/futil.c | 2 +- usr.sbin/pkg_install/add/main.c | 4 +- usr.sbin/pkg_install/add/perform.c | 2 +- usr.sbin/pkg_install/create/Makefile | 6 +- usr.sbin/pkg_install/create/main.c | 4 +- usr.sbin/pkg_install/create/perform.c | 2 +- usr.sbin/pkg_install/create/pl.c | 2 +- usr.sbin/pkg_install/delete/Makefile | 5 ++ usr.sbin/pkg_install/delete/main.c | 4 +- usr.sbin/pkg_install/delete/perform.c | 2 +- usr.sbin/pkg_install/info/Makefile | 6 +- usr.sbin/pkg_install/info/info.h | 39 ++++---- usr.sbin/pkg_install/info/main.c | 14 +-- usr.sbin/pkg_install/info/perform.c | 2 +- usr.sbin/pkg_install/info/show.c | 2 +- usr.sbin/pkg_install/lib/Makefile | 11 +++ .../pkg_install/lib}/deps.c | 2 +- .../pkg_install/lib}/exec.c | 2 +- .../pkg_install/lib}/file.c | 2 +- .../pkg_install/lib}/global.c | 2 +- .../pkg.h => usr.sbin/pkg_install/lib/lib.h | 12 +-- .../pkg_install/lib}/match.c | 4 +- .../libpkg => usr.sbin/pkg_install/lib}/msg.c | 9 +- .../libpkg => usr.sbin/pkg_install/lib}/pen.c | 17 ++-- usr.sbin/pkg_install/lib/pkgwrap.c | 89 ++++++++++++++++++ .../pkg_install/lib}/plist.c | 2 +- .../libpkg => usr.sbin/pkg_install/lib}/str.c | 2 +- .../libpkg => usr.sbin/pkg_install/lib}/url.c | 4 +- .../pkg_install/lib}/version.c | 14 +-- usr.sbin/pkg_install/updating/Makefile | 5 ++ usr.sbin/pkg_install/updating/main.c | 4 +- usr.sbin/pkg_install/version/Makefile | 5 ++ usr.sbin/pkg_install/version/main.c | 4 +- usr.sbin/pkg_install/version/perform.c | 2 +- 43 files changed, 211 insertions(+), 251 deletions(-) delete mode 100644 lib/libpkg/Makefile delete mode 100644 lib/libpkg/pkgwrap.c create mode 100644 usr.sbin/pkg_install/lib/Makefile rename {lib/libpkg => usr.sbin/pkg_install/lib}/deps.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/exec.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/file.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/global.c (98%) rename lib/libpkg/pkg.h => usr.sbin/pkg_install/lib/lib.h (96%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/match.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/msg.c (91%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/pen.c (90%) create mode 100644 usr.sbin/pkg_install/lib/pkgwrap.c rename {lib/libpkg => usr.sbin/pkg_install/lib}/plist.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/str.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/url.c (98%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/version.c (98%) diff --git a/Makefile.inc1 b/Makefile.inc1 index 907cdce7d5bf..4aa53da83d2f 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1205,7 +1205,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \ ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ ${_kerberos5_lib_libroken} \ lib/libbz2 lib/libcom_err lib/libcrypt \ - lib/libexpat lib/libfetch \ + lib/libexpat \ ${_lib_libgssapi} ${_lib_libipx} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/ncurses/ncurses lib/ncurses/ncursesw \ @@ -1238,7 +1238,6 @@ _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 @@ -1274,7 +1273,7 @@ _lib_libypclnt= lib/libypclnt .endif .if ${MK_OPENSSL} == "no" -lib/libfetch__L lib/libradius__L: lib/libmd__L +lib/libradius__L: lib/libmd__L .endif .for _lib in ${_prereq_libs} diff --git a/lib/Makefile b/lib/Makefile index 7be186fca21c..eef204899cde 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -89,7 +89,6 @@ SUBDIR= ${SUBDIR_ORDERED} \ libopie \ libpam \ libpcap \ - ${_libpkg} \ ${_libpmc} \ ${_libproc} \ libprocstat \ @@ -215,10 +214,6 @@ _libmp= libmp _libpmc= libpmc .endif -.if ${MK_PKGTOOLS} != "no" -_libpkg= libpkg -.endif - .if ${MK_SENDMAIL} != "no" _libmilter= libmilter _libsm= libsm diff --git a/lib/libpkg/Makefile b/lib/libpkg/Makefile deleted file mode 100644 index 8f2b325f0980..000000000000 --- a/lib/libpkg/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# $FreeBSD$ - -.include - -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 diff --git a/lib/libpkg/pkgwrap.c b/lib/libpkg/pkgwrap.c deleted file mode 100644 index 9c8c0c3d0a26..000000000000 --- a/lib/libpkg/pkgwrap.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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. - * - * Maxim Sobolev - * 8 September 2002 - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "pkg.h" -#include -#include -#include -#include - -extern char **environ; - -void -pkg_wrap(long curver, char **argv) -{ - FILE* f; - char ver[9]; /* Format is: 'YYYYMMDD\0' */ - char buffer[FILENAME_MAX+10]; /* Format is: 'YYYYMMDD ' */ - char cmd[FILENAME_MAX+5]; /* Format is: ' -PPq' */ - char *path, *cp; - long ptver, lpver; - - if (getenv("PKG_NOWRAP") != NULL) - goto nowrap; - - setenv("PKG_NOWRAP", "1", 1); - - /* Get alternative location for package tools. */ - if ((f = fopen(PKG_WRAPCONF_FNAME, "r")) == NULL) { - goto nowrap; - } else { - if (get_string(buffer, FILENAME_MAX+9, f) == NULL) { - goto nowrap; - } else { - if ((path = strrchr(buffer, ' ')) == NULL) { - goto nowrap; - } else { - *path++ = '\0'; - } - } - } - - if ((cp = strrchr(argv[0], '/')) == NULL) { - cp = argv[0]; - } else { - cp++; - } - - /* 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"); -} diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk index 9a948ff4bbef..d3fb51a9a73f 100644 --- a/share/mk/bsd.libnames.mk +++ b/share/mk/bsd.libnames.mk @@ -129,7 +129,6 @@ 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 diff --git a/usr.sbin/pkg_install/Makefile b/usr.sbin/pkg_install/Makefile index 0aa19415441b..bf1a2135cc79 100644 --- a/usr.sbin/pkg_install/Makefile +++ b/usr.sbin/pkg_install/Makefile @@ -2,11 +2,11 @@ .include -SUBDIR= add create delete info updating version +SUBDIR= lib add create delete info updating version .include -DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/Makefile.inc | sed 's|.*=||' +DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/lib/lib.h | sed 's|.*[ ]||' distfile: clean @(cd ${.CURDIR}/..; \ diff --git a/usr.sbin/pkg_install/Makefile.inc b/usr.sbin/pkg_install/Makefile.inc index d929f2457009..2fa20aa1c394 100644 --- a/usr.sbin/pkg_install/Makefile.inc +++ b/usr.sbin/pkg_install/Makefile.inc @@ -2,11 +2,16 @@ .include -CFLAGS+= -DPKG_INSTALL_VERSION=20101012 -CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE +LIBINSTALL= ${.OBJDIR}/../lib/libinstall.a -DPADD+= ${LIBPKG} -LDADD+= -lpkg +DPADD+= ${LIBUTIL} +LDADD+= -lutil + +.if ${MK_OPENSSL} != "no" && \ + defined(LDADD) && ${LDADD:M-lfetch} != "" +DPADD+= ${LIBSSL} ${LIBCRYPTO} +LDADD+= -lssl -lcrypto +.endif # Inherit BINDIR from one level up. .include "../Makefile.inc" diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile index 03a43f068b76..89988e78b220 100644 --- a/usr.sbin/pkg_install/add/Makefile +++ b/usr.sbin/pkg_install/add/Makefile @@ -1,11 +1,14 @@ # $FreeBSD$ -.include - 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 diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c index 6c2c4fc7b92b..732a13fea441 100644 --- a/usr.sbin/pkg_install/add/extract.c +++ b/usr.sbin/pkg_install/add/extract.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c index c5253202ca5e..ca095ea7ae2e 100644 --- a/usr.sbin/pkg_install/add/futil.c +++ b/usr.sbin/pkg_install/add/futil.c @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include "lib.h" #include "add.h" /* diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index b8b9b54bcf63..f73312a626e5 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" char *Prefix = NULL; @@ -132,8 +132,6 @@ 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 diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 653a1d6296fe..b23cd5232a32 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" #include diff --git a/usr.sbin/pkg_install/create/Makefile b/usr.sbin/pkg_install/create/Makefile index 333403778fe3..42718c6f9273 100644 --- a/usr.sbin/pkg_install/create/Makefile +++ b/usr.sbin/pkg_install/create/Makefile @@ -3,10 +3,12 @@ PROG= pkg_create SRCS= main.c perform.c pl.c +CFLAGS+= -I${.CURDIR}/../lib + WARNS?= 3 WFORMAT?= 1 -DPADD= ${LIBMD} -LDADD= -lmd +DPADD= ${LIBINSTALL} ${LIBMD} +LDADD= ${LIBINSTALL} -lmd .include diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index 5e999dae3350..e4af62128ae0 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -15,7 +15,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "create.h" match_t MatchType = MATCH_GLOB; @@ -72,8 +72,6 @@ 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) { diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 149bcbd08513..45786b62b87c 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "create.h" #include diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c index fe62d421014e..18bbaf24734b 100644 --- a/usr.sbin/pkg_install/create/pl.c +++ b/usr.sbin/pkg_install/create/pl.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "create.h" #include #include diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile index 4f3b3906e63c..c9a0fdebea22 100644 --- a/usr.sbin/pkg_install/delete/Makefile +++ b/usr.sbin/pkg_install/delete/Makefile @@ -3,6 +3,11 @@ PROG= pkg_delete SRCS= main.c perform.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBMD} +LDADD= ${LIBINSTALL} -lmd + .include diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 7677fe9d44bc..f09a432f2bb4 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "delete.h" char *Prefix = NULL; @@ -67,8 +67,6 @@ 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) { diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 02f9717a0919..2557dbcd105d 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include "lib.h" #include "delete.h" static int pkg_do(char *); diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile index ba3909d17da7..485cb2263210 100644 --- a/usr.sbin/pkg_install/info/Makefile +++ b/usr.sbin/pkg_install/info/Makefile @@ -3,9 +3,11 @@ PROG= pkg_info SRCS= main.c perform.c show.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 -DPADD= ${LIBMD} -LDADD= -lmd +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd .include diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 68ec7107a3c3..46e29b1202dd 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -33,26 +33,25 @@ #define MAXNAMESIZE 20 #endif -#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 +#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 struct which_entry { TAILQ_ENTRY(which_entry) next; diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index ca4e477f9995..2de638e4cad3 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "info.h" int Flags = 0; @@ -68,8 +68,6 @@ 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); @@ -227,10 +225,7 @@ main(int argc, char **argv) } case 'P': - if (Flags & SHOW_PTREV) - Flags |= SHOW_LPREV; - else - Flags = SHOW_PTREV; + Flags = SHOW_PTREV; break; case 'h': @@ -247,11 +242,6 @@ 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); } diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index d2956120822a..09cad78ad3f2 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "info.h" #include #include diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 0d3b4ad73d2e..c65c312a5062 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "info.h" #include #include diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile new file mode 100644 index 000000000000..84a41b8d7f15 --- /dev/null +++ b/usr.sbin/pkg_install/lib/Makefile @@ -0,0 +1,11 @@ +# $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 + +WARNS?= 3 +WFORMAT?= 1 + +.include diff --git a/lib/libpkg/deps.c b/usr.sbin/pkg_install/lib/deps.c similarity index 99% rename from lib/libpkg/deps.c rename to usr.sbin/pkg_install/lib/deps.c index 101d04602192..66f44a9c6fea 100644 --- a/lib/libpkg/deps.c +++ b/usr.sbin/pkg_install/lib/deps.c @@ -22,7 +22,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include diff --git a/lib/libpkg/exec.c b/usr.sbin/pkg_install/lib/exec.c similarity index 99% rename from lib/libpkg/exec.c rename to usr.sbin/pkg_install/lib/exec.c index 04891d3cc09a..fc8220c5f399 100644 --- a/lib/libpkg/exec.c +++ b/usr.sbin/pkg_install/lib/exec.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include /* diff --git a/lib/libpkg/file.c b/usr.sbin/pkg_install/lib/file.c similarity index 99% rename from lib/libpkg/file.c rename to usr.sbin/pkg_install/lib/file.c index 7c95f995a2fe..c7ab9d6b2977 100644 --- a/lib/libpkg/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include diff --git a/lib/libpkg/global.c b/usr.sbin/pkg_install/lib/global.c similarity index 98% rename from lib/libpkg/global.c rename to usr.sbin/pkg_install/lib/global.c index 8103126e6935..e136ec86a6f2 100644 --- a/lib/libpkg/global.c +++ b/usr.sbin/pkg_install/lib/global.c @@ -22,7 +22,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" /* These are global for all utils */ Boolean Quiet = FALSE; diff --git a/lib/libpkg/pkg.h b/usr.sbin/pkg_install/lib/lib.h similarity index 96% rename from lib/libpkg/pkg.h rename to usr.sbin/pkg_install/lib/lib.h index 12e35623bc8a..089bfa3630b9 100644 --- a/lib/libpkg/pkg.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -23,10 +23,6 @@ #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 #include @@ -100,12 +96,13 @@ #define PKG_PREFIX_VNAME "PKG_PREFIX" /* - * Version of the package library - increase whenever you make a change + * Version of the package tools - increase whenever you make a change * in the code that is not cosmetic only. */ -#define LIBPKG_VERSION 20100423 +#define PKG_INSTALL_VERSION 20100403 #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 @@ -217,7 +214,7 @@ Boolean make_preserve_name(char *, int, const char *, const char *); /* For all */ int pkg_perform(char **); -void pkg_wrap(long, char **); +int real_main(int, char **); /* Query installed packages */ char **matchinstalled(match_t, char **, int *); @@ -232,7 +229,6 @@ int chkifdepends(const char *, const char *); 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 *); diff --git a/lib/libpkg/match.c b/usr.sbin/pkg_install/lib/match.c similarity index 99% rename from lib/libpkg/match.c rename to usr.sbin/pkg_install/lib/match.c index ba6544224dcf..6c1b2bfcf003 100644 --- a/lib/libpkg/match.c +++ b/usr.sbin/pkg_install/lib/match.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -292,7 +292,7 @@ matchallbyorigin(const char **origins, int *retval) break; } } - if (cmd != PLIST_ORIGIN && 0 != strncmp("bsdpan-", installed[i], 7)) + if (cmd != PLIST_ORIGIN && ( Verbose || 0 != strncmp("bsdpan-", installed[i], 7 ) ) ) warnx("package %s has no origin recorded", installed[i]); fclose(fp); } diff --git a/lib/libpkg/msg.c b/usr.sbin/pkg_install/lib/msg.c similarity index 91% rename from lib/libpkg/msg.c rename to usr.sbin/pkg_install/lib/msg.c index 0d25ad199007..5b17624016d0 100644 --- a/lib/libpkg/msg.c +++ b/usr.sbin/pkg_install/lib/msg.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include @@ -61,7 +61,12 @@ y_or_n(Boolean def, const char *msg, ...) else fprintf(stderr, " [no]? "); fflush(stderr); - ch = toupper(fgetc(tty)); + if (AutoAnswer) { + ch = (AutoAnswer == YES) ? 'Y' : 'N'; + fprintf(stderr, "%c\n", ch); + } + else + ch = toupper(fgetc(tty)); if (ch == '\n') ch = (def) ? 'Y' : 'N'; } diff --git a/lib/libpkg/pen.c b/usr.sbin/pkg_install/lib/pen.c similarity index 90% rename from lib/libpkg/pen.c rename to usr.sbin/pkg_install/lib/pen.c index 6e30445b7594..2b405a3a43a8 100644 --- a/lib/libpkg/pen.c +++ b/usr.sbin/pkg_install/lib/pen.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -103,7 +103,7 @@ popPen(char *pen) const char * make_playpen(char *pen, off_t sz) { - char humbuf[6]; + char humbuf1[6], humbuf2[6]; char cwd[FILENAME_MAX]; if (!find_play_pen(pen, sz)) @@ -114,15 +114,22 @@ make_playpen(char *pen, off_t sz) errx(2, "%s: can't mktemp '%s'", __func__, pen); } - humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE, HN_NOSPACE); + 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); + } + } 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 at least %s and try the command again", - __func__, humbuf, pen); + "with more space and\ntry the command again", __func__, pen); } if (!getcwd(cwd, FILENAME_MAX)) { diff --git a/usr.sbin/pkg_install/lib/pkgwrap.c b/usr.sbin/pkg_install/lib/pkgwrap.c new file mode 100644 index 000000000000..cbd15cd7b445 --- /dev/null +++ b/usr.sbin/pkg_install/lib/pkgwrap.c @@ -0,0 +1,89 @@ +/* + * 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. + * + * Maxim Sobolev + * 8 September 2002 + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "lib.h" +#include +#include +#include +#include + +#undef main + +#define SEPARATORS " \t" + +extern char **environ; + +int +main(int argc, char **argv) +{ + FILE *f; + char buffer[FILENAME_MAX], *cp, *verstr; + int len; + + 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) + goto nowrap; + *cp = '\0'; + for (cp = verstr; *cp != '\0'; cp++) + if (isdigit(*cp) == 0) + 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) + cp = argv[0]; + else + cp++; + strlcat(buffer, "/", sizeof(buffer)); + strlcat(buffer, cp, sizeof(buffer)); + setenv("PKG_NOWRAP", "1", 1); + execve(buffer, argv, environ); + +nowrap: + unsetenv("PKG_NOWRAP"); + return(real_main(argc, argv)); +} diff --git a/lib/libpkg/plist.c b/usr.sbin/pkg_install/lib/plist.c similarity index 99% rename from lib/libpkg/plist.c rename to usr.sbin/pkg_install/lib/plist.c index b14ac20aafc0..545b541c3f18 100644 --- a/lib/libpkg/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include diff --git a/lib/libpkg/str.c b/usr.sbin/pkg_install/lib/str.c similarity index 99% rename from lib/libpkg/str.c rename to usr.sbin/pkg_install/lib/str.c index c26e6cce6605..0d9e288b7579 100644 --- a/lib/libpkg/str.c +++ b/usr.sbin/pkg_install/lib/str.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" char * strconcat(const char *s1, const char *s2) diff --git a/lib/libpkg/url.c b/usr.sbin/pkg_install/lib/url.c similarity index 98% rename from lib/libpkg/url.c rename to usr.sbin/pkg_install/lib/url.c index 4c1084994283..8c5534711997 100644 --- a/lib/libpkg/url.c +++ b/usr.sbin/pkg_install/lib/url.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -109,7 +109,7 @@ fileGetURL(const char *base, const char *spec, int keep_package) printf("Error: Unable to get %s: %s\n", fname, fetchLastErrString); /* If the fetch fails, yank the package. */ - if (keep_package && unlink(pkg) < 0) { + if (keep_package && unlink(pkg) < 0 && Verbose) { warnx("failed to remove partially fetched package: %s", pkg); } return NULL; diff --git a/lib/libpkg/version.c b/usr.sbin/pkg_install/lib/version.c similarity index 98% rename from lib/libpkg/version.c rename to usr.sbin/pkg_install/lib/version.c index 123fd5d20e57..d9c4fe7e070c 100644 --- a/lib/libpkg/version.c +++ b/usr.sbin/pkg_install/lib/version.c @@ -19,19 +19,9 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include -/* - * 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. @@ -76,7 +66,7 @@ split_version(const char *pkgname, const char **endname, unsigned long *epoch, u if (pkgname == NULL) errx(2, "%s: Passed NULL pkgname.", __func__); - /* Look for the last '-' the pkgname */ + /* Look for the last '-' the the pkgname */ ch = strrchr(pkgname, '-'); /* Cheat if we are just passed a version, not a valid package name */ versionstr = ch ? ch + 1 : pkgname; diff --git a/usr.sbin/pkg_install/updating/Makefile b/usr.sbin/pkg_install/updating/Makefile index f5b7525ddb51..b0d3689779e6 100644 --- a/usr.sbin/pkg_install/updating/Makefile +++ b/usr.sbin/pkg_install/updating/Makefile @@ -3,6 +3,11 @@ PROG= pkg_updating SRCS= main.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + .include diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c index 993ccd523104..0ab2ec0fe8ea 100644 --- a/usr.sbin/pkg_install/updating/main.c +++ b/usr.sbin/pkg_install/updating/main.c @@ -19,7 +19,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "pathnames.h" typedef struct installedport { @@ -87,8 +87,6 @@ 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': diff --git a/usr.sbin/pkg_install/version/Makefile b/usr.sbin/pkg_install/version/Makefile index fb079e34c7ad..3e1d7a522f27 100644 --- a/usr.sbin/pkg_install/version/Makefile +++ b/usr.sbin/pkg_install/version/Makefile @@ -3,8 +3,13 @@ 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 diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c index 42384970603b..cad8583c23bf 100644 --- a/usr.sbin/pkg_install/version/main.c +++ b/usr.sbin/pkg_install/version/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "version.h" char *LimitChars = NULL; @@ -58,8 +58,6 @@ 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")); diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c index 79575a32ba28..dc85696cfc15 100644 --- a/usr.sbin/pkg_install/version/perform.c +++ b/usr.sbin/pkg_install/version/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "version.h" #include #include