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_long(argc, argv, opts, longopts, NULL)) != -1) { switch(ch) { case 'a': MatchType = MATCH_ALL; break; case 'b': UseBlkSz = TRUE; break; case 'v': 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': 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) && !isURL(*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); }
int main(int argc, char **argv) { int ch; char **pkgs, **start, *tmp; pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { case 'v': 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 'J': Zipper = XZ; 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 'n': Regenerate = FALSE; break; case 0: if (Help) usage(); break; 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; }
int main(int argc, char **argv) { int ch, error=0; lpkg_head_t pkgs; setprogname(argv[0]); while ((ch = getopt(argc, argv, Options)) != -1) { switch (ch) { case 'A': Automatic = TRUE; break; case 'C': config_file = optarg; case 'P': Destdir = optarg; break; case 'f': Force = TRUE; ForceDepends = TRUE; break; case 'I': NoInstall = TRUE; break; case 'K': pkgdb_set_dir(optarg, 3); break; case 'L': NoView = TRUE; break; case 'R': NoRecord = TRUE; break; case 'm': OverrideMachine = optarg; break; case 'n': Fake = TRUE; Verbose = TRUE; break; case 'p': Prefix = optarg; break; case 'U': ReplaceSame = 1; Replace = 1; break; case 'u': Replace = 1; break; case 'V': show_version(); /* NOTREACHED */ case 'v': Verbose = TRUE; break; case 'W': Viewbase = optarg; break; case 'w': View = optarg; break; case 'h': case '?': default: usage(); break; } } argc -= optind; argv += optind; pkg_install_config(); if (Destdir != NULL) { char *pkgdbdir; pkgdbdir = xasprintf("%s/%s", Destdir, config_pkg_dbdir); pkgdb_set_dir(pkgdbdir, 4); free(pkgdbdir); } process_pkg_path(); TAILQ_INIT(&pkgs); if (argc == 0) { /* If no packages, yelp */ warnx("missing package name(s)"); usage(); } if (strcasecmp(do_license_check, "no") == 0) LicenseCheck = 0; else if (strcasecmp(do_license_check, "yes") == 0) LicenseCheck = 1; else if (strcasecmp(do_license_check, "always") == 0) LicenseCheck = 2; else errx(1, "Unknown value of the configuration variable" "CHECK_LICENSE"); if (LicenseCheck) load_license_lists(); /* Get all the remaining package names, if any */ for (; argc > 0; --argc, ++argv) { lpkg_t *lpp; if (IS_STDIN(*argv)) lpp = alloc_lpkg("-"); else lpp = alloc_lpkg(*argv); TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link); } error += pkg_perform(&pkgs); if (error != 0) { warnx("%d package addition%s failed", error, error == 1 ? "" : "s"); exit(1); } exit(0); }
int main(int argc, char **argv) { int ch, err; char **pkgs, **start; char *prog_name = argv[0]; pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != EOF) switch(ch) { case 'v': Verbose = TRUE; break; case 'p': Prefix = optarg; break; case 'I': NoInstall = TRUE; break; case 'R': NoRecord = TRUE; break; case 'n': Fake = TRUE; Verbose = TRUE; break; case 't': PlayPen = optarg; break; case 'S': AddMode = SLAVE; break; case 'M': AddMode = MASTER; break; case 'h': case '?': default: usage(prog_name, NULL); break; } argc -= optind; argv += optind; /* Get all the remaining package names, if any */ while (*argv) *pkgs++ = *argv++; /* If no packages, yelp */ *pkgs = NULL; if (pkgs == start && AddMode != SLAVE) usage(prog_name, "Missing package name(s)"); else if (start[1] && AddMode == MASTER) usage(prog_name, "Only one package name may be specified with master mode"); else if (pkgs != start && AddMode == SLAVE) whinge("Package names ignored in slave mode."); if ((err = pkg_perform(start)) != NULL) { if (Verbose) fprintf(stderr, "%d package addition(s) failed.\n", err); return err; } else return 0; }
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_long(argc, argv, opts, longopts, NULL)) != -1) { switch(ch) { case 'v': 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': default: usage(); break; } } argc -= optind; argv += optind; return pkg_perform(argv); }
int main(int argc, char **argv) { int ch; setprogname(argv[0]); while ((ch = getopt(argc, argv, Options)) != -1) switch (ch) { case 'v': Verbose = TRUE; break; case 'E': create_views = 1; break; case 'I': realprefix = optarg; break; case 'O': PlistOnly = 1; break; case 'R': ReorderDirs = 1; break; case 'U': update_pkgdb = 0; break; case 'p': Prefix = optarg; break; case 's': SizePkg = optarg; break; case 'S': SizeAll = optarg; break; case 'f': Contents = optarg; break; case 'c': Comment = optarg; break; case 'd': Desc = optarg; break; case 'g': DefaultGroup = optarg; break; case 'i': Install = optarg; break; case 'K': _pkgdb_setPKGDB_DIR(optarg); break; case 'k': DeInstall = optarg; break; case 'l': RelativeLinks = 1; break; case 'L': SrcDir = optarg; break; case 'u': DefaultOwner = optarg; break; case 'D': Display = optarg; break; case 'n': Preserve = optarg; break; case 'P': Pkgdeps = optarg; break; case 'T': BuildPkgdeps = optarg; break; case 'C': Pkgcfl = optarg; break; case 'b': BuildVersion = optarg; break; case 'B': BuildInfo = optarg; break; case 'V': show_version(); /* NOTREACHED */ case '?': default: usage(); break; } argc -= optind; argv += optind; if (argc == 0) { warnx("missing package name"); usage(); } if (argc != 1) { warnx("only one package name allowed"); usage(); } if (pkg_perform(*argv)) return 0; if (Verbose) { if (PlistOnly) warnx("package registration failed"); else warnx("package creation failed"); } return 1; }
int main(int argc, char **argv) { char *CheckPkg = NULL; char *BestCheckPkg = NULL; lpkg_t *lpp; int ch; int rc; setprogname(argv[0]); while ((ch = getopt(argc, argv, Options)) != -1) switch (ch) { case '.': /* for backward compatibility */ break; case 'a': Which = WHICH_ALL; break; case 'B': Flags |= SHOW_BUILD_INFO; break; case 'b': Flags |= SHOW_BUILD_VERSION; break; case 'c': Flags |= SHOW_COMMENT; break; case 'D': Flags |= SHOW_DISPLAY; break; case 'd': Flags |= SHOW_DESC; break; case 'E': BestCheckPkg = optarg; break; case 'e': CheckPkg = optarg; break; case 'f': Flags |= SHOW_PLIST; break; case 'F': File2Pkg = 1; break; case 'I': Flags |= SHOW_INDEX; break; case 'i': Flags |= SHOW_INSTALL; break; case 'K': pkgdb_set_dir(optarg, 3); break; case 'k': Flags |= SHOW_DEINSTALL; break; case 'L': Flags |= SHOW_FILES; break; case 'l': InfoPrefix = optarg; break; case 'm': Flags |= SHOW_MTREE; break; case 'N': Flags |= SHOW_BLD_DEPENDS; break; case 'n': Flags |= SHOW_DEPENDS; break; case 'p': Flags |= SHOW_PREFIX; break; case 'Q': Flags |= SHOW_BI_VAR; BuildInfoVariable = optarg; break; case 'q': Quiet = TRUE; break; case 'r': Flags |= SHOW_FULL_REQBY; break; case 'R': Flags |= SHOW_REQBY; break; case 's': Flags |= SHOW_PKG_SIZE; break; case 'S': Flags |= SHOW_ALL_SIZE; break; case 'u': Which = WHICH_USER; break; case 'v': Verbose = TRUE; /* Reasonable definition of 'everything' */ Flags = SHOW_COMMENT | SHOW_DESC | SHOW_PLIST | SHOW_INSTALL | SHOW_DEINSTALL | SHOW_DISPLAY | SHOW_MTREE | SHOW_REQBY | SHOW_BLD_DEPENDS | SHOW_DEPENDS | SHOW_PKG_SIZE | SHOW_ALL_SIZE; break; case 'V': show_version(); /* NOTREACHED */ case 'X': Flags |= SHOW_SUMMARY; break; case 'h': case '?': default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; pkg_install_config(); if (argc == 0 && !Flags && !CheckPkg) { /* No argument or relevant flags specified - assume -I */ Flags = SHOW_INDEX; /* assume -a if neither -u nor -a is given */ if (Which == WHICH_LIST) Which = WHICH_ALL; } if (CheckPkg != NULL && BestCheckPkg != NULL) { warnx("-E and -e are mutally exlusive"); usage(); } if (argc != 0 && CheckPkg != NULL) { warnx("can't give any additional arguments to -e"); usage(); } if (argc != 0 && BestCheckPkg != NULL) { warnx("can't give any additional arguments to -E"); usage(); } if (argc != 0 && Which != WHICH_LIST) { warnx("can't use both -a/-u and package name"); usage(); } /* Set some reasonable defaults */ if (!Flags) Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY | SHOW_DEPENDS | SHOW_DISPLAY; /* -Fe /filename -> change CheckPkg to real packagename */ if (CheckPkg) { if (File2Pkg) { char *s; if (!pkgdb_open(ReadOnly)) err(EXIT_FAILURE, "cannot open pkgdb"); s = pkgdb_retrieve(CheckPkg); if (s == NULL) errx(EXIT_FAILURE, "No matching pkg for %s.", CheckPkg); CheckPkg = xstrdup(s); pkgdb_close(); } return CheckForPkg(CheckPkg); } if (BestCheckPkg) return CheckForBestPkg(BestCheckPkg); TAILQ_INIT(&pkgs); /* Get all the remaining package names, if any */ if (File2Pkg && Which == WHICH_LIST) if (!pkgdb_open(ReadOnly)) { err(EXIT_FAILURE, "cannot open pkgdb"); } while (*argv) { /* pkgdb: if -F flag given, don't add pkgnames to the "pkgs" * queue but rather resolve the given filenames to pkgnames * using pkgdb_retrieve, then add them. */ if (File2Pkg) { char *s; s = pkgdb_retrieve(*argv); if (s) { lpp = alloc_lpkg(s); TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link); } else errx(EXIT_FAILURE, "No matching pkg for %s.", *argv); } else { if (ispkgpattern(*argv)) { switch (add_installed_pkgs_by_pattern(*argv, &pkgs)) { case 0: errx(EXIT_FAILURE, "No matching pkg for %s.", *argv); case -1: errx(EXIT_FAILURE, "Error during search in pkgdb for %s", *argv); } } else { const char *dbdir; dbdir = pkgdb_get_dir(); if (**argv == '/' && strncmp(*argv, dbdir, strlen(dbdir)) == 0) { *argv += strlen(dbdir) + 1; if ((*argv)[strlen(*argv) - 1] == '/') { (*argv)[strlen(*argv) - 1] = 0; } } lpp = alloc_lpkg(*argv); TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link); } } argv++; } if (File2Pkg) pkgdb_close(); /* If no packages, yelp */ if (TAILQ_FIRST(&pkgs) == NULL && Which == WHICH_LIST && !CheckPkg) warnx("missing package name(s)"), usage(); rc = pkg_perform(&pkgs); exit(rc); /* NOTREACHED */ }
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_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { case 'v': 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': 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; }