2 * dselect - Debian package maintenance user interface
3 * pkglist.h - external definitions for package list handling
5 * Copyright © 1994,1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 * Copyright © 2001 Wichert Akkerman <wakkerma@debian.org>
7 * Copyright © 2007-2014 Guillem Jover <guillem@debian.org>
9 * This is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 dp_none
, // has not been involved in any unsatisfied things
30 dp_may
, // has been involved in an unsatisfied Suggests
31 dp_should
, // has been involved in an unsatisfied Recommends
32 dp_must
, // has been involved in an unsatisfied Depends/Conflicts
36 // where did the currently suggested value come from, and how important
37 // is it to display this package ?
39 sp_inherit
, // inherited from our parent list
40 sp_selecting
, // propagating a selection
41 sp_deselecting
, // propagating a deselection
42 sp_fixed
, // it came from the ‘status’ file and we're not a recursive list
46 enum ssavailval
{ // Availability sorting order, first to last:
47 ssa_broken
, // Brokenly-installed and nothing available
48 ssa_notinst_unseen
, // Entirely new packages (available but not deselected yet)
49 ssa_installed_newer
, // Installed, newer version available
50 ssa_installed_gone
, // Installed but no longer available
51 ssa_installed_sameold
, // Same or older version available as installed
52 ssa_notinst_seen
, // Available but not installed
53 ssa_notinst_gone
, // Not available, and only config files left
57 enum ssstateval
{ // State sorting order, first to last:
58 sss_broken
, // In some way brokenly installed
59 sss_installed
, // Installed
60 sss_configfiles
, // Config files only
61 sss_notinstalled
, // Not installed
65 struct perpackagestate
{
67 /* The ‘heading’ entries in the list, for “all packages of type foo”,
68 * point to a made-up pkginfo, which has pkg->name==0.
69 * pkg->priority and pkg->section are set to the values if appropriate, or to
70 * PKG_PRIO_UNSET resp. null if the heading refers to all priorities resp.
72 * uprec is used when constructing the list initially and when tearing it
73 * down and should not otherwise be used; other fields are undefined.
75 pkgwant original
; // set by caller
76 pkgwant direct
; // set by caller
77 pkgwant suggested
; // set by caller, modified by resolvesuggest
78 pkgwant selected
; // not set by caller, will be set by packagelist
79 selpriority spriority
; // monotonically increases (used by sublists)
80 showpriority dpriority
; // monotonically increases (used by sublists)
81 struct perpackagestate
*uprec
; // 0 if this is not part of a recursive list
86 void free(bool recursive
);
89 class packagelist
: public baselist
{
95 column col_archinstalled
;
96 column col_archavailable
;
97 column col_versioninstalled
;
98 column col_versionavailable
;
99 column col_description
;
101 // Only used when ‘verbose’ is set
102 column col_status_hold
;
103 column col_status_status
;
104 column col_status_old_want
;
105 column col_status_new_want
;
108 struct perpackagestate
*datatable
;
109 struct perpackagestate
**table
;
113 bool recursive
, verbose
;
135 bool calcssadone
, calcsssdone
;
136 struct perpackagestate
*headings
;
138 // Package searching flags
142 // Information displays
144 bool (packagelist::*relevant
)(); // null means always relevant
145 void (packagelist::*display
)(); // null means end of table
147 const infotype
*currentinfo
;
148 static const infotype infoinfos
[];
149 static const infotype
*const baseinfo
;
150 bool itr_recursive();
151 bool itr_nonrecursive();
152 void severalinfoblurb();
153 void itd_mainwelcome();
154 void itd_explaindisplay();
155 void itd_recurwelcome();
156 void itd_relations();
157 void itd_description();
158 void itd_statuscontrol();
159 void itd_availablecontrol();
161 // Dependency and sublist processing
162 struct doneent
{ doneent
*next
; void *dep
; } *depsdone
, *unavdone
;
163 bool alreadydone(doneent
**, void *);
164 int resolvedepcon(dependency
*);
165 int checkdependers(pkginfo
*, int changemade
); // returns new changemade
166 int deselect_one_of(pkginfo
*er
, pkginfo
*ed
, dependency
*dep
);
168 // Define these virtuals
169 bool checksearch(char *str
) override
;
170 bool matchsearch(int index
) override
;
171 void redraw1itemsel(int index
, int selected
) override
;
172 void redrawcolheads() override
;
173 void redrawthisstate() override
;
174 void redrawinfo() override
;
175 void redrawtitle() override
;
176 void setwidths() override
;
177 const char *itemname(int index
) override
;
178 const struct helpmenuentry
*helpmenulist() override
;
180 // Miscellaneous internal routines
182 void redraw1package(int index
, int selected
);
183 int compareentries(const struct perpackagestate
*a
, const struct perpackagestate
*b
);
184 friend int qsort_compareentries(const void *a
, const void *b
);
185 pkgwant
reallywant(pkgwant
, struct perpackagestate
*);
186 int describemany(char buf
[], const char *prioritystring
, const char *section
,
187 const struct perpackagestate
*pps
);
188 bool deppossatisfied(deppossi
*possi
, perpackagestate
**fixbyupgrade
);
190 void sortmakeheads();
191 void resortredisplay();
192 void movecursorafter(int ncursor
);
195 void ensurestatsortinfo();
197 // To do with building the list, with heading lines in it
198 void discardheadings();
199 void addheading(enum ssavailval
, enum ssstateval
,
200 pkgpriority
, const char *, const char *section
);
202 bool affectedmatches(struct pkginfo
*pkg
, struct pkginfo
*comparewith
);
203 void affectedrange(int *startp
, int *endp
);
204 void setwant(pkgwant nw
);
205 void sethold(int hold
);
209 // Keybinding functions */
211 void kd_revert_abort();
212 void kd_revertsuggest();
213 void kd_revertdirect();
214 void kd_revertinstalled();
215 void kd_morespecific();
216 void kd_lessspecific();
218 void kd_swapstatorder();
225 void kd_toggleinfo();
227 void kd_archdisplay();
228 void kd_versiondisplay();
230 explicit packagelist(keybindings
*kb
); // nonrecursive
231 packagelist(keybindings
*kb
, pkginfo
**pkgltab
); // recursive
232 void add(pkginfo
**array
) { while (*array
) add(*array
++); }
234 void add(pkginfo
*, pkgwant
);
235 void add(pkginfo
*, const char *extrainfo
, showpriority displayimportance
);
236 bool add(dependency
*, showpriority displayimportance
);
237 void addunavailable(deppossi
*);
238 bool useavailable(pkginfo
*);
239 pkgbin
*find_pkgbin(pkginfo
*);
241 int resolvesuggest();
242 int deletelessimp_anyleft(showpriority than
);
247 void repeatedlydisplay(packagelist
*sub
, showpriority
,
248 packagelist
*unredisplay
= nullptr);
249 int would_like_to_install(pkgwant
, pkginfo
*pkg
);
251 extern const char *const wantstrings
[];
252 extern const char *const eflagstrings
[];
253 extern const char *const statusstrings
[];
254 extern const char *const prioritystrings
[];
255 extern const char *const priorityabbrevs
[];
256 extern const char *const relatestrings
[];
257 extern const char *const ssastrings
[], *const ssaabbrevs
[];
258 extern const char *const sssstrings
[], *const sssabbrevs
[];
259 extern const char statuschars
[];
260 extern const char eflagchars
[];
261 extern const char wantchars
[];
263 #endif /* PKGLIST_H */