void trig_incorporate(enum modstatdb_rw cstatus) { enum trigdef_update_status ur; enum trigdef_updateflags tduf; free(triggersdir); triggersdir = dpkg_db_get_path(TRIGGERSDIR); free(triggersfilefile); triggersfilefile = trig_get_filename(triggersdir, "File"); free(triggersnewfilefile); triggersnewfilefile = trig_get_filename(triggersdir, "File.new"); trigdef_set_methods(&tdm_incorp); trig_file_interests_ensure(); tduf = tduf_nolockok; if (cstatus >= msdbrw_write) { tduf |= tduf_write; if (trigh.transitional_activate) tduf |= tduf_writeifenoent; } ur = trigdef_update_start(tduf); if (ur == tdus_error_no_dir && cstatus >= msdbrw_write) { if (mkdir(triggersdir, 0755)) { if (errno != EEXIST) ohshite(_("unable to create triggers state" " directory `%.250s'"), triggersdir); } else if (chown(triggersdir, 0, 0)) { ohshite(_("unable to set ownership of triggers state" " directory `%.250s'"), triggersdir); } ur = trigdef_update_start(tduf); } switch (ur) { case tdus_error_empty_deferred: return; case tdus_error_no_dir: case tdus_error_no_deferred: if (!trigh.transitional_activate) return; /* Fall through. */ case tdus_no_deferred: trigh.transitional_activate(cstatus); break; case tdus_ok: /* Read and incorporate triggers. */ trigdef_parse(); break; default: internerr("unknown trigdef_update_start return value '%d'", ur); } /* Right, that's it. New (empty) Unincorp can be installed. */ trigdef_process_done(); }
void trig_incorporate(enum modstatdb_rw cstatus) { enum trigdef_update_status ur; enum trigdef_update_flags tduf; free(triggersdir); triggersdir = dpkg_db_get_path(TRIGGERSDIR); free(triggersfilefile); triggersfilefile = trig_get_filename(triggersdir, TRIGGERSFILEFILE); trigdef_set_methods(&tdm_incorp); trig_file_interests_ensure(); tduf = TDUF_NO_LOCK_OK; if (cstatus >= msdbrw_write) { tduf |= TDUF_WRITE; if (trigh.transitional_activate) tduf |= TDUF_WRITE_IF_ENOENT; } ur = trigdef_update_start(tduf); if (ur == TDUS_ERROR_NO_DIR && cstatus >= msdbrw_write) { if (mkdir(triggersdir, 0755)) { if (errno != EEXIST) ohshite(_("unable to create triggers state" " directory '%.250s'"), triggersdir); } else if (chown(triggersdir, 0, 0)) { ohshite(_("unable to set ownership of triggers state" " directory '%.250s'"), triggersdir); } ur = trigdef_update_start(tduf); } switch (ur) { case TDUS_ERROR_EMPTY_DEFERRED: return; case TDUS_ERROR_NO_DIR: case TDUS_ERROR_NO_DEFERRED: if (!trigh.transitional_activate) return; /* Fall through. */ case TDUS_NO_DEFERRED: trigh.transitional_activate(cstatus); break; case TDUS_OK: /* Read and incorporate triggers. */ trigdef_parse(); break; default: internerr("unknown trigdef_update_start return value '%d'", ur); } /* Right, that's it. New (empty) Unincorp can be installed. */ trigdef_process_done(); }