awful debugging hacking
[dpkg] / src / main.h
CommitLineData
1479465f
GJ
1/*
2 * dpkg - main program for package management
3 * main.h - external definitions for this program
4 *
5 * Copyright © 1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2006, 2008-2016 Guillem Jover <guillem@debian.org>
7 *
8 * This is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef MAIN_H
23#define MAIN_H
24
25#include <dpkg/debug.h>
26#include <dpkg/pkg-list.h>
27
28/* These two are defined in filesdb.h. */
29struct fileinlist;
30struct filenamenode;
31
32enum pkg_istobe {
33 /** Package is to be left in a normal state. */
34 PKG_ISTOBE_NORMAL,
35 /** Package is to be removed. */
36 PKG_ISTOBE_REMOVE,
37 /** Package is to be installed, configured or triggered. */
38 PKG_ISTOBE_INSTALLNEW,
39 /** Package is to be deconfigured. */
40 PKG_ISTOBE_DECONFIGURE,
41 /** Package is to be checked for Pre-Depends satisfiability. */
42 PKG_ISTOBE_PREINSTALL,
43};
44
45enum pkg_cycle_color {
46 PKG_CYCLE_WHITE,
47 PKG_CYCLE_GRAY,
48 PKG_CYCLE_BLACK,
49};
50
51struct perpackagestate {
52 enum pkg_istobe istobe;
53
54 /** Used during cycle detection. */
55 enum pkg_cycle_color color;
56
57 bool enqueued;
58
59 /**
60 * filelistvalid files Meaning
61 * ------------- ----- -------
62 * false NULL Not read yet, must do so if want them.
63 * false !NULL Read, but rewritten and now out of date. If want
64 * info must throw away old and reread file.
65 * true !NULL Read, all is OK.
66 * true NULL Read OK, but, there were no files.
67 */
68 bool fileslistvalid;
69 struct fileinlist *files;
70 int replacingfilesandsaid;
71 int cmdline_seen;
72
73 off_t listfile_phys_offs;
74
75 /** Non-NULL iff in trigproc.c:deferred. */
76 struct pkg_list *trigprocdeferred;
77};
78
79enum action {
80 act_unset,
81
82 act_unpack,
83 act_configure,
84 act_install,
85 act_triggers,
86 act_remove,
87 act_purge,
88 act_verify,
89 act_commandfd,
90
91 act_status,
92 act_listpackages,
93 act_listfiles,
94 act_searchfiles,
95 act_controlpath,
96 act_controllist,
97 act_controlshow,
98
99 act_cmpversions,
100
101 act_arch_add,
102 act_arch_remove,
103 act_printarch,
104 act_printforeignarches,
105
106 act_assertpredep,
107 act_assertepoch,
108 act_assertlongfilenames,
109 act_assertmulticonrep,
110 act_assertmultiarch,
111 act_assertverprovides,
112
113 act_validate_pkgname,
114 act_validate_trigname,
115 act_validate_archname,
116 act_validate_version,
117
118 act_audit,
119 act_unpackchk,
120 act_predeppackage,
121
122 act_getselections,
123 act_setselections,
124 act_clearselections,
125
126 act_avail,
127 act_printavail,
128 act_avclear,
129 act_avreplace,
130 act_avmerge,
131 act_forgetold,
132};
133
134extern const char *const statusstrings[];
135
136extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
137extern int f_autodeconf, f_nodebsig;
138extern int f_triggers;
139extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
140extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
141extern int fc_breaks, fc_badpath, fc_overwritediverted, fc_architecture;
142extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
143extern int fc_conff_old, fc_conff_def;
144extern int fc_conff_ask;
145extern int fc_badverify;
146extern int fc_badversion;
147extern int fc_unsafe_io;
148extern int fc_script_chrootless;
149
150extern bool abort_processing;
151extern int errabort;
152extern const char *instdir;
153extern struct pkg_list *ignoredependss;
154
155struct invoke_hook {
156 struct invoke_hook *next;
157 char *command;
158};
159
160struct invoke_list {
161 struct invoke_hook *head, **tail;
162};
163
164/* from archives.c */
165
166int archivefiles(const char *const *argv);
167void process_archive(const char *filename);
168bool wanttoinstall(struct pkginfo *pkg);
169
170/* from update.c */
171
172int forgetold(const char *const *argv);
173int updateavailable(const char *const *argv);
174
175/* from enquiry.c */
176
177int audit(const char *const *argv);
178int unpackchk(const char *const *argv);
179int assertepoch(const char *const *argv);
180int assertpredep(const char *const *argv);
181int assertlongfilenames(const char *const *argv);
182int assertmulticonrep(const char *const *argv);
183int assertmultiarch(const char *const *argv);
184int assertverprovides(const char *const *argv);
185int validate_pkgname(const char *const *argv);
186int validate_trigname(const char *const *argv);
187int validate_archname(const char *const *argv);
188int validate_version(const char *const *argv);
189int predeppackage(const char *const *argv);
190int printarch(const char *const *argv);
191int printinstarch(const char *const *argv);
192int print_foreign_arches(const char *const *argv);
193int cmpversions(const char *const *argv);
194
195/* from verify.c */
196
197bool verify_set_output(const char *name);
198int verify(const char *const *argv);
199
200/* from select.c */
201
202int getselections(const char *const *argv);
203int setselections(const char *const *argv);
204int clearselections(const char *const *argv);
205
206/* from packages.c, remove.c and configure.c */
207
208void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn);
209void enqueue_package(struct pkginfo *pkg);
210void enqueue_package_mark_seen(struct pkginfo *pkg);
211void process_queue(void);
212int packages(const char *const *argv);
213void removal_bulk(struct pkginfo *pkg);
214int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in);
215
216enum dep_check {
217 DEP_CHECK_HALT = 0,
218 DEP_CHECK_DEFER = 1,
219 DEP_CHECK_OK = 2,
220};
221
222enum dep_check dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
223 struct varbuf *aemsgs);
224enum dep_check breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
225
226void deferred_remove(struct pkginfo *pkg);
227void deferred_configure(struct pkginfo *pkg);
228
229extern int sincenothing, dependtry;
230
231/* from cleanup.c (most of these are declared in archives.h) */
232
233void cu_prermremove(int argc, void **argv);
234
235/* from errors.c */
236
237void print_error_perpackage(const char *emsg, const void *data);
238void print_error_perarchive(const char *emsg, const void *data);
239void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2);
240int reportbroken_retexitstatus(int ret);
241bool skip_due_to_hold(struct pkginfo *pkg);
242
243/* from help.c */
244
245struct stat;
246
247bool ignore_depends(struct pkginfo *pkg);
248bool force_breaks(struct deppossi *possi);
249bool force_depends(struct deppossi *possi);
250bool force_conflicts(struct deppossi *possi);
251void conffile_mark_obsolete(struct pkginfo *pkg, struct filenamenode *namenode);
252void pkg_conffiles_mark_old(struct pkginfo *pkg);
253bool find_command(const char *prog);
254void checkpath(void);
255
256struct filenamenode *namenodetouse(struct filenamenode *namenode,
257 struct pkginfo *pkg, struct pkgbin *pkgbin);
258
259int maintscript_installed(struct pkginfo *pkg, const char *scriptname,
260 const char *desc, ...) DPKG_ATTR_SENTINEL;
261int maintscript_new(struct pkginfo *pkg,
262 const char *scriptname, const char *desc,
263 const char *cidir, char *cidirrest, ...)
264 DPKG_ATTR_SENTINEL;
265int maintscript_fallback(struct pkginfo *pkg,
266 const char *scriptname, const char *desc,
267 const char *cidir, char *cidirrest,
268 const char *ifok, const char *iffallback);
269
270/* Callers wanting to run the postinst use these two as they want to postpone
271 * trigger incorporation until after updating the package status. The effect
272 * is that a package can trigger itself. */
273int maintscript_postinst(struct pkginfo *pkg, ...) DPKG_ATTR_SENTINEL;
274void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
275
276void clear_istobes(void);
277bool dir_is_used_by_others(struct filenamenode *namenode, struct pkginfo *pkg);
278bool dir_is_used_by_pkg(struct filenamenode *namenode, struct pkginfo *pkg,
279 struct fileinlist *list);
280bool dir_has_conffiles(struct filenamenode *namenode, struct pkginfo *pkg);
281
282void log_action(const char *action, struct pkginfo *pkg, struct pkgbin *pkgbin);
283
284/* From selinux.c */
285
286void dpkg_selabel_load(void);
287void dpkg_selabel_set_context(const char *matchpath, const char *path, mode_t mode);
288void dpkg_selabel_close(void);
289
290/* from trigproc.c */
291
292enum trigproc_type {
293 /** Opportunistic trigger processing. */
294 TRIGPROC_TRY,
295 /** Required trigger processing. */
296 TRIGPROC_REQUIRED,
297};
298
299void trigproc_install_hooks(void);
300void trigproc_populate_deferred(void);
301void trigproc_run_deferred(void);
302void trigproc_reset_cycle(void);
303
304void trigproc(struct pkginfo *pkg, enum trigproc_type type);
305
306void trig_activate_packageprocessing(struct pkginfo *pkg);
307
308/* from depcon.c */
309
310enum which_pkgbin {
311 wpb_installed,
312 wpb_available,
313 wpb_by_istobe,
314};
315
316struct deppossi_pkg_iterator;
317
318struct deppossi_pkg_iterator *
319deppossi_pkg_iter_new(struct deppossi *possi, enum which_pkgbin wpb);
320struct pkginfo *
321deppossi_pkg_iter_next(struct deppossi_pkg_iterator *iter);
322void
323deppossi_pkg_iter_free(struct deppossi_pkg_iterator *iter);
324
325bool depisok(struct dependency *dep, struct varbuf *whynot,
326 struct pkginfo **fixbyrm, struct pkginfo **fixbytrigaw,
327 bool allowunconfigd);
328struct cyclesofarlink;
329bool findbreakcycle(struct pkginfo *pkg);
330void describedepcon(struct varbuf *addto, struct dependency *dep);
331
332#endif /* MAIN_H */