main.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * dpkg - main program for package management
  3. * main.h - external definitions for this program
  4. *
  5. * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef MAIN_H
  21. #define MAIN_H
  22. #include <dpkg/debug.h>
  23. #include <dpkg/pkg-list.h>
  24. /* These two are defined in filesdb.h. */
  25. struct fileinlist;
  26. struct filenamenode;
  27. struct perpackagestate {
  28. enum istobes {
  29. itb_normal, itb_remove, itb_installnew, itb_deconfigure, itb_preinstall
  30. } istobe;
  31. /** Used during cycle detection. */
  32. enum {
  33. white,
  34. gray,
  35. black,
  36. } color;
  37. /**
  38. * filelistvalid files Meaning
  39. * ------------- ----- -------
  40. * false NULL Not read yet, must do so if want them.
  41. * false !NULL Read, but rewritten and now out of date. If want
  42. * info must throw away old and reread file.
  43. * true !NULL Read, all is OK.
  44. * true NULL Read OK, but, there were no files.
  45. */
  46. bool fileslistvalid;
  47. struct fileinlist *files;
  48. int replacingfilesandsaid;
  49. off_t listfile_phys_offs;
  50. /** Non-NULL iff in trigproc.c:deferred. */
  51. struct pkg_list *trigprocdeferred;
  52. };
  53. enum action {
  54. act_unset,
  55. act_unpack,
  56. act_configure,
  57. act_install,
  58. act_triggers,
  59. act_remove,
  60. act_purge,
  61. act_verify,
  62. act_commandfd,
  63. act_status,
  64. act_listpackages,
  65. act_listfiles,
  66. act_searchfiles,
  67. act_controlpath,
  68. act_controllist,
  69. act_controlshow,
  70. act_cmpversions,
  71. act_arch_add,
  72. act_arch_remove,
  73. act_printarch,
  74. act_printinstarch,
  75. act_printforeignarches,
  76. act_assertpredep,
  77. act_assertepoch,
  78. act_assertlongfilenames,
  79. act_assertmulticonrep,
  80. act_assertmultiarch,
  81. act_audit,
  82. act_unpackchk,
  83. act_predeppackage,
  84. act_getselections,
  85. act_setselections,
  86. act_clearselections,
  87. act_avail,
  88. act_printavail,
  89. act_avclear,
  90. act_avreplace,
  91. act_avmerge,
  92. act_forgetold,
  93. };
  94. extern const char *const statusstrings[];
  95. extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
  96. extern int f_autodeconf, f_nodebsig;
  97. extern int f_triggers;
  98. extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
  99. extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
  100. extern int fc_breaks, fc_badpath, fc_overwritediverted, fc_architecture;
  101. extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
  102. extern int fc_conff_old, fc_conff_def;
  103. extern int fc_conff_ask;
  104. extern int fc_badverify;
  105. extern int fc_badversion;
  106. extern int fc_unsafe_io;
  107. extern bool abort_processing;
  108. extern int errabort;
  109. extern const char *instdir;
  110. extern struct pkg_list *ignoredependss;
  111. struct invoke_hook {
  112. struct invoke_hook *next;
  113. const char *command;
  114. };
  115. /* from archives.c */
  116. int archivefiles(const char *const *argv);
  117. void process_archive(const char *filename);
  118. bool wanttoinstall(struct pkginfo *pkg);
  119. struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
  120. struct filenamenode *namenode);
  121. /* from update.c */
  122. int forgetold(const char *const *argv);
  123. int updateavailable(const char *const *argv);
  124. /* from enquiry.c */
  125. int audit(const char *const *argv);
  126. int unpackchk(const char *const *argv);
  127. int assertepoch(const char *const *argv);
  128. int assertpredep(const char *const *argv);
  129. int assertlongfilenames(const char *const *argv);
  130. int assertmulticonrep(const char *const *argv);
  131. int assertmultiarch(const char *const *argv);
  132. int predeppackage(const char *const *argv);
  133. int printarch(const char *const *argv);
  134. int printinstarch(const char *const *argv);
  135. int print_foreign_arches(const char *const *argv);
  136. int cmpversions(const char *const *argv);
  137. /* from verify.c */
  138. int verify_set_output(const char *name);
  139. int verify(const char *const *argv);
  140. /* from select.c */
  141. int getselections(const char *const *argv);
  142. int setselections(const char *const *argv);
  143. int clearselections(const char *const *argv);
  144. /* from packages.c, remove.c and configure.c */
  145. void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn);
  146. void enqueue_package(struct pkginfo *pkg);
  147. void process_queue(void);
  148. int packages(const char *const *argv);
  149. void removal_bulk(struct pkginfo *pkg);
  150. int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in);
  151. enum dep_check {
  152. dep_check_halt = 0,
  153. dep_check_defer = 1,
  154. dep_check_ok = 2,
  155. };
  156. enum dep_check dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
  157. struct varbuf *aemsgs);
  158. enum dep_check breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
  159. void deferred_remove(struct pkginfo *pkg);
  160. void deferred_configure(struct pkginfo *pkg);
  161. extern int sincenothing, dependtry;
  162. /* from cleanup.c (most of these are declared in archives.h) */
  163. void cu_prermremove(int argc, void **argv);
  164. /* from errors.c */
  165. void print_error_perpackage(const char *emsg, const void *data);
  166. void print_error_perarchive(const char *emsg, const void *data);
  167. void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2);
  168. int reportbroken_retexitstatus(int ret);
  169. bool skip_due_to_hold(struct pkginfo *pkg);
  170. /* from help.c */
  171. struct stat;
  172. bool ignore_depends(struct pkginfo *pkg);
  173. bool force_breaks(struct deppossi *possi);
  174. bool force_depends(struct deppossi *possi);
  175. bool force_conflicts(struct deppossi *possi);
  176. void conffile_mark_obsolete(struct pkginfo *pkg, struct filenamenode *namenode);
  177. void oldconffsetflags(const struct conffile *searchconff);
  178. void ensure_pathname_nonexisting(const char *pathname);
  179. int secure_unlink(const char *pathname);
  180. int secure_unlink_statted(const char *pathname, const struct stat *stab);
  181. void checkpath(void);
  182. struct filenamenode *namenodetouse(struct filenamenode *namenode,
  183. struct pkginfo *pkg, struct pkgbin *pkgbin);
  184. int maintscript_installed(struct pkginfo *pkg, const char *scriptname,
  185. const char *desc, ...) DPKG_ATTR_SENTINEL;
  186. int maintscript_new(struct pkginfo *pkg,
  187. const char *scriptname, const char *desc,
  188. const char *cidir, char *cidirrest, ...)
  189. DPKG_ATTR_SENTINEL;
  190. int maintscript_fallback(struct pkginfo *pkg,
  191. const char *scriptname, const char *desc,
  192. const char *cidir, char *cidirrest,
  193. const char *ifok, const char *iffallback);
  194. /* Callers wanting to run the postinst use these two as they want to postpone
  195. * trigger incorporation until after updating the package status. The effect
  196. * is that a package can trigger itself. */
  197. int maintscript_postinst(struct pkginfo *pkg, ...) DPKG_ATTR_SENTINEL;
  198. void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
  199. void clear_istobes(void);
  200. bool dir_is_used_by_others(struct filenamenode *namenode, struct pkginfo *pkg);
  201. bool dir_is_used_by_pkg(struct filenamenode *namenode, struct pkginfo *pkg,
  202. struct fileinlist *list);
  203. bool dir_has_conffiles(struct filenamenode *namenode, struct pkginfo *pkg);
  204. void log_action(const char *action, struct pkginfo *pkg, struct pkgbin *pkgbin);
  205. /* from trigproc.c */
  206. void trigproc_install_hooks(void);
  207. void trigproc_run_deferred(void);
  208. void trigproc_reset_cycle(void);
  209. void trigproc(struct pkginfo *pkg);
  210. void trig_activate_packageprocessing(struct pkginfo *pkg);
  211. /* from depcon.c */
  212. enum which_pkgbin {
  213. wpb_installed,
  214. wpb_available,
  215. wpb_by_istobe,
  216. };
  217. struct deppossi_pkg_iterator;
  218. struct deppossi_pkg_iterator *
  219. deppossi_pkg_iter_new(struct deppossi *possi, enum which_pkgbin wpb);
  220. struct pkginfo *
  221. deppossi_pkg_iter_next(struct deppossi_pkg_iterator *iter);
  222. void
  223. deppossi_pkg_iter_free(struct deppossi_pkg_iterator *iter);
  224. bool depisok(struct dependency *dep, struct varbuf *whynot,
  225. struct pkginfo **fixbyrm, struct pkginfo **fixbytrigaw,
  226. bool allowunconfigd);
  227. struct cyclesofarlink;
  228. bool findbreakcycle(struct pkginfo *pkg);
  229. void describedepcon(struct varbuf *addto, struct dependency *dep);
  230. #endif /* MAIN_H */