main.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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_commandfd,
  62. act_status,
  63. act_listpackages,
  64. act_listfiles,
  65. act_searchfiles,
  66. act_controlpath,
  67. act_controllist,
  68. act_controlshow,
  69. act_cmpversions,
  70. act_arch_add,
  71. act_arch_remove,
  72. act_printarch,
  73. act_printinstarch,
  74. act_printforeignarches,
  75. act_assertpredep,
  76. act_assertepoch,
  77. act_assertlongfilenames,
  78. act_assertmulticonrep,
  79. act_assertmultiarch,
  80. act_audit,
  81. act_unpackchk,
  82. act_predeppackage,
  83. act_getselections,
  84. act_setselections,
  85. act_clearselections,
  86. act_avail,
  87. act_printavail,
  88. act_avclear,
  89. act_avreplace,
  90. act_avmerge,
  91. act_forgetold,
  92. };
  93. extern const char *const statusstrings[];
  94. extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
  95. extern int f_autodeconf, f_nodebsig;
  96. extern int f_triggers;
  97. extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
  98. extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
  99. extern int fc_breaks, fc_badpath, fc_overwritediverted, fc_architecture;
  100. extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
  101. extern int fc_conff_old, fc_conff_def;
  102. extern int fc_conff_ask;
  103. extern int fc_badverify;
  104. extern int fc_badversion;
  105. extern int fc_unsafe_io;
  106. extern bool abort_processing;
  107. extern int errabort;
  108. extern const char *instdir;
  109. extern struct pkg_list *ignoredependss;
  110. struct invoke_hook {
  111. struct invoke_hook *next;
  112. const char *command;
  113. };
  114. /* from archives.c */
  115. int archivefiles(const char *const *argv);
  116. void process_archive(const char *filename);
  117. bool wanttoinstall(struct pkginfo *pkg);
  118. struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
  119. struct filenamenode *namenode);
  120. /* from update.c */
  121. int forgetold(const char *const *argv);
  122. int updateavailable(const char *const *argv);
  123. /* from enquiry.c */
  124. int audit(const char *const *argv);
  125. int unpackchk(const char *const *argv);
  126. int assertepoch(const char *const *argv);
  127. int assertpredep(const char *const *argv);
  128. int assertlongfilenames(const char *const *argv);
  129. int assertmulticonrep(const char *const *argv);
  130. int assertmultiarch(const char *const *argv);
  131. int predeppackage(const char *const *argv);
  132. int printarch(const char *const *argv);
  133. int printinstarch(const char *const *argv);
  134. int print_foreign_arches(const char *const *argv);
  135. int cmpversions(const char *const *argv);
  136. /* from select.c */
  137. int getselections(const char *const *argv);
  138. int setselections(const char *const *argv);
  139. int clearselections(const char *const *argv);
  140. /* from packages.c, remove.c and configure.c */
  141. void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn);
  142. void add_to_queue(struct pkginfo *pkg);
  143. void process_queue(void);
  144. int packages(const char *const *argv);
  145. void removal_bulk(struct pkginfo *pkg);
  146. int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in);
  147. enum dep_check {
  148. dep_check_halt = 0,
  149. dep_check_defer = 1,
  150. dep_check_ok = 2,
  151. };
  152. enum dep_check dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
  153. struct varbuf *aemsgs);
  154. enum dep_check breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
  155. void deferred_remove(struct pkginfo *pkg);
  156. void deferred_configure(struct pkginfo *pkg);
  157. extern int sincenothing, dependtry;
  158. /* from cleanup.c (most of these are declared in archives.h) */
  159. void cu_prermremove(int argc, void **argv);
  160. /* from errors.c */
  161. void print_error_perpackage(const char *emsg, const char *arg);
  162. void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2);
  163. int reportbroken_retexitstatus(int ret);
  164. bool skip_due_to_hold(struct pkginfo *pkg);
  165. /* from help.c */
  166. struct stat;
  167. bool ignore_depends(struct pkginfo *pkg);
  168. bool force_breaks(struct deppossi *possi);
  169. bool force_depends(struct deppossi *possi);
  170. bool force_conflicts(struct deppossi *possi);
  171. void conffile_mark_obsolete(struct pkginfo *pkg, struct filenamenode *namenode);
  172. void oldconffsetflags(const struct conffile *searchconff);
  173. void ensure_pathname_nonexisting(const char *pathname);
  174. int secure_unlink(const char *pathname);
  175. int secure_unlink_statted(const char *pathname, const struct stat *stab);
  176. void checkpath(void);
  177. struct filenamenode *namenodetouse(struct filenamenode *namenode,
  178. struct pkginfo *pkg, struct pkgbin *pkgbin);
  179. int maintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
  180. const char *desc, ...) DPKG_ATTR_SENTINEL;
  181. int maintainer_script_new(struct pkginfo *pkg,
  182. const char *scriptname, const char *desc,
  183. const char *cidir, char *cidirrest, ...)
  184. DPKG_ATTR_SENTINEL;
  185. int maintainer_script_alternative(struct pkginfo *pkg,
  186. const char *scriptname, const char *desc,
  187. const char *cidir, char *cidirrest,
  188. const char *ifok, const char *iffallback);
  189. /* Callers wanting to run the postinst use these two as they want to postpone
  190. * trigger incorporation until after updating the package status. The effect
  191. * is that a package can trigger itself. */
  192. int maintainer_script_postinst(struct pkginfo *pkg, ...) DPKG_ATTR_SENTINEL;
  193. void post_postinst_tasks_core(struct pkginfo *pkg);
  194. void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
  195. void clear_istobes(void);
  196. bool dir_is_used_by_others(struct filenamenode *namenode, struct pkginfo *pkg);
  197. bool dir_is_used_by_pkg(struct filenamenode *namenode, struct pkginfo *pkg,
  198. struct fileinlist *list);
  199. bool dir_has_conffiles(struct filenamenode *namenode, struct pkginfo *pkg);
  200. void log_action(const char *action, struct pkginfo *pkg, struct pkgbin *pkgbin);
  201. /* from trigproc.c */
  202. void trigproc_install_hooks(void);
  203. void trigproc_run_deferred(void);
  204. void trigproc_reset_cycle(void);
  205. void trigproc(struct pkginfo *pkg);
  206. void trig_activate_packageprocessing(struct pkginfo *pkg);
  207. /* from depcon.c */
  208. enum which_pkgbin {
  209. wpb_installed,
  210. wpb_available,
  211. wpb_by_istobe,
  212. };
  213. struct deppossi_pkg_iterator;
  214. struct deppossi_pkg_iterator *
  215. deppossi_pkg_iter_new(struct deppossi *possi, enum which_pkgbin wpb);
  216. struct pkginfo *
  217. deppossi_pkg_iter_next(struct deppossi_pkg_iterator *iter);
  218. void
  219. deppossi_pkg_iter_free(struct deppossi_pkg_iterator *iter);
  220. bool depisok(struct dependency *dep, struct varbuf *whynot,
  221. struct pkginfo **fixbyrm, struct pkginfo **fixbytrigaw,
  222. bool allowunconfigd);
  223. struct cyclesofarlink;
  224. bool findbreakcycle(struct pkginfo *pkg);
  225. void describedepcon(struct varbuf *addto, struct dependency *dep);
  226. #endif /* MAIN_H */