diff options
-rw-r--r-- | usr.sbin/pkg_install/info/info.h | 33 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/main.c | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/pkg_info.1 | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/lib.h | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/pkgwrap.c | 89 |
5 files changed, 131 insertions, 18 deletions
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 9f4b52f..94a8b5b 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -33,22 +33,23 @@ #define MAXNAMESIZE 20 #endif -#define SHOW_COMMENT 0x0001 -#define SHOW_DESC 0x0002 -#define SHOW_PLIST 0x0004 -#define SHOW_INSTALL 0x0008 -#define SHOW_DEINSTALL 0x0010 -#define SHOW_REQUIRE 0x0020 -#define SHOW_PREFIX 0x0040 -#define SHOW_INDEX 0x0080 -#define SHOW_FILES 0x0100 -#define SHOW_DISPLAY 0x0200 -#define SHOW_REQBY 0x0400 -#define SHOW_MTREE 0x0800 -#define SHOW_SIZE 0x1000 -#define SHOW_ORIGIN 0x2000 -#define SHOW_CKSUM 0x4000 -#define SHOW_FMTREV 0x8000 +#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 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 c1c8816..401cf13 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$"); #include "info.h" #include <err.h> -static char Options[] = "acdDe:fgGhiIkl:LmoO:pqrRst:vVW:x"; +static char Options[] = "acdDe:fgGhiIkl:LmoO:pPqrRst:vVW:x"; int Flags = 0; match_t MatchType = MATCH_GLOB; @@ -177,6 +177,10 @@ main(int argc, char **argv) break; } + case 'P': + Flags = SHOW_PTREV; + break; + case 'h': case '?': default: @@ -188,6 +192,13 @@ main(int argc, char **argv) argc -= optind; argv += optind; + if (Flags & SHOW_PTREV) { + if (!Quiet) + printf("Package tools revision: "); + printf("%d\n", PKG_INSTALL_VERSION); + exit(0); + } + /* Set some reasonable defaults */ if (!Flags) Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY; diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1 index c4a97ba..f618e01 100644 --- a/usr.sbin/pkg_install/info/pkg_info.1 +++ b/usr.sbin/pkg_install/info/pkg_info.1 @@ -25,7 +25,7 @@ .Nd a utility for displaying information on software packages .Sh SYNOPSIS .Nm -.Op Fl cdDfgGiIkLmopqrRsvVx +.Op Fl cdDfgGiIkLmopPqrRsvVx .Op Fl e Ar package .Op Fl l Ar prefix .Op Fl t Ar template @@ -174,6 +174,8 @@ indeed to overflow it. .Ed .It Fl V Show revision number of the packing list format. +.It Fl P +Show revision number of package tools. .El .Sh TECHNICAL DETAILS Package info is either extracted from package files named on the diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 6a01fac..00b735e 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -82,6 +82,15 @@ /* The name of the "prefix" environment variable given to scripts */ #define PKG_PREFIX_VNAME "PKG_PREFIX" +/* + * Version of the package tools - increase only when some + * functionality used by bsd.port.mk is changed, added or removed + */ +#define PKG_INSTALL_VERSION 20020908 + +#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 #define PLIST_FMT_VER_MINOR 1 @@ -190,6 +199,7 @@ Boolean make_preserve_name(char *, int, const char *, const char *); /* For all */ int pkg_perform(char **); +int real_main(int, char **); /* Query installed packages */ char **matchinstalled(match_t, char **, int *); diff --git a/usr.sbin/pkg_install/lib/pkgwrap.c b/usr.sbin/pkg_install/lib/pkgwrap.c new file mode 100644 index 0000000..cbd15cd --- /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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "lib.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) +{ + 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)); +} |