2 ===================================================================
3 RCS file: /cvsroot/installer/poldek/ask.c,v
4 retrieving revision 1.6
5 retrieving revision 1.7
7 --- ask.c 14 Apr 2003 16:28:09 -0000 1.6
8 +++ ask.c 3 Nov 2005 00:16:58 -0000 1.7
24 - msg(-1, _("Which one do you want to install? [%c]"), 'a' + default_i);
25 + msg(-1, _("Which one do you want to install ('Q' to abort)? [%c]"),
27 a = poldek_term_ask(STDIN_FILENO, validchrs, NULL);
37 //printf("Selected %d\n", a);
38 Index: pkgset-install.c
39 ===================================================================
40 RCS file: /cvsroot/installer/poldek/pkgset-install.c,v
41 retrieving revision 1.148
42 retrieving revision 1.149
43 diff -u -r1.148 -r1.149
44 --- pkgset-install.c 1 Nov 2005 19:36:36 -0000 1.148
45 +++ pkgset-install.c 3 Nov 2005 00:21:00 -0000 1.149
48 DBGF("req %s\n", capreq_snprintf_s(req));
50 - if (upg->ts->getop(upg->ts, POLDEK_OP_EQPKG_ASKUSER) && upg->ts->askpkg_fn)
51 + if (upg->ts->getop(upg->ts, POLDEK_OP_EQPKG_ASKUSER) &&
53 tomark_candidates_ptr = &tomark_candidates;
55 if (find_req(pkg, req, &tomark, tomark_candidates_ptr, ps, upg)) {
56 @@ -1301,6 +1308,14 @@
58 n = upg->ts->askpkg_fn(capreq_snprintf_s(req),
59 tomark_candidates, tomark);
61 + if (n == -1) { /* user abort */
62 + free(tomark_candidates);
63 + tomark_candidates = NULL;
68 real_tomark = tomark_candidates[n];
69 free(tomark_candidates);
70 tomark_candidates = NULL;
71 @@ -1437,12 +1452,15 @@
74 process_pkg_reqs(indent, pkg, ps, upg, process_as);
77 if (process_as == PROCESS_AS_NEW) {
78 process_pkg_conflicts(indent, pkg, ps, upg);
79 //process_pkg_obsl(pkg, ps, upg, indent);
82 + if (upg->nerr_fatal || sigint_reached())
85 DBGF("END PROCESSING [%d] %s as %s\n", indent, pkg_id(pkg),
86 process_as == PROCESS_AS_NEW ? "NEW" : "ORPHAN");
88 @@ -1532,7 +1550,14 @@
89 struct pkg *real_tomark = tomark;
90 if (tomark_candidates) {
92 - n = upg->ts->askpkg_fn(capreq_snprintf_s(req), tomark_candidates, tomark);
93 + n = upg->ts->askpkg_fn(capreq_snprintf_s(req), tomark_candidates,
96 + n_cfree(&tomark_candidates);
101 real_tomark = tomark_candidates[n];
102 n_cfree(&tomark_candidates);
104 @@ -1808,6 +1833,9 @@
108 + if (upg->nerr_fatal || sigint_reached())
111 if (!upg->ts->getop(upg->ts, POLDEK_OP_CONFLICTS))
114 @@ -1850,7 +1878,9 @@
116 pkg_set_unmetdeps(upg->unmetpms, pkg);
120 + if (upg->nerr_fatal || sigint_reached())
123 if (pkg->cnfls != NULL)
124 for (i = 0; i < n_array_size(pkg->cnfls); i++) {
125 @@ -2317,103 +2347,8 @@
130 -int prepare_icap(struct poldek_ts *ts, const char *capname, tn_array *pkgs)
134 - struct capreq *cap;
136 - capreq_new_name_a(capname, cap);
137 - dbpkgs = pkgdb_get_provides_dbpkgs(ts->db, cap, NULL, 0);
138 - if (dbpkgs == NULL) {
140 - if (ts->getop(ts, POLDEK_OP_FRESHEN))
143 - n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev);
144 - pkg = n_array_nth(pkgs, 0);
145 - pkg_hand_mark(ts->pms, pkg);
149 - n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev);
150 - for (i=0; i < n_array_size(dbpkgs); i++) {
151 - struct pkg *dbpkg = n_array_nth(dbpkgs, i);
152 - int n = n_array_bsearch_idx_ex(pkgs, dbpkg,
153 - (tn_fn_cmp)pkg_cmp_name);
155 - DBGF("%s: %s\n", capname, pkg_id(dbpkg));
160 - for (; n < n_array_size(pkgs); n++) {
161 - struct pkg *pkg = n_array_nth(pkgs, n);
162 - int cmprc, mark = 0;
164 - DBGF("%s: %s cmp %s\n", capname, pkg_id(pkg),
166 - if (pkg_cmp_name(pkg, dbpkg) != 0)
169 - cmprc = pkg_cmp_name_evr(pkg, dbpkg);
173 - else if (cmprc == 0 && poldek_ts_issetf(ts, POLDEK_TS_REINSTALL))
176 - else if (cmprc < 0 && poldek_ts_issetf(ts, POLDEK_TS_DOWNGRADE))
181 - msgn(1, _("%s: marked as %s's provider"), pkg_id(pkg),
184 - pkg_hand_mark(ts->pms, pkg);
187 - } else if (cmprc <= 0) {
188 - char *eqs = cmprc == 0 ? "equal" : "newer";
189 - msgn(1, _("%s: %s version of %s is installed (%s), skipped"),
190 - capname, eqs, pkg_id(dbpkg),
201 - n_array_free(dbpkgs);
207 -int prepare_icaps(struct poldek_ts *ts)
213 - icaps = arg_packages_get_resolved_caps(ts->aps);
214 - keys = n_hash_keys_cp(icaps);
215 - for (i=0; i < n_array_size(keys); i++) {
216 - const char *cap = n_array_nth(keys, i);
217 - tn_array *pkgs = n_hash_get(icaps, cap);
218 - prepare_icap(ts, cap, pkgs);
220 - n_array_free(keys);
221 - n_hash_free(icaps);
226 +/* use install/ in_prepare_icaps() */
227 +extern int in_prepare_icaps(struct poldek_ts *ts);
229 int do_poldek_ts_install(struct poldek_ts *ts, struct poldek_iinf *iinf)
231 @@ -2424,7 +2359,9 @@
233 n_assert(ts->type == POLDEK_TS_INSTALL);
236 + if (in_prepare_icaps(ts) == -1) /* user abort */
239 if (unmark_name_dups(ts->pms, ps->pkgs) == 0) {
240 msgn(1, _("Nothing to do"));
242 Index: install/conflicts.c
243 ===================================================================
244 RCS file: /cvsroot/installer/poldek/install/conflicts.c,v
245 retrieving revision 1.1
246 retrieving revision 1.2
248 --- install/conflicts.c 9 Jul 2005 17:51:18 -0000 1.1
249 +++ install/conflicts.c 3 Nov 2005 00:21:05 -0000 1.2
261 struct pkg *real_tomark = tomark;
262 if (tomark_candidates) {
264 - n = ictx->ts->askpkg_fn(capreq_snprintf_s(req), tomark_candidates, tomark);
265 - real_tomark = tomark_candidates[n];
266 + real_tomark = in_choose_equiv(ictx->ts, req, tomark_candidates,
268 n_cfree(&tomark_candidates);
269 + if (real_tomark == NULL) { /* user aborts */
270 + ictx->nerr_fatal++;
274 tomark = real_tomark;
276 Index: install/icaps.c
277 ===================================================================
278 RCS file: /cvsroot/installer/poldek/install/icaps.c,v
279 retrieving revision 1.1
280 retrieving revision 1.2
282 --- install/icaps.c 9 Jul 2005 17:51:18 -0000 1.1
283 +++ install/icaps.c 3 Nov 2005 00:21:05 -0000 1.2
295 capreq_new_name_a(capname, cap);
296 dbpkgs = pkgdb_get_provides_dbpkgs(ts->db, cap, NULL, 0);
298 if (dbpkgs == NULL) {
300 + struct pkg *pkg = NULL;
302 if (ts->getop(ts, POLDEK_OP_FRESHEN))
305 n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev);
306 - pkg = n_array_nth(pkgs, 0);
308 + if (ts->getop(ts, POLDEK_OP_EQPKG_ASKUSER) && ts->askpkg_fn && n_array_size(pkgs) > 1) {
309 + struct pkg **candidates = alloca(sizeof(struct pkg *) *
310 + (n_array_size(pkgs) + 1));
311 + for (i=0; i < n_array_size(pkgs); i++)
312 + candidates[i] = n_array_nth(pkgs, i);
313 + candidates[i] = NULL;
315 + pkg = in_choose_equiv(ts, cap, candidates, NULL);
316 + if (pkg == NULL) { /* user aborts */
323 + pkg = n_array_nth(pkgs, 0);
325 pkg_hand_mark(ts->pms, pkg);
330 else if (cmprc < 0 && poldek_ts_issetf(ts, POLDEK_TS_DOWNGRADE))
336 msgn(1, _("%s: marked as %s's provider"), pkg_id(pkg),
348 n_array_free(dbpkgs);
353 +/* handles --caplookup */
354 int in_prepare_icaps(struct poldek_ts *ts)
362 icaps = arg_packages_get_resolved_caps(ts->aps);
363 keys = n_hash_keys_cp(icaps);
364 for (i=0; i < n_array_size(keys); i++) {
365 const char *cap = n_array_nth(keys, i);
366 tn_array *pkgs = n_hash_get(icaps, cap);
367 - prepare_icap(ts, cap, pkgs);
369 + if (prepare_icap(ts, cap, pkgs) == -1) {
380 Index: install/ictx.h
381 ===================================================================
382 RCS file: /cvsroot/installer/poldek/install/ictx.h,v
383 retrieving revision 1.2
384 retrieving revision 1.3
386 --- install/ictx.h 20 Oct 2005 18:19:16 -0000 1.2
387 +++ install/ictx.h 3 Nov 2005 00:21:05 -0000 1.3
389 int in_process_package(int indent, struct install_ctx *ictx,
390 struct pkg *pkg, int process_as);
393 +struct pkg *in_choose_equiv(struct poldek_ts *ts, struct capreq *cap,
394 + struct pkg **candidates, struct pkg *defaultpkg);
396 Index: install/install.c
397 ===================================================================
398 RCS file: /cvsroot/installer/poldek/install/install.c,v
399 retrieving revision 1.3
400 retrieving revision 1.4
402 --- install/install.c 15 Sep 2005 18:00:35 -0000 1.3
403 +++ install/install.c 3 Nov 2005 00:21:05 -0000 1.4
412 #include <vfile/vfile.h>
414 struct install_ctx ictx;
415 n_assert(ts->type == POLDEK_TS_INSTALL);
417 - in_prepare_icaps(ts);
418 + if (in_prepare_icaps(ts) < 0) /* user aborts, no error */
421 if (unmark_name_dups(ts->pms, ts->ctx->ps->pkgs) == 0) {
422 msgn(1, _("Nothing to do"));
424 Index: install/misc.c
425 ===================================================================
426 RCS file: /cvsroot/installer/poldek/install/misc.c,v
427 retrieving revision 1.4
428 retrieving revision 1.5
430 --- install/misc.c 20 Oct 2005 17:57:51 -0000 1.4
431 +++ install/misc.c 3 Nov 2005 00:18:36 -0000 1.5
445 - if (candidates && nsuspkgs) {
446 + if (candidates && nsuspkgs > 1) {
448 *candidates = suspkgs;
451 ictx->uninst_set->dbpkgs);
454 +struct pkg *in_choose_equiv(struct poldek_ts *ts, struct capreq *cap,
455 + struct pkg **candidates, struct pkg *defaultpkg)
459 + if (defaultpkg == NULL)
460 + defaultpkg = candidates[0];
462 + n = ts->askpkg_fn(capreq_snprintf_s(cap), candidates, defaultpkg);
465 + return candidates[n];
467 Index: install/requirements.c
468 ===================================================================
469 RCS file: /cvsroot/installer/poldek/install/requirements.c,v
470 retrieving revision 1.3
471 retrieving revision 1.4
473 --- install/requirements.c 20 Oct 2005 18:19:16 -0000 1.3
474 +++ install/requirements.c 3 Nov 2005 00:21:05 -0000 1.4
484 @@ -165,12 +165,15 @@
486 struct pkg *real_tomark = tomark;
487 if (tomark_candidates) {
489 - n = ictx->ts->askpkg_fn(capreq_snprintf_s(req),
490 - tomark_candidates, tomark);
491 - real_tomark = tomark_candidates[n];
492 + real_tomark = in_choose_equiv(ictx->ts, req, tomark_candidates,
494 free(tomark_candidates);
495 tomark_candidates = NULL;
497 + if (real_tomark == NULL) { /* user abort */
498 + ictx->nerr_fatal++;
503 if (in_is_marked_for_removal_by_req(ictx, real_tomark, req)) {