static const char * parse_awaiter_package(void) { struct dpkg_error err = DPKG_ERROR_INIT; struct pkginfo *pkg; if (!f_await) bypackage = "-"; if (bypackage == NULL) { const char *pkgname, *archname; pkgname = getenv("DPKG_MAINTSCRIPT_PACKAGE"); archname = getenv("DPKG_MAINTSCRIPT_ARCH"); if (pkgname == NULL || archname == NULL) ohshit(_("must be called from a maintainer script" " (or with a --by-package option)")); pkg = pkg_spec_find_pkg(pkgname, archname, &err); } else if (strcmp(bypackage, "-") == 0) { pkg = NULL; } else { pkg = pkg_spec_parse_pkg(bypackage, &err); } /* Normalize the bypackage name if there was no error. */ if (pkg) bypackage = pkg_name(pkg, pnaw_nonambig); return err.str; }
static void enqueue_specified(const char *const *argv) { const char *thisarg; while ((thisarg = *argv++) != NULL) { struct dpkg_error err; struct pkginfo *pkg; pkg = pkg_spec_parse_pkg(thisarg, &err); if (pkg == NULL) badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), cipaction->olong, thisarg, err.str); if (pkg->status == stat_notinstalled) { size_t l = strlen(pkg->set->name); const char *extension = pkg->set->name + l - sizeof(DEBEXT) + 1; if (l >= sizeof(DEBEXT) && strcmp(extension, DEBEXT) == 0) badusage(_("you must specify packages by their own names," " not by quoting the names of the files they come in")); } enqueue_package(pkg); } }
static void tdm_incorp_package(const char *awname) { struct pkginfo *aw; if (strcmp(awname, "-") == 0) aw = NULL; else aw = pkg_spec_parse_pkg(awname, NULL); dtki->activate_awaiter(aw); }
void trig_file_interests_ensure(void) { FILE *f; char linebuf[1024], *space; struct pkginfo *pkg; struct pkgbin *pkgbin; if (filetriggers_edited >= 0) return; f = fopen(triggersfilefile, "r"); if (!f) { if (errno == ENOENT) goto ok; ohshite(_("unable to read file triggers file '%.250s'"), triggersfilefile); } push_cleanup(cu_closestream, ~0, 1, f); while (fgets_checked(linebuf, sizeof(linebuf), f, triggersfilefile) >= 0) { struct dpkg_error err; char *slash; enum trig_options trig_opts = TRIG_AWAIT; space = strchr(linebuf, ' '); if (!space || linebuf[0] != '/') ohshit(_("syntax error in file triggers file '%.250s'"), triggersfilefile); *space++ = '\0'; slash = strchr(space, '/'); if (slash && strcmp("/noawait", slash) == 0) { trig_opts = TRIG_NOAWAIT; *slash = '\0'; } if (slash && strcmp("/await", slash) == 0) { trig_opts = TRIG_AWAIT; *slash = '\0'; } pkg = pkg_spec_parse_pkg(space, &err); if (pkg == NULL) ohshit(_("file triggers record mentions illegal " "package name '%.250s' (for interest in file " "'%.250s'): %.250s"), space, linebuf, err.str); pkgbin = &pkg->installed; trk_file_interest_change(linebuf, pkg, pkgbin, +2, trig_opts); } pop_cleanup(ehflag_normaltidy); ok: filetriggers_edited = 0; }
static void trk_explicit_activate_awaiter(struct pkginfo *aw) { char buf[1024]; struct pkginfo *pend; if (!trk_explicit_f) return; if (fseek(trk_explicit_f, 0, SEEK_SET)) ohshite(_("failed to rewind trigger interest file '%.250s'"), trk_explicit_fn.buf); while (trk_explicit_fgets(buf, sizeof(buf)) >= 0) { struct dpkg_error err; char *slash; bool noawait = false; slash = strchr(buf, '/'); if (slash && strcmp("/noawait", slash) == 0) { noawait = true; *slash = '\0'; } if (slash && strcmp("/await", slash) == 0) { noawait = false; *slash = '\0'; } pend = pkg_spec_parse_pkg(buf, &err); if (pend == NULL) ohshit(_("trigger interest file '%.250s' syntax error; " "illegal package name '%.250s': %.250s"), trk_explicit_fn.buf, buf, err.str); trig_record_activation(pend, noawait ? NULL : aw, trk_explicit_trig); } }
int setselections(const char *const *argv) { enum modstatdb_rw msdbflags; const struct namevalue *nv; struct pkginfo *pkg; int c, lno; struct varbuf namevb = VARBUF_INIT; struct varbuf selvb = VARBUF_INIT; bool db_possibly_outdated = false; if (*argv) badusage(_("--%s takes no arguments"), cipaction->olong); msdbflags = msdbrw_available_readonly; if (f_noact) msdbflags |= msdbrw_readonly; else msdbflags |= msdbrw_write; modstatdb_open(msdbflags); pkg_infodb_upgrade(); lno= 1; for (;;) { struct dpkg_error err; do { c= getchar(); if (c == '\n') lno++; } while (c != EOF && isspace(c)); if (c == EOF) break; if (c == '#') { do { c= getchar(); if (c == '\n') lno++; } while (c != EOF && c != '\n'); continue; } varbuf_reset(&namevb); while (!isspace(c)) { varbuf_add_char(&namevb, c); c= getchar(); if (c == EOF) ohshit(_("unexpected eof in package name at line %d"),lno); if (c == '\n') ohshit(_("unexpected end of line in package name at line %d"),lno); } varbuf_end_str(&namevb); while (c != EOF && isspace(c)) { c= getchar(); if (c == EOF) ohshit(_("unexpected eof after package name at line %d"),lno); if (c == '\n') ohshit(_("unexpected end of line after package name at line %d"),lno); } varbuf_reset(&selvb); while (c != EOF && !isspace(c)) { varbuf_add_char(&selvb, c); c= getchar(); } varbuf_end_str(&selvb); while (c != EOF && c != '\n') { c= getchar(); if (!isspace(c)) ohshit(_("unexpected data after package and selection at line %d"),lno); } pkg = pkg_spec_parse_pkg(namevb.buf, &err); if (pkg == NULL) ohshit(_("illegal package name at line %d: %.250s"), lno, err.str); if (!pkg_is_informative(pkg, &pkg->installed) && !pkg_is_informative(pkg, &pkg->available)) { db_possibly_outdated = true; warning(_("package not in database at line %d: %.250s"), lno, namevb.buf); continue; } nv = namevalue_find_by_name(wantinfos, selvb.buf); if (nv == NULL) ohshit(_("unknown wanted status at line %d: %.250s"), lno, selvb.buf); pkg_set_want(pkg, nv->value); if (c == EOF) break; lno++; } if (ferror(stdin)) ohshite(_("read error on standard input")); modstatdb_shutdown(); varbuf_destroy(&namevb); varbuf_destroy(&selvb); if (db_possibly_outdated) warning(_("found unknown packages; this might mean the available database\n" "is outdated, and needs to be updated through a frontend method")); return 0; }