static int arch_add(const char *const *argv) { struct dpkg_arch *arch; const char *archname = *argv++; if (archname == NULL || *argv) badusage(_("--%s takes exactly one argument"), cipaction->olong); dpkg_arch_load_list(); arch = dpkg_arch_add(archname); switch (arch->type) { case DPKG_ARCH_NATIVE: case DPKG_ARCH_FOREIGN: break; case DPKG_ARCH_ILLEGAL: ohshit(_("architecture '%s' is illegal: %s"), archname, dpkg_arch_name_is_illegal(archname)); default: ohshit(_("architecture '%s' is reserved and cannot be added"), archname); } dpkg_arch_save_list(); return 0; }
enum modstatdb_rw modstatdb_open(enum modstatdb_rw readwritereq) { modstatdb_init(); cflags = readwritereq & msdbrw_available_mask; readwritereq &= ~msdbrw_available_mask; switch (readwritereq) { case msdbrw_needsuperuser: case msdbrw_needsuperuserlockonly: if (getuid() || geteuid()) ohshit(_("requested operation requires superuser privilege")); /* Fall through. */ case msdbrw_write: case msdbrw_writeifposs: if (access(dpkg_db_get_dir(), W_OK)) { if (errno != EACCES) ohshite(_("unable to access dpkg status area")); else if (readwritereq == msdbrw_write) ohshit(_("operation requires read/write access to dpkg status area")); cstatus= msdbrw_readonly; } else { modstatdb_lock(); cstatus= (readwritereq == msdbrw_needsuperuserlockonly ? msdbrw_needsuperuserlockonly : msdbrw_write); } break; case msdbrw_readonly: cstatus= msdbrw_readonly; break; default: internerr("unknown modstatdb_rw '%d'", readwritereq); } dpkg_arch_load_list(); if (cstatus != msdbrw_needsuperuserlockonly) { cleanupdates(); if (cflags >= msdbrw_available_readonly) parsedb(availablefile, pdb_parse_available, NULL); } if (cstatus >= msdbrw_write) { createimptmp(); varbuf_init(&uvb, 10240); } trig_fixup_awaiters(cstatus); trig_incorporate(cstatus); return cstatus; }
int print_foreign_arches(const char *const *argv) { struct dpkg_arch *arch; if (*argv) badusage(_("--%s takes no arguments"), cipaction->olong); dpkg_arch_load_list(); for (arch = dpkg_arch_get_list(); arch; arch = arch->next) { if (arch->type != DPKG_ARCH_FOREIGN) continue; printf("%s\n", arch->name); } m_output(stdout, _("<standard output>")); return 0; }