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
;
114 enum { so_unsorted
, so_section
, so_priority
, so_alpha
} sortorder
;
115 enum { sso_unsorted
, sso_avail
, sso_state
} statsortorder
;
116 enum { ado_none
, ado_available
, ado_both
} archdisplayopt
;
117 enum { vdo_none
, vdo_available
, vdo_both
} versiondisplayopt
;
118 bool calcssadone
, calcsssdone
;
119 struct perpackagestate
*headings
;
121 // Package searching flags
125 // Information displays
127 bool (packagelist
::*relevant
)(); // null means always relevant
128 void (packagelist
::*display
)(); // null means end of table
130 const infotype
*currentinfo
;
131 static const infotype infoinfos
[];
132 static const infotype
*const baseinfo
;
133 bool itr_recursive();
134 bool itr_nonrecursive();
135 void severalinfoblurb();
136 void itd_mainwelcome();
137 void itd_explaindisplay();
138 void itd_recurwelcome();
139 void itd_relations();
140 void itd_description();
141 void itd_statuscontrol();
142 void itd_availablecontrol();
144 // Dependency and sublist processing
145 struct doneent
{ doneent
*next
; void *dep
; } *depsdone
, *unavdone
;
146 bool alreadydone(doneent
**, void *);
147 int resolvedepcon(dependency
*);
148 int checkdependers(pkginfo
*, int changemade
); // returns new changemade
149 int deselect_one_of(pkginfo
*er
, pkginfo
*ed
, dependency
*dep
);
151 // Define these virtuals
152 bool checksearch(char *str
);
153 bool matchsearch(int index
);
154 void redraw1itemsel(int index
, int selected
);
155 void redrawcolheads();
156 void redrawthisstate();
160 const char *itemname(int index
);
161 const struct helpmenuentry
*helpmenulist();
163 // Miscellaneous internal routines
165 void redraw1package(int index
, int selected
);
166 int compareentries(const struct perpackagestate
*a
, const struct perpackagestate
*b
);
167 friend int qsort_compareentries(const void *a
, const void *b
);
168 pkgwant
reallywant(pkgwant
, struct perpackagestate
*);
169 int describemany(char buf
[], const char *prioritystring
, const char *section
,
170 const struct perpackagestate
*pps
);
171 bool deppossatisfied(deppossi
*possi
, perpackagestate
**fixbyupgrade
);
173 void sortmakeheads();
174 void resortredisplay();
175 void movecursorafter(int ncursor
);
178 void ensurestatsortinfo();
180 // To do with building the list, with heading lines in it
181 void discardheadings();
182 void addheading(enum ssavailval
, enum ssstateval
,
183 pkgpriority
, const char *, const char *section
);
185 bool affectedmatches(struct pkginfo
*pkg
, struct pkginfo
*comparewith
);
186 void affectedrange(int *startp
, int *endp
);
187 void setwant(pkgwant nw
);
188 void sethold(int hold
);
192 // Keybinding functions */
194 void kd_revert_abort();
195 void kd_revertsuggest();
196 void kd_revertdirect();
197 void kd_revertinstalled();
198 void kd_morespecific();
199 void kd_lessspecific();
201 void kd_swapstatorder();
208 void kd_toggleinfo();
210 void kd_archdisplay();
211 void kd_versiondisplay();
213 packagelist(keybindings
*kb
); // nonrecursive
214 packagelist(keybindings
*kb
, pkginfo
**pkgltab
); // recursive
215 void add(pkginfo
**arry
) { while (*arry
) add(*arry
++); }
217 void add(pkginfo
*, pkgwant
);
218 void add(pkginfo
*, const char *extrainfo
, showpriority displayimportance
);
219 bool add(dependency
*, showpriority displayimportance
);
220 void addunavailable(deppossi
*);
221 bool useavailable(pkginfo
*);
222 pkgbin
*find_pkgbin(pkginfo
*);
224 int resolvesuggest();
225 int deletelessimp_anyleft(showpriority than
);
230 void repeatedlydisplay(packagelist
*sub
, showpriority
,
231 packagelist
*unredisplay
= nullptr);
232 int would_like_to_install(pkgwant
, pkginfo
*pkg
);
234 extern const char *const wantstrings
[];
235 extern const char *const eflagstrings
[];
236 extern const char *const statusstrings
[];
237 extern const char *const prioritystrings
[];
238 extern const char *const priorityabbrevs
[];
239 extern const char *const relatestrings
[];
240 extern const char *const ssastrings
[], *const ssaabbrevs
[];
241 extern const char *const sssstrings
[], *const sssabbrevs
[];
242 extern const char statuschars
[];
243 extern const char eflagchars
[];
244 extern const char wantchars
[];
246 #endif /* PKGLIST_H */