main.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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_cmpversions,
  68. act_arch_add,
  69. act_arch_remove,
  70. act_printarch,
  71. act_printinstarch,
  72. act_printforeignarches,
  73. act_assertpredep,
  74. act_assertepoch,
  75. act_assertlongfilenames,
  76. act_assertmulticonrep,
  77. act_assertmultiarch,
  78. act_audit,
  79. act_unpackchk,
  80. act_predeppackage,
  81. act_getselections,
  82. act_setselections,
  83. act_clearselections,
  84. act_avail,
  85. act_printavail,
  86. act_avclear,
  87. act_avreplace,
  88. act_avmerge,
  89. act_forgetold,
  90. };
  91. enum conffopt {
  92. cfof_prompt = 001,
  93. cfof_keep = 002,
  94. cfof_install = 004,
  95. cfof_backup = 00100,
  96. cfof_newconff = 00200,
  97. cfof_isnew = 00400,
  98. cfof_isold = 01000,
  99. cfof_userrmd = 02000,
  100. cfo_keep = cfof_keep,
  101. cfo_prompt_keep = cfof_keep | cfof_prompt,
  102. cfo_prompt = cfof_prompt,
  103. cfo_prompt_install = cfof_prompt | cfof_install,
  104. cfo_install = cfof_install,
  105. cfo_newconff = cfof_install | cfof_newconff,
  106. cfo_identical = cfof_keep
  107. };
  108. extern const char *const statusstrings[];
  109. extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
  110. extern int f_autodeconf, f_nodebsig;
  111. extern int f_triggers;
  112. extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
  113. extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
  114. extern int fc_breaks, fc_badpath, fc_overwritediverted, fc_architecture;
  115. extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
  116. extern int fc_conff_old, fc_conff_def;
  117. extern int fc_conff_ask;
  118. extern int fc_badverify;
  119. extern int fc_badversion;
  120. extern int fc_unsafe_io;
  121. extern bool abort_processing;
  122. extern int errabort;
  123. extern const char *instdir;
  124. extern struct pkg_list *ignoredependss;
  125. struct invoke_hook {
  126. struct invoke_hook *next;
  127. const char *command;
  128. };
  129. /* from archives.c */
  130. int archivefiles(const char *const *argv);
  131. void process_archive(const char *filename);
  132. bool wanttoinstall(struct pkginfo *pkg);
  133. struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
  134. struct filenamenode *namenode);
  135. /* from update.c */
  136. int forgetold(const char *const *argv);
  137. int updateavailable(const char *const *argv);
  138. /* from enquiry.c */
  139. int audit(const char *const *argv);
  140. int unpackchk(const char *const *argv);
  141. int assertepoch(const char *const *argv);
  142. int assertpredep(const char *const *argv);
  143. int assertlongfilenames(const char *const *argv);
  144. int assertmulticonrep(const char *const *argv);
  145. int assertmultiarch(const char *const *argv);
  146. int predeppackage(const char *const *argv);
  147. int printarch(const char *const *argv);
  148. int printinstarch(const char *const *argv);
  149. int print_foreign_arches(const char *const *argv);
  150. int cmpversions(const char *const *argv);
  151. /* from select.c */
  152. int getselections(const char *const *argv);
  153. int setselections(const char *const *argv);
  154. int clearselections(const char *const *argv);
  155. /* from packages.c, remove.c and configure.c */
  156. void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn);
  157. void add_to_queue(struct pkginfo *pkg);
  158. void process_queue(void);
  159. int packages(const char *const *argv);
  160. void removal_bulk(struct pkginfo *pkg);
  161. int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in);
  162. enum dep_check {
  163. dep_check_halt = 0,
  164. dep_check_defer = 1,
  165. dep_check_ok = 2,
  166. };
  167. enum dep_check dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
  168. struct varbuf *aemsgs);
  169. enum dep_check breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
  170. void deferred_remove(struct pkginfo *pkg);
  171. void deferred_configure(struct pkginfo *pkg);
  172. extern int sincenothing, dependtry;
  173. /* from cleanup.c (most of these are declared in archives.h) */
  174. void cu_prermremove(int argc, void **argv);
  175. /* from errors.c */
  176. void print_error_perpackage(const char *emsg, const char *arg);
  177. void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2);
  178. int reportbroken_retexitstatus(int ret);
  179. bool skip_due_to_hold(struct pkginfo *pkg);
  180. /* from help.c */
  181. struct stat;
  182. bool ignore_depends(struct pkginfo *pkg);
  183. bool force_breaks(struct deppossi *possi);
  184. bool force_depends(struct deppossi *possi);
  185. bool force_conflicts(struct deppossi *possi);
  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 maintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
  194. const char *desc, ...) DPKG_ATTR_SENTINEL;
  195. int maintainer_script_new(struct pkginfo *pkg,
  196. const char *scriptname, const char *desc,
  197. const char *cidir, char *cidirrest, ...)
  198. DPKG_ATTR_SENTINEL;
  199. int maintainer_script_alternative(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 maintainer_script_postinst(struct pkginfo *pkg, ...) DPKG_ATTR_SENTINEL;
  207. void post_postinst_tasks_core(struct pkginfo *pkg);
  208. void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
  209. void clear_istobes(void);
  210. bool dir_is_used_by_others(struct filenamenode *namenode, struct pkginfo *pkg);
  211. bool dir_is_used_by_pkg(struct filenamenode *namenode, struct pkginfo *pkg,
  212. struct fileinlist *list);
  213. bool dir_has_conffiles(struct filenamenode *namenode, struct pkginfo *pkg);
  214. void log_action(const char *action, struct pkginfo *pkg, struct pkgbin *pkgbin);
  215. /* from trigproc.c */
  216. void trigproc_install_hooks(void);
  217. void trigproc_run_deferred(void);
  218. void trigproc_reset_cycle(void);
  219. void trigproc(struct pkginfo *pkg);
  220. void trig_activate_packageprocessing(struct pkginfo *pkg);
  221. /* from depcon.c */
  222. enum which_pkgbin {
  223. wpb_installed,
  224. wpb_available,
  225. wpb_by_istobe,
  226. };
  227. struct deppossi_pkg_iterator;
  228. struct deppossi_pkg_iterator *
  229. deppossi_pkg_iter_new(struct deppossi *possi, enum which_pkgbin wpb);
  230. struct pkginfo *
  231. deppossi_pkg_iter_next(struct deppossi_pkg_iterator *iter);
  232. void
  233. deppossi_pkg_iter_free(struct deppossi_pkg_iterator *iter);
  234. bool depisok(struct dependency *dep, struct varbuf *whynot,
  235. struct pkginfo **fixbyrm, struct pkginfo **fixbytrigaw,
  236. bool allowunconfigd);
  237. struct cyclesofarlink;
  238. bool findbreakcycle(struct pkginfo *pkg);
  239. void describedepcon(struct varbuf *addto, struct dependency *dep);
  240. #endif /* MAIN_H */