main.h 9.8 KB

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