main.h 9.3 KB

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