main.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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/pkg-list.h>
  23. /* These two are defined in filesdb.h. */
  24. struct fileinlist;
  25. struct filenamenode;
  26. struct perpackagestate {
  27. enum istobes {
  28. itb_normal, itb_remove, itb_installnew, itb_deconfigure, itb_preinstall
  29. } istobe;
  30. /* Used during cycle detection. */
  31. enum {
  32. white,
  33. gray,
  34. black,
  35. } color;
  36. /*
  37. * filelistvalid files Meaning
  38. * ------------- ----- -------
  39. * false NULL Not read yet, must do so if want them.
  40. * false !NULL Read, but rewritten and now out of date. If want
  41. * info must throw away old and reread file.
  42. * true !NULL Read, all is OK.
  43. * true NULL Read OK, but, there were no files.
  44. */
  45. bool fileslistvalid;
  46. struct fileinlist *files;
  47. int replacingfilesandsaid;
  48. off_t listfile_phys_offs;
  49. /* Non-NULL iff in trigproc.c:deferred. */
  50. struct pkg_list *trigprocdeferred;
  51. };
  52. enum action {
  53. act_unset,
  54. act_unpack,
  55. act_configure,
  56. act_install,
  57. act_triggers,
  58. act_remove,
  59. act_purge,
  60. act_commandfd,
  61. act_status,
  62. act_listpackages,
  63. act_listfiles,
  64. act_searchfiles,
  65. act_controlpath,
  66. act_cmpversions,
  67. act_printarch,
  68. act_printinstarch,
  69. act_assertpredep,
  70. act_assertepoch,
  71. act_assertlongfilenames,
  72. act_assertmulticonrep,
  73. act_audit,
  74. act_unpackchk,
  75. act_predeppackage,
  76. act_getselections,
  77. act_setselections,
  78. act_clearselections,
  79. act_avail,
  80. act_printavail,
  81. act_avclear,
  82. act_avreplace,
  83. act_avmerge,
  84. act_forgetold,
  85. };
  86. enum conffopt {
  87. cfof_prompt = 001,
  88. cfof_keep = 002,
  89. cfof_install = 004,
  90. cfof_backup = 00100,
  91. cfof_newconff = 00200,
  92. cfof_isnew = 00400,
  93. cfof_isold = 01000,
  94. cfof_userrmd = 02000,
  95. cfo_keep = cfof_keep,
  96. cfo_prompt_keep = cfof_keep | cfof_prompt,
  97. cfo_prompt = cfof_prompt,
  98. cfo_prompt_install = cfof_prompt | cfof_install,
  99. cfo_install = cfof_install,
  100. cfo_newconff = cfof_install | cfof_newconff,
  101. cfo_identical = cfof_keep
  102. };
  103. extern const char *const statusstrings[];
  104. extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
  105. extern int f_autodeconf, f_nodebsig;
  106. extern int f_triggers;
  107. extern unsigned long f_debug;
  108. extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
  109. extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
  110. extern int fc_breaks, fc_badpath, fc_overwritediverted, fc_architecture;
  111. extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
  112. extern int fc_conff_old, fc_conff_def;
  113. extern int fc_conff_ask;
  114. extern int fc_badverify;
  115. extern bool abort_processing;
  116. extern int errabort;
  117. extern const char *admindir;
  118. extern const char *instdir;
  119. extern struct pkg_list *ignoredependss;
  120. extern const char architecture[];
  121. struct invoke_hook {
  122. struct invoke_hook *next;
  123. const char *command;
  124. };
  125. /* from archives.c */
  126. void archivefiles(const char *const *argv);
  127. void process_archive(const char *filename);
  128. int wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver,
  129. bool saywhy);
  130. struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
  131. struct filenamenode *namenode);
  132. /* from update.c */
  133. void forgetold(const char *const *argv);
  134. void updateavailable(const char *const *argv);
  135. /* from enquiry.c */
  136. void audit(const char *const *argv);
  137. void unpackchk(const char *const *argv);
  138. void assertepoch(const char *const *argv);
  139. void assertpredep(const char *const *argv);
  140. void assertlongfilenames(const char *const *argv);
  141. void assertmulticonrep(const char *const *argv);
  142. void predeppackage(const char *const *argv);
  143. void printarch(const char *const *argv);
  144. void printinstarch(const char *const *argv);
  145. void cmpversions(const char *const *argv) DPKG_ATTR_NORET;
  146. /* from select.c */
  147. void getselections(const char *const *argv);
  148. void setselections(const char *const *argv);
  149. void clearselections(const char *const *argv);
  150. /* from packages.c, remove.c and configure.c */
  151. void add_to_queue(struct pkginfo *pkg);
  152. void process_queue(void);
  153. void packages(const char *const *argv);
  154. void removal_bulk(struct pkginfo *pkg);
  155. int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in);
  156. enum dep_check {
  157. dep_check_halt = 0,
  158. dep_check_defer = 1,
  159. dep_check_ok = 2,
  160. };
  161. enum dep_check dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
  162. struct varbuf *aemsgs);
  163. enum dep_check breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
  164. void deferred_remove(struct pkginfo *pkg);
  165. void deferred_configure(struct pkginfo *pkg);
  166. extern int sincenothing, dependtry;
  167. /* from cleanup.c (most of these are declared in archives.h) */
  168. void cu_prermremove(int argc, void **argv);
  169. /* from errors.c */
  170. void print_error_perpackage(const char *emsg, const char *arg);
  171. void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2);
  172. int reportbroken_retexitstatus(void);
  173. bool skip_due_to_hold(struct pkginfo *pkg);
  174. /* from help.c */
  175. struct stat;
  176. bool ignore_depends(struct pkginfo *pkg);
  177. bool force_breaks(struct deppossi *possi);
  178. bool force_depends(struct deppossi *possi);
  179. bool force_conff_new(struct deppossi *possi);
  180. bool force_conff_miss(struct deppossi *possi);
  181. bool force_conflicts(struct deppossi *possi);
  182. void oldconffsetflags(const struct conffile *searchconff);
  183. void ensure_pathname_nonexisting(const char *pathname);
  184. int secure_unlink(const char *pathname);
  185. int secure_unlink_statted(const char *pathname, const struct stat *stab);
  186. void checkpath(void);
  187. struct filenamenode *namenodetouse(struct filenamenode*, struct pkginfo*);
  188. int maintainer_script_installed(struct pkginfo *pkg, const char *scriptname,
  189. const char *desc, ...) DPKG_ATTR_SENTINEL;
  190. int maintainer_script_new(struct pkginfo *pkg,
  191. const char *scriptname, const char *desc,
  192. const char *cidir, char *cidirrest, ...)
  193. DPKG_ATTR_SENTINEL;
  194. int maintainer_script_alternative(struct pkginfo *pkg,
  195. const char *scriptname, const char *desc,
  196. const char *cidir, char *cidirrest,
  197. const char *ifok, const char *iffallback);
  198. /* Callers wanting to run the postinst use these two as they want to postpone
  199. * trigger incorporation until after updating the package status. The effect
  200. * is that a package can trigger itself. */
  201. int maintainer_script_postinst(struct pkginfo *pkg, ...) DPKG_ATTR_SENTINEL;
  202. void post_postinst_tasks_core(struct pkginfo *pkg);
  203. void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
  204. void clear_istobes(void);
  205. bool isdirectoryinuse(struct filenamenode *namenode, struct pkginfo *pkg);
  206. bool hasdirectoryconffiles(struct filenamenode *namenode, struct pkginfo *pkg);
  207. enum debugflags {
  208. dbg_general= 00001,
  209. dbg_scripts= 00002,
  210. dbg_eachfile= 00010,
  211. dbg_eachfiledetail= 00100,
  212. dbg_conff= 00020,
  213. dbg_conffdetail= 00200,
  214. dbg_depcon= 00040,
  215. dbg_depcondetail= 00400,
  216. dbg_veryverbose= 01000,
  217. dbg_stupidlyverbose= 02000,
  218. dbg_triggers = 010000,
  219. dbg_triggersdetail = 020000,
  220. dbg_triggersstupid = 040000,
  221. };
  222. void debug(int which, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
  223. void log_action(const char *action, struct pkginfo *pkg);
  224. /* from trigproc.c */
  225. void trigproc_install_hooks(void);
  226. void trigproc_run_deferred(void);
  227. void trigproc_reset_cycle(void);
  228. void trigproc(struct pkginfo *pkg);
  229. void trig_activate_packageprocessing(struct pkginfo *pkg);
  230. /* from depcon.c */
  231. bool depisok(struct dependency *dep, struct varbuf *whynot,
  232. struct pkginfo **fixbyrm, bool allowunconfigd);
  233. struct cyclesofarlink;
  234. bool findbreakcycle(struct pkginfo *pkg);
  235. void describedepcon(struct varbuf *addto, struct dependency *dep);
  236. #endif /* MAIN_H */