main.h 8.6 KB

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