Index: head/usr.sbin/pkg_install/add/main.c =================================================================== --- head/usr.sbin/pkg_install/add/main.c (revision 159553) +++ head/usr.sbin/pkg_install/add/main.c (revision 159554) @@ -1,332 +1,332 @@ /* * * FreeBSD install - a package for the installation and maintainance * 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. * * Jordan K. Hubbard * 18 July 1993 * * This is the add module. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include "lib.h" #include "add.h" static char Options[] = "hvIRfFnrp:P:SMt:C:K"; char *Prefix = NULL; Boolean PrefixRecursive = FALSE; char *Chroot = NULL; Boolean NoInstall = FALSE; Boolean NoRecord = FALSE; Boolean Remote = FALSE; Boolean KeepPackage = FALSE; Boolean FailOnAlreadyInstalled = TRUE; char *Mode = NULL; char *Owner = NULL; char *Group = NULL; char *PkgName = NULL; char *PkgAddCmd = NULL; char *Directory = NULL; char FirstPen[FILENAME_MAX]; add_mode_t AddMode = NORMAL; #define MAX_PKGS 200 char pkgnames[MAX_PKGS][MAXPATHLEN]; char *pkgs[MAX_PKGS]; struct { int lowver; /* Lowest version number to match */ int hiver; /* Highest version number to match */ const char *directory; /* Directory it lives in */ } releases[] = { { 410000, 410000, "/packages-4.1-release" }, { 420000, 420000, "/packages-4.2-release" }, { 430000, 430000, "/packages-4.3-release" }, { 440000, 440000, "/packages-4.4-release" }, { 450000, 450000, "/packages-4.5-release" }, { 460000, 460001, "/packages-4.6-release" }, { 460002, 460099, "/packages-4.6.2-release" }, { 470000, 470099, "/packages-4.7-release" }, { 480000, 480099, "/packages-4.8-release" }, { 490000, 490099, "/packages-4.9-release" }, { 491000, 491099, "/packages-4.10-release" }, { 492000, 492099, "/packages-4.11-release" }, { 500000, 500099, "/packages-5.0-release" }, { 501000, 501099, "/packages-5.1-release" }, { 502000, 502009, "/packages-5.2-release" }, { 502010, 502099, "/packages-5.2.1-release" }, { 503000, 503099, "/packages-5.3-release" }, { 504000, 504099, "/packages-5.4-release" }, { 600000, 600099, "/packages-6.0-release" }, { 300000, 399000, "/packages-3-stable" }, { 400000, 499000, "/packages-4-stable" }, { 502100, 502128, "/packages-5-current" }, { 503100, 599000, "/packages-5-stable" }, { 600100, 699000, "/packages-6-stable" }, { 700000, 799000, "/packages-7-current" }, { 0, 9999999, "/packages-current" }, { 0, 0, NULL } }; static char *getpackagesite(void); int getosreldate(void); static void usage __P((void)); int main(int argc, char **argv) { int ch, error; char **start; char *cp, *packagesite = NULL, *remotepkg = NULL, *ptr; static char temppackageroot[MAXPATHLEN]; static char pkgaddpath[MAXPATHLEN]; if (*argv[0] != '/' && strchr(argv[0], '/') != NULL) PkgAddCmd = realpath(argv[0], pkgaddpath); else PkgAddCmd = argv[0]; start = argv; while ((ch = getopt(argc, argv, Options)) != -1) { switch(ch) { case 'v': - Verbose = TRUE; + Verbose++; break; case 'p': Prefix = optarg; PrefixRecursive = FALSE; break; case 'P': Prefix = optarg; PrefixRecursive = TRUE; break; case 'I': NoInstall = TRUE; break; case 'R': NoRecord = TRUE; break; case 'f': Force = TRUE; break; case 'F': FailOnAlreadyInstalled = FALSE; break; case 'K': KeepPackage = TRUE; break; case 'n': Fake = TRUE; break; case 'r': Remote = TRUE; break; case 't': if (strlcpy(FirstPen, optarg, sizeof(FirstPen)) >= sizeof(FirstPen)) errx(1, "-t Argument too long."); break; case 'S': AddMode = SLAVE; break; case 'M': AddMode = MASTER; break; case 'C': Chroot = optarg; break; case 'h': case '?': default: usage(); break; } } argc -= optind; argv += optind; if (argc > MAX_PKGS) { errx(1, "too many packages (max %d)", MAX_PKGS); } if (AddMode != SLAVE) { for (ch = 0; ch < MAX_PKGS; pkgs[ch++] = NULL) ; /* Get all the remaining package names, if any */ for (ch = 0; *argv; ch++, argv++) { if (Remote) { if ((packagesite = getpackagesite()) == NULL) errx(1, "package name too long"); if (strlcpy(temppackageroot, packagesite, sizeof(temppackageroot)) >= sizeof(temppackageroot)) errx(1, "package name too long"); if (strlcat(temppackageroot, *argv, sizeof(temppackageroot)) >= sizeof(temppackageroot)) errx(1, "package name too long"); remotepkg = temppackageroot; if (!((ptr = strrchr(remotepkg, '.')) && ptr[1] == 't' && (ptr[2] == 'b' || ptr[2] == 'g') && ptr[3] == 'z' && !ptr[4])) if (strlcat(remotepkg, #if defined(__FreeBSD_version) && __FreeBSD_version >= 500039 ".tbz", #else ".tgz", #endif sizeof(temppackageroot)) >= sizeof(temppackageroot)) errx(1, "package name too long"); } if (!strcmp(*argv, "-")) /* stdin? */ pkgs[ch] = (char *)"-"; else if (isURL(*argv)) { /* preserve URLs */ if (strlcpy(pkgnames[ch], *argv, sizeof(pkgnames[ch])) >= sizeof(pkgnames[ch])) errx(1, "package name too long"); pkgs[ch] = pkgnames[ch]; } else if ((Remote) && isURL(remotepkg)) { if (strlcpy(pkgnames[ch], remotepkg, sizeof(pkgnames[ch])) >= sizeof(pkgnames[ch])) errx(1, "package name too long"); pkgs[ch] = pkgnames[ch]; } else { /* expand all pathnames to fullnames */ if (fexists(*argv)) /* refers to a file directly */ pkgs[ch] = realpath(*argv, pkgnames[ch]); else { /* look for the file in the expected places */ if (!(cp = fileFindByPath(NULL, *argv))) { /* let pkg_do() fail later, so that error is reported */ if (strlcpy(pkgnames[ch], *argv, sizeof(pkgnames[ch])) >= sizeof(pkgnames[ch])) errx(1, "package name too long"); pkgs[ch] = pkgnames[ch]; } else { if (strlcpy(pkgnames[ch], cp, sizeof(pkgnames[ch])) >= sizeof(pkgnames[ch])) errx(1, "package name too long"); pkgs[ch] = pkgnames[ch]; } } } if (packagesite != NULL) packagesite[0] = '\0'; } } /* If no packages, yelp */ else if (!ch) { warnx("missing package name(s)"); usage(); } else if (ch > 1 && AddMode == MASTER) { warnx("only one package name may be specified with master mode"); usage(); } /* Perform chroot if requested */ if (Chroot != NULL) { if (chroot(Chroot)) errx(1, "chroot to %s failed", Chroot); } /* Make sure the sub-execs we invoke get found */ setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin", 1); /* Set a reasonable umask */ umask(022); if ((error = pkg_perform(pkgs)) != 0) { if (Verbose) warnx("%d package addition(s) failed", error); return error; } else return 0; } static char * getpackagesite(void) { int reldate, i; static char sitepath[MAXPATHLEN]; struct utsname u; if (getenv("PACKAGESITE")) { if (strlcpy(sitepath, getenv("PACKAGESITE"), sizeof(sitepath)) >= sizeof(sitepath)) return NULL; return sitepath; } if (getenv("PACKAGEROOT")) { if (strlcpy(sitepath, getenv("PACKAGEROOT"), sizeof(sitepath)) >= sizeof(sitepath)) return NULL; } else { if (strlcat(sitepath, "ftp://ftp.freebsd.org", sizeof(sitepath)) >= sizeof(sitepath)) return NULL; } if (strlcat(sitepath, "/pub/FreeBSD/ports/", sizeof(sitepath)) >= sizeof(sitepath)) return NULL; uname(&u); if (strlcat(sitepath, u.machine, sizeof(sitepath)) >= sizeof(sitepath)) return NULL; reldate = getosreldate(); for(i = 0; releases[i].directory != NULL; i++) { if (reldate >= releases[i].lowver && reldate <= releases[i].hiver) { if (strlcat(sitepath, releases[i].directory, sizeof(sitepath)) >= sizeof(sitepath)) return NULL; break; } } if (strlcat(sitepath, "/Latest/", sizeof(sitepath)) >= sizeof(sitepath)) return NULL; return sitepath; } static void usage() { fprintf(stderr, "%s\n%s\n", "usage: pkg_add [-vInrfRMSK] [-t template] [-p prefix] [-P prefix] [-C chrootdir]", " pkg-name [pkg-name ...]"); exit(1); } Index: head/usr.sbin/pkg_install/create/main.c =================================================================== --- head/usr.sbin/pkg_install/create/main.c (revision 159553) +++ head/usr.sbin/pkg_install/create/main.c (revision 159554) @@ -1,239 +1,239 @@ /* * FreeBSD install - a package for the installation and maintainance * of non-core utilities. * * Jordan K. Hubbard * 18 July 1993 * * This is the create module. * */ #include __FBSDID("$FreeBSD$"); #include #include "lib.h" #include "create.h" static char Options[] = "EGYNORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:"; match_t MatchType = MATCH_GLOB; char *Prefix = NULL; char *Comment = NULL; char *Desc = NULL; char *SrcDir = NULL; char *BaseDir = NULL; char *Display = NULL; char *Install = NULL; char *PostInstall = NULL; char *DeInstall = NULL; char *PostDeInstall = NULL; char *Contents = NULL; char *Require = NULL; char *ExcludeFrom = NULL; char *Mtree = NULL; char *Pkgdeps = NULL; char *Conflicts = NULL; char *Origin = NULL; char *InstalledPkg = NULL; char PlayPen[FILENAME_MAX]; int Dereference = FALSE; int PlistOnly = FALSE; int Recursive = FALSE; #if defined(__FreeBSD_version) && __FreeBSD_version >= 500039 enum zipper Zipper = BZIP2; #else enum zipper Zipper = GZIP; #endif static void usage __P((void)); int main(int argc, char **argv) { int ch; char **pkgs, **start, *tmp; pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != -1) switch(ch) { case 'v': - Verbose = TRUE; + Verbose++; break; case 'x': MatchType = MATCH_REGEX; break; case 'E': MatchType = MATCH_EREGEX; break; case 'G': MatchType = MATCH_EXACT; break; case 'N': AutoAnswer = NO; break; case 'Y': AutoAnswer = YES; break; case 'O': PlistOnly = TRUE; break; case 'p': Prefix = optarg; break; case 's': SrcDir = optarg; break; case 'S': BaseDir = optarg; break; case 'f': Contents = optarg; break; case 'C': Conflicts = optarg; break; case 'c': Comment = optarg; break; case 'd': Desc = optarg; break; case 'i': Install = optarg; break; case 'I': PostInstall = optarg; break; case 'k': DeInstall = optarg; break; case 'K': PostDeInstall = optarg; break; case 'r': Require = optarg; break; case 't': strlcpy(PlayPen, optarg, sizeof(PlayPen)); break; case 'X': ExcludeFrom = optarg; break; case 'h': Dereference = TRUE; break; case 'D': Display = optarg; break; case 'm': Mtree = optarg; break; case 'P': Pkgdeps = optarg; break; case 'o': Origin = optarg; break; case 'y': case 'j': Zipper = BZIP2; break; case 'z': Zipper = GZIP; break; case 'b': InstalledPkg = optarg; while ((tmp = strrchr(optarg, (int)'/')) != NULL) { *tmp++ = '\0'; /* * If character after the '/' is alphanumeric, then we've * found the package name. Otherwise we've come across * a trailing '/' and need to continue our quest. */ if (isalpha(*tmp)) { InstalledPkg = tmp; break; } } break; case 'R': Recursive = TRUE; break; case '?': default: usage(); break; } argc -= optind; argv += optind; /* Get all the remaining package names, if any */ while (*argv) *pkgs++ = *argv++; /* If no packages, yelp */ if ((pkgs == start) && (InstalledPkg == NULL)) warnx("missing package name"), usage(); *pkgs = NULL; if ((start[0] != NULL) && (start[1] != NULL)) { warnx("only one package name allowed ('%s' extraneous)", start[1]); usage(); } if (start[0] == NULL) start[0] = InstalledPkg; if (!pkg_perform(start)) { if (Verbose) warnx("package creation failed"); return 1; } else return 0; } static void usage() { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n", "usage: pkg_create [-YNOhvyz] [-P pkgs] [-C conflicts] [-p prefix] ", " [-i iscript] [-I piscript] [-k dscript] [-K pdscript] ", " [-r rscript] [-t template] [-X excludefile] ", " [-D displayfile] [-m mtreefile] [-o origin] ", " [-s srcdir] [-S basedir] ", " -c comment -d description -f packlist pkg-filename", " pkg_create [-EGYNhvxyzR] -b pkg-name [pkg-filename]"); exit(1); } Index: head/usr.sbin/pkg_install/delete/main.c =================================================================== --- head/usr.sbin/pkg_install/delete/main.c (revision 159553) +++ head/usr.sbin/pkg_install/delete/main.c (revision 159554) @@ -1,161 +1,161 @@ /* * * FreeBSD install - a package for the installation and maintainance * 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. * * Jordan K. Hubbard * 18 July 1993 * * This is the delete module. * */ #include __FBSDID("$FreeBSD$"); #include #include #include #include "lib.h" #include "delete.h" static char Options[] = "adDfGhinp:rvxX"; char *Prefix = NULL; Boolean CleanDirs = FALSE; Boolean Interactive = FALSE; Boolean NoDeInstall = FALSE; Boolean Recursive = FALSE; match_t MatchType = MATCH_GLOB; static void usage __P((void)); int main(int argc, char **argv) { int ch, error; char **pkgs, **start; char *pkgs_split; const char *tmp; struct stat stat_s; pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != -1) switch(ch) { case 'v': - Verbose = TRUE; + Verbose++; break; case 'f': Force = TRUE; break; case 'p': Prefix = optarg; break; case 'D': NoDeInstall = TRUE; break; case 'd': CleanDirs = TRUE; break; case 'n': Fake = TRUE; Verbose = TRUE; break; case 'a': MatchType = MATCH_ALL; break; case 'G': MatchType = MATCH_EXACT; break; case 'x': MatchType = MATCH_REGEX; break; case 'X': MatchType = MATCH_EREGEX; break; case 'i': Interactive = TRUE; break; case 'r': Recursive = TRUE; break; case 'h': case '?': default: usage(); break; } argc -= optind; argv += optind; /* Get all the remaining package names, if any */ while (*argv) { /* Don't try to apply heuristics if arguments are regexs */ if (MatchType != MATCH_REGEX) while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) { *pkgs_split++ = '\0'; /* * If character after the '/' is alphanumeric, then we've found the * package name. Otherwise we've come across a trailing '/' and * need to continue our quest. */ if (isalnum(*pkgs_split) || ((MatchType == MATCH_GLOB) && \ strpbrk(pkgs_split, "*?[]") != NULL)) { *argv = pkgs_split; break; } } *pkgs++ = *argv++; } /* If no packages, yelp */ if (pkgs == start && MatchType != MATCH_ALL) warnx("missing package name(s)"), usage(); *pkgs = NULL; tmp = LOG_DIR; (void) stat(tmp, &stat_s); if (!Fake && getuid() && geteuid() != stat_s.st_uid) { if (!Force) errx(1, "you do not own %s, use -f to force", tmp); else warnx("you do not own %s (proceeding anyways)", tmp); } if ((error = pkg_perform(start)) != 0) { if (Verbose) warnx("%d package deletion(s) failed", error); return error; } else return 0; } static void usage() { fprintf(stderr, "%s\n%s\n", "usage: pkg_delete [-dDfGinrvxX] [-p prefix] pkg-name ...", " pkg_delete -a [flags]"); exit(1); } Index: head/usr.sbin/pkg_install/info/main.c =================================================================== --- head/usr.sbin/pkg_install/info/main.c (revision 159553) +++ head/usr.sbin/pkg_install/info/main.c (revision 159554) @@ -1,275 +1,275 @@ /* * * FreeBSD install - a package for the installation and maintainance * 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. * * Jordan K. Hubbard * 18 July 1993 * * This is the info module. * */ #include __FBSDID("$FreeBSD$"); #include "lib.h" #include "info.h" #include static char Options[] = "abcdDe:EfgGhiIjkKl:LmoO:pPqQrRst:vVW:xX"; int Flags = 0; match_t MatchType = MATCH_GLOB; Boolean QUIET = FALSE; Boolean UseBlkSz = FALSE; char *InfoPrefix = (char *)(uintptr_t)""; char PlayPen[FILENAME_MAX]; char *CheckPkg = NULL; char *LookUpOrigin = NULL; Boolean KeepPackage = FALSE; struct which_head *whead; static void usage __P((void)); int main(int argc, char **argv) { int ch; char **pkgs, **start; char *pkgs_split; whead = malloc(sizeof(struct which_head)); if (whead == NULL) err(2, NULL); TAILQ_INIT(whead); pkgs = start = argv; if (argc == 1) { MatchType = MATCH_ALL; Flags = SHOW_INDEX; } else while ((ch = getopt(argc, argv, Options)) != -1) { switch(ch) { case 'a': MatchType = MATCH_ALL; break; case 'b': UseBlkSz = TRUE; break; case 'v': - Verbose = TRUE; + Verbose++; /* Reasonable definition of 'everything' */ Flags = SHOW_COMMENT | SHOW_DESC | SHOW_PLIST | SHOW_INSTALL | SHOW_DEINSTALL | SHOW_REQUIRE | SHOW_DISPLAY | SHOW_MTREE; break; case 'E': Flags |= SHOW_PKGNAME; break; case 'I': Flags |= SHOW_INDEX; break; case 'p': Flags |= SHOW_PREFIX; break; case 'c': Flags |= SHOW_COMMENT; break; case 'd': Flags |= SHOW_DESC; break; case 'D': Flags |= SHOW_DISPLAY; break; case 'f': Flags |= SHOW_PLIST; break; case 'g': Flags |= SHOW_CKSUM; break; case 'G': MatchType = MATCH_EXACT; break; case 'i': Flags |= SHOW_INSTALL; break; case 'j': Flags |= SHOW_REQUIRE; break; case 'k': Flags |= SHOW_DEINSTALL; break; case 'K': KeepPackage = TRUE; break; case 'r': Flags |= SHOW_DEPEND; break; case 'R': Flags |= SHOW_REQBY; break; case 'L': Flags |= SHOW_FILES; break; case 'm': Flags |= SHOW_MTREE; break; case 's': Flags |= SHOW_SIZE; break; case 'o': Flags |= SHOW_ORIGIN; break; case 'O': LookUpOrigin = strdup(optarg); if (LookUpOrigin == NULL) err(2, NULL); break; case 'V': Flags |= SHOW_FMTREV; break; case 'l': InfoPrefix = optarg; break; case 'q': Quiet = TRUE; break; case 'Q': Quiet = TRUE; QUIET = TRUE; break; case 't': strlcpy(PlayPen, optarg, sizeof(PlayPen)); break; case 'x': MatchType = MATCH_REGEX; break; case 'X': MatchType = MATCH_EREGEX; break; case 'e': CheckPkg = optarg; break; case 'W': { struct which_entry *entp; entp = calloc(1, sizeof(struct which_entry)); if (entp == NULL) err(2, NULL); strlcpy(entp->file, optarg, PATH_MAX); entp->skip = FALSE; TAILQ_INSERT_TAIL(whead, entp, next); break; } case 'P': Flags = SHOW_PTREV; break; case 'h': case '?': default: usage(); break; } } 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; /* Get all the remaining package names, if any */ while (*argv) { /* * Don't try to apply heuristics if arguments are regexs or if * the argument refers to an existing file. */ if (MatchType != MATCH_REGEX && MatchType != MATCH_EREGEX && !isfile(*argv)) while ((pkgs_split = strrchr(*argv, (int)'/')) != NULL) { *pkgs_split++ = '\0'; /* * If character after the '/' is alphanumeric or shell * metachar, then we've found the package name. Otherwise * we've come across a trailing '/' and need to continue our * quest. */ if (isalnum(*pkgs_split) || ((MatchType == MATCH_GLOB) && \ strpbrk(pkgs_split, "*?[]") != NULL)) { *argv = pkgs_split; break; } } *pkgs++ = *argv++; } /* If no packages, yelp */ if (pkgs == start && MatchType != MATCH_ALL && !CheckPkg && TAILQ_EMPTY(whead) && LookUpOrigin == NULL) warnx("missing package name(s)"), usage(); *pkgs = NULL; return pkg_perform(start); } static void usage() { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", "usage: pkg_info [-bcdDEfgGiIjkKLmopPqQrRsvVxX] [-e package] [-l prefix]", " [-t template] -a | pkg-name ...", " pkg_info [-qQ] -W filename", " pkg_info [-qQ] -O origin", " pkg_info"); exit(1); } Index: head/usr.sbin/pkg_install/lib/global.c =================================================================== --- head/usr.sbin/pkg_install/lib/global.c (revision 159553) +++ head/usr.sbin/pkg_install/lib/global.c (revision 159554) @@ -1,32 +1,32 @@ /* * FreeBSD install - a package for the installation and maintainance * 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. * * Jordan K. Hubbard * 18 July 1993 * * Semi-convenient place to stick some needed globals. * */ #include __FBSDID("$FreeBSD$"); #include "lib.h" /* These are global for all utils */ Boolean Quiet = FALSE; -Boolean Verbose = FALSE; Boolean Fake = FALSE; Boolean Force = FALSE; int AutoAnswer = FALSE; +int Verbose = 0; /* Allow multiple levels of verbose. */ Index: head/usr.sbin/pkg_install/lib/lib.h =================================================================== --- head/usr.sbin/pkg_install/lib/lib.h (revision 159553) +++ head/usr.sbin/pkg_install/lib/lib.h (revision 159554) @@ -1,238 +1,238 @@ /* $FreeBSD$ */ /* * FreeBSD install - a package for the installation and maintainance * 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. * * Jordan K. Hubbard * 18 July 1993 * * Include and define various things wanted by the library routines. * */ #ifndef _INST_LIB_LIB_H_ #define _INST_LIB_LIB_H_ /* Includes */ #include #include #include #include #include #include #include #include #include #include #include /* Macros */ #define SUCCESS (0) #define FAIL (-1) #ifndef TRUE #define TRUE (1) #endif #ifndef FALSE #define FALSE (0) #endif #define YES 2 #define NO 1 /* Usually "rm", but often "echo" during debugging! */ #define REMOVE_CMD "/bin/rm" /* Usually "rm", but often "echo" during debugging! */ #define RMDIR_CMD "/bin/rmdir" /* Where we put logging information by default, else ${PKG_DBDIR} if set */ #define DEF_LOG_DIR "/var/db/pkg" /* just in case we change the environment variable name */ #define PKG_DBDIR "PKG_DBDIR" /* macro to get name of directory where we put logging information */ #define LOG_DIR (getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR) /* The names of our "special" files */ #define CONTENTS_FNAME "+CONTENTS" #define COMMENT_FNAME "+COMMENT" #define DESC_FNAME "+DESC" #define INSTALL_FNAME "+INSTALL" #define POST_INSTALL_FNAME "+POST-INSTALL" #define DEINSTALL_FNAME "+DEINSTALL" #define POST_DEINSTALL_FNAME "+POST-DEINSTALL" #define REQUIRE_FNAME "+REQUIRE" #define REQUIRED_BY_FNAME "+REQUIRED_BY" #define DISPLAY_FNAME "+DISPLAY" #define MTREE_FNAME "+MTREE_DIRS" #if defined(__FreeBSD_version) && __FreeBSD_version >= 700000 #define INDEX_FNAME "INDEX-7" #elif defined(__FreeBSD_version) && __FreeBSD_version >= 600000 #define INDEX_FNAME "INDEX-6" #elif defined(__FreeBSD_version) && __FreeBSD_version >= 500036 #define INDEX_FNAME "INDEX-5" #else #define INDEX_FNAME "INDEX" #endif #define CMD_CHAR '@' /* prefix for extended PLIST cmd */ /* 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 20040629 #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 enum _plist_t { PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD, PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY, PLIST_PKGDEP, PLIST_CONFLICTS, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST, PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN, PLIST_NOINST }; typedef enum _plist_t plist_t; enum _match_t { MATCH_ALL, MATCH_EXACT, MATCH_GLOB, MATCH_NGLOB, MATCH_EREGEX, MATCH_REGEX }; typedef enum _match_t match_t; /* Types */ typedef unsigned int Boolean; struct _plist { struct _plist *prev, *next; char *name; Boolean marked; plist_t type; }; typedef struct _plist *PackingList; struct _pack { struct _plist *head, *tail; const char *name; const char *origin; int fmtver_maj, fmtver_mnr; }; typedef struct _pack Package; struct reqr_by_entry { STAILQ_ENTRY(reqr_by_entry) link; char pkgname[PATH_MAX]; }; STAILQ_HEAD(reqr_by_head, reqr_by_entry); /* Prototypes */ /* Misc */ int vsystem(const char *, ...); char *vpipe(const char *, ...); void cleanup(int); char *make_playpen(char *, off_t); char *where_playpen(void); void leave_playpen(void); off_t min_free(const char *); /* String */ char *get_dash_string(char **); char *copy_string(const char *); char *copy_string_adds_newline(const char *); Boolean suffix(const char *, const char *); void nuke_suffix(char *); void str_lowercase(char *); char *strconcat(const char *, const char *); char *get_string(char *, int, FILE *); /* File */ Boolean fexists(const char *); Boolean isdir(const char *); Boolean isemptydir(const char *fname); Boolean isemptyfile(const char *fname); Boolean isfile(const char *); Boolean isempty(const char *); Boolean issymlink(const char *); Boolean isURL(const char *); char *fileGetURL(const char *, const char *, int); char *fileFindByPath(const char *, const char *); char *fileGetContents(const char *); void write_file(const char *, const char *); void copy_file(const char *, const char *, const char *); void move_file(const char *, const char *, const char *); void copy_hierarchy(const char *, const char *, Boolean); int delete_hierarchy(const char *, Boolean, Boolean); int unpack(const char *, const char *); void format_cmd(char *, int, const char *, const char *, const char *); /* Msg */ void upchuck(const char *); void barf(const char *, ...); void whinge(const char *, ...); Boolean y_or_n(Boolean, const char *, ...); /* Packing list */ PackingList new_plist_entry(void); PackingList last_plist(Package *); PackingList find_plist(Package *, plist_t); char *find_plist_option(Package *, const char *name); void plist_delete(Package *, Boolean, plist_t, const char *); void free_plist(Package *); void mark_plist(Package *); void csum_plist_entry(char *, PackingList); void add_plist(Package *, plist_t, const char *); void add_plist_top(Package *, plist_t, const char *); void delete_plist(Package *pkg, Boolean all, plist_t type, const char *name); void write_plist(Package *, FILE *); void read_plist(Package *, FILE *); int plist_cmd(const char *, char **); int delete_package(Boolean, Boolean, Package *); 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 *); char **matchbyorigin(const char *, int *); int isinstalledpkg(const char *name); int pattern_match(match_t MatchType, char *pattern, const char *pkgname); /* Dependencies */ int sortdeps(char **); int chkifdepends(const char *, const char *); int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean); /* Version */ int verscmp(Package *, int, int); int version_cmp(const char *, const char *); /* Externs */ extern Boolean Quiet; -extern Boolean Verbose; extern Boolean Fake; extern Boolean Force; extern int AutoAnswer; +extern int Verbose; #endif /* _INST_LIB_LIB_H_ */ Index: head/usr.sbin/pkg_install/version/main.c =================================================================== --- head/usr.sbin/pkg_install/version/main.c (revision 159553) +++ head/usr.sbin/pkg_install/version/main.c (revision 159554) @@ -1,122 +1,122 @@ /* * FreeBSD install - a package for the installation and maintainance * 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. * * Jeremy D. Lea. * 11 May 2002 * * This is the version module. Based on pkg_version.pl by Bruce A. Mah. * */ #include __FBSDID("$FreeBSD$"); #include "lib.h" #include "version.h" #include static char Options[] = "dIhl:L:qs:XtTO:ov"; char *LimitChars = NULL; char *PreventChars = NULL; char *MatchName = NULL; char *LookUpOrigin = NULL; Boolean RegexExtended = FALSE; Boolean UseINDEXOnly = FALSE; Boolean ShowOrigin = FALSE; static void usage __P((void)); int main(int argc, char **argv) { int ch, cmp = 0; if (argc == 4 && !strcmp(argv[1], "-t")) { cmp = version_cmp(argv[2], argv[3]); printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n")); exit(0); } else if (argc == 4 && !strcmp(argv[1], "-T")) { cmp = version_match(argv[3], argv[2]); exit(cmp == 1 ? 0 : 1); } else while ((ch = getopt(argc, argv, Options)) != -1) { switch(ch) { case 'v': - Verbose = TRUE; + Verbose++; break; case 'I': UseINDEXOnly = TRUE; break; case 'l': LimitChars = optarg; break; case 'L': PreventChars = optarg; break; case 'q': Quiet = TRUE; break; case 's': MatchName = optarg; break; case 'O': LookUpOrigin = optarg; break; case 'o': ShowOrigin = TRUE; break; case 't': errx(2, "Invalid -t usage."); break; case 'T': errx(2, "Invalid -T usage."); break; case 'X': RegexExtended = TRUE; break; case 'h': case '?': default: usage(); break; } } argc -= optind; argv += optind; return pkg_perform(argv); } static void usage() { fprintf(stderr, "%s\n%s\n%s\n", "usage: pkg_version [-hIoqv] [-l limchar] [-L limchar] [[-X] -s string] [-O origin] [index]", " pkg_version -t v1 v2", " pkg_version -T name pattern"); exit(1); }