2 * dpkg - main program for package management
3 * main.h - external definitions for this program
5 * Copyright © 1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2006, 2008-2016 Guillem Jover <guillem@debian.org>
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.
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.
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/>.
25 #include <dpkg/debug.h>
26 #include <dpkg/pkg-list.h>
28 /* These two are defined in filesdb.h. */
33 /** Package is to be left in a normal state. */
35 /** Package is to be removed. */
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
,
45 enum pkg_cycle_color
{
51 struct perpackagestate
{
52 enum pkg_istobe istobe
;
54 /** Used during cycle detection. */
55 enum pkg_cycle_color color
;
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.
69 struct fileinlist
*files
;
70 int replacingfilesandsaid
;
73 off_t listfile_phys_offs
;
75 /** Non-NULL iff in trigproc.c:deferred. */
76 struct pkg_list
*trigprocdeferred
;
104 act_printforeignarches
,
108 act_assertlongfilenames
,
109 act_assertmulticonrep
,
111 act_assertverprovides
,
113 act_validate_pkgname
,
114 act_validate_trigname
,
115 act_validate_archname
,
116 act_validate_version
,
134 extern const char *const statusstrings
[];
136 extern int f_pending
, f_recursive
, f_alsoselect
, f_skipsame
, f_noact
;
137 extern int f_autodeconf
, f_nodebsig
;
138 extern int f_triggers
;
139 extern int fc_downgrade
, fc_configureany
, fc_hold
, fc_removereinstreq
, fc_overwrite
;
140 extern int fc_removeessential
, fc_conflicts
, fc_depends
, fc_dependsversion
;
141 extern int fc_breaks
, fc_badpath
, fc_overwritediverted
, fc_architecture
;
142 extern int fc_nonroot
, fc_overwritedir
, fc_conff_new
, fc_conff_miss
;
143 extern int fc_conff_old
, fc_conff_def
;
144 extern int fc_conff_ask
;
145 extern int fc_badverify
;
146 extern int fc_badversion
;
147 extern int fc_unsafe_io
;
148 extern int fc_script_chrootless
;
150 extern bool abort_processing
;
152 extern const char *instdir
;
153 extern struct pkg_list
*ignoredependss
;
156 struct invoke_hook
*next
;
161 struct invoke_hook
*head
, **tail
;
164 /* from archives.c */
166 int archivefiles(const char *const *argv
);
167 void process_archive(const char *filename
);
168 bool wanttoinstall(struct pkginfo
*pkg
);
172 int forgetold(const char *const *argv
);
173 int updateavailable(const char *const *argv
);
177 int audit(const char *const *argv
);
178 int unpackchk(const char *const *argv
);
179 int assertepoch(const char *const *argv
);
180 int assertpredep(const char *const *argv
);
181 int assertlongfilenames(const char *const *argv
);
182 int assertmulticonrep(const char *const *argv
);
183 int assertmultiarch(const char *const *argv
);
184 int assertverprovides(const char *const *argv
);
185 int validate_pkgname(const char *const *argv
);
186 int validate_trigname(const char *const *argv
);
187 int validate_archname(const char *const *argv
);
188 int validate_version(const char *const *argv
);
189 int predeppackage(const char *const *argv
);
190 int printarch(const char *const *argv
);
191 int printinstarch(const char *const *argv
);
192 int print_foreign_arches(const char *const *argv
);
193 int cmpversions(const char *const *argv
);
197 bool verify_set_output(const char *name
);
198 int verify(const char *const *argv
);
202 int getselections(const char *const *argv
);
203 int setselections(const char *const *argv
);
204 int clearselections(const char *const *argv
);
206 /* from packages.c, remove.c and configure.c */
208 void md5hash(struct pkginfo
*pkg
, char *hashbuf
, const char *fn
);
209 void enqueue_package(struct pkginfo
*pkg
);
210 void enqueue_package_mark_seen(struct pkginfo
*pkg
);
211 void process_queue(void);
212 int packages(const char *const *argv
);
213 void removal_bulk(struct pkginfo
*pkg
);
214 int conffderef(struct pkginfo
*pkg
, struct varbuf
*result
, const char *in
);
222 enum dep_check
dependencies_ok(struct pkginfo
*pkg
, struct pkginfo
*removing
,
223 struct varbuf
*aemsgs
);
224 enum dep_check
breakses_ok(struct pkginfo
*pkg
, struct varbuf
*aemsgs
);
226 void deferred_remove(struct pkginfo
*pkg
);
227 void deferred_configure(struct pkginfo
*pkg
);
229 extern int sincenothing
, dependtry
;
231 /* from cleanup.c (most of these are declared in archives.h) */
233 void cu_prermremove(int argc
, void **argv
);
237 void print_error_perpackage(const char *emsg
, const void *data
);
238 void print_error_perarchive(const char *emsg
, const void *data
);
239 void forcibleerr(int forceflag
, const char *format
, ...) DPKG_ATTR_PRINTF(2);
240 int reportbroken_retexitstatus(int ret
);
241 bool skip_due_to_hold(struct pkginfo
*pkg
);
247 bool ignore_depends(struct pkginfo
*pkg
);
248 bool force_breaks(struct deppossi
*possi
);
249 bool force_depends(struct deppossi
*possi
);
250 bool force_conflicts(struct deppossi
*possi
);
251 void conffile_mark_obsolete(struct pkginfo
*pkg
, struct filenamenode
*namenode
);
252 void pkg_conffiles_mark_old(struct pkginfo
*pkg
);
253 bool find_command(const char *prog
);
254 void checkpath(void);
256 struct filenamenode
*namenodetouse(struct filenamenode
*namenode
,
257 struct pkginfo
*pkg
, struct pkgbin
*pkgbin
);
259 int maintscript_installed(struct pkginfo
*pkg
, const char *scriptname
,
260 const char *desc
, ...) DPKG_ATTR_SENTINEL
;
261 int maintscript_new(struct pkginfo
*pkg
,
262 const char *scriptname
, const char *desc
,
263 const char *cidir
, char *cidirrest
, ...)
265 int 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
);
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. */
273 int maintscript_postinst(struct pkginfo
*pkg
, ...) DPKG_ATTR_SENTINEL
;
274 void post_postinst_tasks(struct pkginfo
*pkg
, enum pkgstatus new_status
);
276 void clear_istobes(void);
277 bool dir_is_used_by_others(struct filenamenode
*namenode
, struct pkginfo
*pkg
);
278 bool dir_is_used_by_pkg(struct filenamenode
*namenode
, struct pkginfo
*pkg
,
279 struct fileinlist
*list
);
280 bool dir_has_conffiles(struct filenamenode
*namenode
, struct pkginfo
*pkg
);
282 void log_action(const char *action
, struct pkginfo
*pkg
, struct pkgbin
*pkgbin
);
286 void dpkg_selabel_load(void);
287 void dpkg_selabel_set_context(const char *matchpath
, const char *path
, mode_t mode
);
288 void dpkg_selabel_close(void);
290 /* from trigproc.c */
293 /** Opportunistic trigger processing. */
295 /** Required trigger processing. */
299 void trigproc_install_hooks(void);
300 void trigproc_populate_deferred(void);
301 void trigproc_run_deferred(void);
302 void trigproc_reset_cycle(void);
304 void trigproc(struct pkginfo
*pkg
, enum trigproc_type type
);
306 void trig_activate_packageprocessing(struct pkginfo
*pkg
);
316 struct deppossi_pkg_iterator
;
318 struct deppossi_pkg_iterator
*
319 deppossi_pkg_iter_new(struct deppossi
*possi
, enum which_pkgbin wpb
);
321 deppossi_pkg_iter_next(struct deppossi_pkg_iterator
*iter
);
323 deppossi_pkg_iter_free(struct deppossi_pkg_iterator
*iter
);
325 bool depisok(struct dependency
*dep
, struct varbuf
*whynot
,
326 struct pkginfo
**fixbyrm
, struct pkginfo
**fixbytrigaw
,
327 bool allowunconfigd
);
328 struct cyclesofarlink
;
329 bool findbreakcycle(struct pkginfo
*pkg
);
330 void describedepcon(struct varbuf
*addto
, struct dependency
*dep
);