static void DPKG_ATTR_NORET usage(const struct cmdinfo *ci, const char *value) { printf(_( "Usage: %s [<options> ...] <trigger-name>\n" " %s [<options> ...] <command>\n" "\n"), dpkg_get_progname(), dpkg_get_progname()); printf(_( "Commands:\n" " --check-supported Check if the running dpkg supports triggers.\n" "\n")); printf(_( " -?, --help Show this help message.\n" " --version Show the version.\n" "\n")); printf(_( "Options:\n" " --admindir=<directory> Use <directory> instead of %s.\n" " --by-package=<package> Override trigger awaiter (normally set\n" " by dpkg).\n" " --await Package needs to await the processing.\n" " --no-await No package needs to await the processing.\n" " --no-act Just test - don't actually change anything.\n" "\n"), ADMINDIR); m_output(stdout, _("<standard output>")); exit(0); }
static void print_abort_error(const char *etype, const char *emsg) { fprintf(stderr, _("%s%s%s: %s%s:%s\n %s\n"), color_get(COLOR_PROG), dpkg_get_progname(), color_reset(), color_get(COLOR_ERROR), etype, color_reset(), emsg); }
static void DPKG_ATTR_NORET usage(const struct cmdinfo *cip, const char *value) { printf(_( "Usage: %s [<option> ...] <command>\n" "\n"), dpkg_get_progname()); printf(_( "Commands:\n" " --add <owner> <group> <mode> <path>\n" " add a new <path> entry into the database.\n" " --remove <path> remove <path> from the database.\n" " --list [<glob-pattern>] list current overrides in the database.\n" "\n")); printf(_( "Options:\n" " --admindir <directory> set the directory with the statoverride file.\n" " --update immediately update <path> permissions.\n" " --force force an action even if a sanity check fails.\n" " --quiet quiet operation, minimal output.\n" " --help show this help message.\n" " --version show the version.\n" "\n")); m_output(stdout, _("<standard output>")); exit(0); }
void print_fatal_error(const char *emsg, const void *data) { fprintf(stderr, "%s%s:%s %s%s:%s %s\n", color_get(COLOR_PROG), dpkg_get_progname(), color_reset(), color_get(COLOR_ERROR), _("error"), color_reset(), emsg); }
void parse_force(const char *value, bool set) { const char *comma; size_t l; const struct forceinfo *fip; if (strcmp(value, "help") == 0) { printf(_( "%s forcing options - control behaviour when problems found:\n" " warn but continue: --force-<thing>,<thing>,...\n" " stop with error: --refuse-<thing>,<thing>,... | --no-force-<thing>,...\n" " Forcing things:\n"), dpkg_get_progname()); for (fip = forceinfos; fip->name; fip++) if ((enum force_flags)fip->flag == FORCE_ALL || (fip->flag & force_mask) == fip->flag) print_forceinfo(fip); printf(_( "\n" "WARNING - use of options marked [!] can seriously damage your installation.\n" "Forcing options marked [*] are enabled by default.\n")); m_output(stdout, _("<standard output>")); printf(_( "\n" "Currently enabled options:\n" " %s\n"), get_force_string()); exit(0); } for (;;) { comma = strchrnul(value, ','); l = (size_t)(comma - value); for (fip = forceinfos; fip->name; fip++) if (strncmp(fip->name, value, l) == 0 && strlen(fip->name) == l) break; if (!fip->name) { badusage(_("unknown force/refuse option '%.*s'"), (int)min(l, 250), value); } else if (fip->flag) { if (set) set_force(fip->flag); else reset_force(fip->flag); } else { warning(_("obsolete force/refuse option '%s'"), fip->name); } if (*comma == '\0') break; value = ++comma; } }
void warningv(const char *fmt, va_list args) { char buf[1024]; warn_count++; vsnprintf(buf, sizeof(buf), fmt, args); fprintf(stderr, _("%s: warning: %s\n"), dpkg_get_progname(), buf); }
void notice(const char *fmt, ...) { char buf[1024]; va_list args; va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); fprintf(stderr, "%s: %s\n", dpkg_get_progname(), buf); }
static void DPKG_ATTR_NORET do_check(void) { enum trigdef_update_status uf; uf = trigdef_update_start(tduf_nolockok); switch (uf) { case tdus_error_no_dir: fprintf(stderr, _("%s: triggers data directory not yet created\n"), dpkg_get_progname()); exit(1); case tdus_error_no_deferred: fprintf(stderr, _("%s: trigger records not yet in existence\n"), dpkg_get_progname()); exit(1); case tdus_ok: case tdus_error_empty_deferred: exit(0); default: internerr("unknown trigdef_update_start return value '%d'", uf); } }
static void DPKG_ATTR_NORET printversion(const struct cmdinfo *ci, const char *value) { printf(_("Debian %s package trigger utility version %s.\n"), dpkg_get_progname(), DPKG_VERSION_ARCH); printf(_( "This is free software; see the GNU General Public License version 2 or\n" "later for copying conditions. There is NO warranty.\n")); m_output(stdout, _("<standard output>")); exit(0); }
static void printversion(const struct cmdinfo *cip, const char *value) { printf(_("Debian %s version %s.\n"), dpkg_get_progname(), PACKAGE_RELEASE); printf(_( "This is free software; see the GNU General Public License version 2 or\n" "later for copying conditions. There is NO warranty.\n")); m_output(stdout, _("<standard output>")); exit(0); }
void do_internerr(const char *file, int line, const char *func, const char *fmt, ...) { va_list args; va_start(args, fmt); error_context_errmsg_format(fmt, args); va_end(args); fprintf(stderr, "%s%s:%s:%d:%s:%s %s%s:%s %s\n", color_get(COLOR_PROG), dpkg_get_progname(), file, line, func, color_reset(), color_get(COLOR_ERROR), _("internal error"), color_reset(), econtext->errmsg); abort(); }
static void usage(const struct cmdinfo *cip, const char *value) { printf(_( "Usage: %s [<option> ...] <command>\n" "\n"), dpkg_get_progname()); printf(_( "Commands:\n" " [--add] <file> add a diversion.\n" " --remove <file> remove the diversion.\n" " --list [<glob-pattern>] show file diversions.\n" " --listpackage <file> show what package diverts the file.\n" " --truename <file> return the diverted file.\n" "\n")); printf(_( "Options:\n" " --package <package> name of the package whose copy of <file> will not\n" " be diverted.\n" " --local all packages' versions are diverted.\n" " --divert <divert-to> the name used by other packages' versions.\n" " --rename actually move the file aside (or back).\n" " --no-rename do not move the file aside (or back) (default).\n" " --admindir <directory> set the directory with the diversions file.\n" " --instdir <directory> set the root directory, but not the admin dir.\n" " --root <directory> set the directory of the root filesystem.\n" " --test don't do anything, just demonstrate.\n" " --quiet quiet operation, minimal output.\n" " --help show this help message.\n" " --version show the version.\n" "\n")); printf(_( "When adding, default is --local and --divert <original>.distrib.\n" "When removing, --package or --local and --divert must match if specified.\n" "Package preinst/postrm scripts should always specify --package and --divert.\n")); m_output(stdout, _("<standard output>")); exit(0); }
static void test_progname(void) { const char *progname; /* Test initially empty progname. */ progname = dpkg_get_progname(); /* Handle libtool exectuables. */ if (strncmp(progname, "lt-", 3) == 0) progname += 3; test_str(progname, ==, "t-progname"); /* Test setting a new progname. */ dpkg_set_progname("newname"); test_str(dpkg_get_progname(), ==, "newname"); /* Test setting a new progname with path. */ dpkg_set_progname("path/newprogname"); test_str(dpkg_get_progname(), ==, "newprogname"); }
static void print_subproc_error(const char *emsg, const void *data) { fprintf(stderr, _("%s (subprocess): %s\n"), dpkg_get_progname(), emsg); }
/* * Returns package we're to give up on. */ static struct pkginfo * check_trigger_cycle(struct pkginfo *processing_now) { struct trigcyclenode *tcn; struct trigcycleperpkg *tcpp, *tortoise_pkg; struct trigpend *hare_trig, *tortoise_trig; struct pkgiterator *it; struct pkginfo *pkg, *giveup; const char *sep; debug(dbg_triggers, "check_triggers_cycle pnow=%s", pkg_describe(processing_now, pdo_foreign)); tcn = nfmalloc(sizeof(*tcn)); tcn->pkgs = NULL; tcn->then_processed = processing_now; it = pkg_db_iter_new(); while ((pkg = pkg_db_iter_next_pkg(it))) { if (!pkg->trigpend_head) continue; tcpp = nfmalloc(sizeof(*tcpp)); tcpp->pkg = pkg; tcpp->then_trigs = pkg->trigpend_head; tcpp->next = tcn->pkgs; tcn->pkgs = tcpp; } pkg_db_iter_free(it); if (!hare) { debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s first", pkg_describe(processing_now, pdo_foreign)); tcn->next = NULL; hare = tortoise = tcn; return NULL; } tcn->next = NULL; hare->next = tcn; hare = tcn; if (tortoise_advance) tortoise = tortoise->next; tortoise_advance = !tortoise_advance; /* Now we compare hare to tortoise. * We want to find a trigger pending in tortoise which is not in hare * if we find such a thing we have proved that hare isn't a superset * of tortoise and so that we haven't found a loop (yet). */ for (tortoise_pkg = tortoise->pkgs; tortoise_pkg; tortoise_pkg = tortoise_pkg->next) { const char *pnow_name, *tortoise_name; pnow_name = pkg_describe(processing_now, pdo_foreign); tortoise_name = pkg_describe(tortoise_pkg->pkg, pdo_foreign); debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s tortoise=%s", pnow_name, tortoise_name); for (tortoise_trig = tortoise_pkg->then_trigs; tortoise_trig; tortoise_trig = tortoise_trig->next) { debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s tortoise=%s" " tortoisetrig=%s", pnow_name, tortoise_name, tortoise_trig->name); /* hare is now so we can just look up in the actual * data. */ for (hare_trig = tortoise_pkg->pkg->trigpend_head; hare_trig; hare_trig = hare_trig->next) { debug(dbg_triggersstupid, "check_triggers_cycle pnow=%s tortoise=%s" " tortoisetrig=%s haretrig=%s", pnow_name, tortoise_name, tortoise_trig->name, hare_trig->name); if (!strcmp(hare_trig->name, tortoise_trig->name)) goto found_in_hare; } /* Not found in hare, yay! */ debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s tortoise=%s OK", pnow_name, tortoise_name); return NULL; found_in_hare:; } } /* Oh dear. hare is a superset of tortoise. We are making no * progress. */ fprintf(stderr, _("%s: cycle found while processing triggers:\n chain of" " packages whose triggers are or may be responsible:\n"), dpkg_get_progname()); sep = " "; for (tcn = tortoise; tcn; tcn = tcn->next) { fprintf(stderr, "%s%s", sep, pkg_describe(tcn->then_processed, pdo_foreign)); sep = " -> "; } fprintf(stderr, _("\n" " packages' pending triggers which are" " or may be unresolvable:\n")); for (tortoise_pkg = tortoise->pkgs; tortoise_pkg; tortoise_pkg = tortoise_pkg->next) { fprintf(stderr, " %s", pkg_describe(tortoise_pkg->pkg, pdo_foreign)); sep = ": "; for (tortoise_trig = tortoise_pkg->then_trigs; tortoise_trig; tortoise_trig = tortoise_trig->next) { fprintf(stderr, "%s%s", sep, tortoise_trig->name); } fprintf(stderr, "\n"); } /* We give up on the _earliest_ package involved. */ giveup = tortoise->pkgs->pkg; debug(dbg_triggers, "check_triggers_cycle pnow=%s giveup=%p", pkg_describe(processing_now, pdo_foreign), pkg_describe(giveup, pdo_foreign)); assert(giveup->status == stat_triggersawaited || giveup->status == stat_triggerspending); giveup->status = stat_halfconfigured; modstatdb_note(giveup); print_error_perpackage(_("triggers looping, abandoned"), pkg_describe(giveup, pdo_foreign)); return giveup; }