]>
Commit | Line | Data |
---|---|---|
2307cd91 ER |
1 | Index: ask.c |
2 | =================================================================== | |
3 | RCS file: /cvsroot/installer/poldek/ask.c,v | |
4 | retrieving revision 1.6 | |
5 | retrieving revision 1.7 | |
6 | diff -u -r1.6 -r1.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 | |
9 | @@ -11,7 +11,7 @@ | |
10 | */ | |
11 | ||
12 | /* | |
13 | - $Id$ | |
14 | + $Id$ | |
15 | */ | |
16 | ||
17 | #ifdef HAVE_CONFIG_H | |
18 | @@ -92,13 +92,18 @@ | |
19 | *p++ = 'a' + i; | |
20 | i++; | |
21 | } | |
22 | + *p++ = 'Q'; | |
23 | ||
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]"), | |
26 | + 'a' + default_i); | |
27 | a = poldek_term_ask(STDIN_FILENO, validchrs, NULL); | |
28 | msg(-1, "_\n"); | |
29 | ||
30 | if (a == '\n') | |
31 | return default_i; | |
32 | + | |
33 | + if (a == 'Q') | |
34 | + return -1; | |
35 | ||
36 | a -= 'a'; | |
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 | |
46 | @@ -1243,7 +1249,8 @@ | |
47 | ||
48 | DBGF("req %s\n", capreq_snprintf_s(req)); | |
49 | ||
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) && | |
52 | + upg->ts->askpkg_fn) | |
53 | tomark_candidates_ptr = &tomark_candidates; | |
54 | ||
55 | if (find_req(pkg, req, &tomark, tomark_candidates_ptr, ps, upg)) { | |
56 | @@ -1301,6 +1308,14 @@ | |
57 | int n; | |
58 | n = upg->ts->askpkg_fn(capreq_snprintf_s(req), | |
59 | tomark_candidates, tomark); | |
60 | + | |
61 | + if (n == -1) { /* user abort */ | |
62 | + free(tomark_candidates); | |
63 | + tomark_candidates = NULL; | |
64 | + upg->nerr_fatal++; | |
65 | + return 0; | |
66 | + } | |
67 | + | |
68 | real_tomark = tomark_candidates[n]; | |
69 | free(tomark_candidates); | |
70 | tomark_candidates = NULL; | |
71 | @@ -1437,12 +1452,15 @@ | |
72 | ||
73 | if (pkg->reqs) | |
74 | process_pkg_reqs(indent, pkg, ps, upg, process_as); | |
75 | - | |
76 | + | |
77 | if (process_as == PROCESS_AS_NEW) { | |
78 | process_pkg_conflicts(indent, pkg, ps, upg); | |
79 | //process_pkg_obsl(pkg, ps, upg, indent); | |
80 | } | |
81 | ||
82 | + if (upg->nerr_fatal || sigint_reached()) | |
83 | + return 0; | |
84 | + | |
85 | DBGF("END PROCESSING [%d] %s as %s\n", indent, pkg_id(pkg), | |
86 | process_as == PROCESS_AS_NEW ? "NEW" : "ORPHAN"); | |
87 | ||
88 | @@ -1532,7 +1550,14 @@ | |
89 | struct pkg *real_tomark = tomark; | |
90 | if (tomark_candidates) { | |
91 | int n; | |
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, | |
94 | + tomark); | |
95 | + if (n == -1) { | |
96 | + n_cfree(&tomark_candidates); | |
97 | + upg->nerr_fatal++; | |
98 | + goto l_end; | |
99 | + } | |
100 | + | |
101 | real_tomark = tomark_candidates[n]; | |
102 | n_cfree(&tomark_candidates); | |
103 | } | |
104 | @@ -1808,6 +1833,9 @@ | |
105 | ||
106 | db = upg->ts->db; | |
107 | ||
108 | + if (upg->nerr_fatal || sigint_reached()) | |
109 | + return 0; | |
110 | + | |
111 | if (!upg->ts->getop(upg->ts, POLDEK_OP_CONFLICTS)) | |
112 | return 1; | |
113 | ||
114 | @@ -1850,7 +1878,9 @@ | |
115 | if (n) | |
116 | pkg_set_unmetdeps(upg->unmetpms, pkg); | |
117 | } | |
118 | - | |
119 | + | |
120 | + if (upg->nerr_fatal || sigint_reached()) | |
121 | + return 0; | |
122 | ||
123 | if (pkg->cnfls != NULL) | |
124 | for (i = 0; i < n_array_size(pkg->cnfls); i++) { | |
125 | @@ -2317,103 +2347,8 @@ | |
126 | return nmarked; | |
127 | } | |
128 | ||
129 | -static | |
130 | -int prepare_icap(struct poldek_ts *ts, const char *capname, tn_array *pkgs) | |
131 | -{ | |
132 | - int i, found = 0; | |
133 | - tn_array *dbpkgs; | |
134 | - struct capreq *cap; | |
135 | - | |
136 | - capreq_new_name_a(capname, cap); | |
137 | - dbpkgs = pkgdb_get_provides_dbpkgs(ts->db, cap, NULL, 0); | |
138 | - if (dbpkgs == NULL) { | |
139 | - struct pkg *pkg; | |
140 | - if (ts->getop(ts, POLDEK_OP_FRESHEN)) | |
141 | - return 0; | |
142 | - | |
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); | |
146 | - return 1; | |
147 | - } | |
148 | - | |
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); | |
154 | - | |
155 | - DBGF("%s: %s\n", capname, pkg_id(dbpkg)); | |
156 | - | |
157 | - if (n < 0) | |
158 | - continue; | |
159 | - | |
160 | - for (; n < n_array_size(pkgs); n++) { | |
161 | - struct pkg *pkg = n_array_nth(pkgs, n); | |
162 | - int cmprc, mark = 0; | |
163 | - | |
164 | - DBGF("%s: %s cmp %s\n", capname, pkg_id(pkg), | |
165 | - pkg_id(dbpkg)); | |
166 | - if (pkg_cmp_name(pkg, dbpkg) != 0) | |
167 | - break; | |
168 | - | |
169 | - cmprc = pkg_cmp_name_evr(pkg, dbpkg); | |
170 | - if (cmprc > 0) | |
171 | - mark = 1; | |
172 | - | |
173 | - else if (cmprc == 0 && poldek_ts_issetf(ts, POLDEK_TS_REINSTALL)) | |
174 | - mark = 1; | |
175 | - | |
176 | - else if (cmprc < 0 && poldek_ts_issetf(ts, POLDEK_TS_DOWNGRADE)) | |
177 | - mark = 1; | |
178 | - | |
179 | - if (mark) { | |
180 | - found = 1; | |
181 | - msgn(1, _("%s: marked as %s's provider"), pkg_id(pkg), | |
182 | - capname); | |
183 | - | |
184 | - pkg_hand_mark(ts->pms, pkg); | |
185 | - goto l_end; | |
186 | - | |
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), | |
191 | - pkg_id(pkg)); | |
192 | - | |
193 | - } else { | |
194 | - n_assert(0); | |
195 | - | |
196 | - } | |
197 | - } | |
198 | - } | |
199 | -l_end: | |
200 | - if (dbpkgs) | |
201 | - n_array_free(dbpkgs); | |
202 | - | |
203 | - return found; | |
204 | -} | |
205 | - | |
206 | -static | |
207 | -int prepare_icaps(struct poldek_ts *ts) | |
208 | -{ | |
209 | - tn_array *keys; | |
210 | - tn_hash *icaps; | |
211 | - int i; | |
212 | - | |
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); | |
219 | - } | |
220 | - n_array_free(keys); | |
221 | - n_hash_free(icaps); | |
222 | - return 1; | |
223 | -} | |
224 | - | |
225 | - | |
226 | +/* use install/ in_prepare_icaps() */ | |
227 | +extern int in_prepare_icaps(struct poldek_ts *ts); | |
228 | ||
229 | int do_poldek_ts_install(struct poldek_ts *ts, struct poldek_iinf *iinf) | |
230 | { | |
231 | @@ -2424,7 +2359,9 @@ | |
232 | ||
233 | n_assert(ts->type == POLDEK_TS_INSTALL); | |
234 | ||
235 | - prepare_icaps(ts); | |
236 | + if (in_prepare_icaps(ts) == -1) /* user abort */ | |
237 | + return 1; | |
238 | + | |
239 | if (unmark_name_dups(ts->pms, ps->pkgs) == 0) { | |
240 | msgn(1, _("Nothing to do")); | |
241 | return 1; | |
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 | |
247 | diff -u -r1.1 -r1.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 | |
250 | @@ -11,7 +11,7 @@ | |
251 | */ | |
252 | ||
253 | /* | |
254 | - $Id$ | |
255 | + $Id$ | |
256 | */ | |
257 | ||
258 | #include "ictx.h" | |
259 | @@ -96,10 +96,13 @@ | |
260 | if (found) { | |
261 | struct pkg *real_tomark = tomark; | |
262 | if (tomark_candidates) { | |
263 | - int n; | |
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, | |
267 | + tomark); | |
268 | n_cfree(&tomark_candidates); | |
269 | + if (real_tomark == NULL) { /* user aborts */ | |
270 | + ictx->nerr_fatal++; | |
271 | + found = 0; | |
272 | + } | |
273 | } | |
274 | tomark = real_tomark; | |
275 | ||
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 | |
281 | diff -u -r1.1 -r1.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 | |
284 | @@ -11,7 +11,7 @@ | |
285 | */ | |
286 | ||
287 | /* | |
288 | - $Id$ | |
289 | + $Id$ | |
290 | */ | |
291 | ||
292 | #include "ictx.h" | |
293 | @@ -25,13 +25,32 @@ | |
294 | ||
295 | capreq_new_name_a(capname, cap); | |
296 | dbpkgs = pkgdb_get_provides_dbpkgs(ts->db, cap, NULL, 0); | |
297 | + | |
298 | if (dbpkgs == NULL) { | |
299 | - struct pkg *pkg; | |
300 | + struct pkg *pkg = NULL; | |
301 | + | |
302 | if (ts->getop(ts, POLDEK_OP_FRESHEN)) | |
303 | return 0; | |
304 | ||
305 | n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev); | |
306 | - pkg = n_array_nth(pkgs, 0); | |
307 | + | |
49c7101e | 308 | + if (ts->getop(ts, POLDEK_OP_EQPKG_ASKUSER) && ts->askpkg_fn && n_array_size(pkgs) > 1) { |
2307cd91 ER |
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; | |
314 | + | |
315 | + pkg = in_choose_equiv(ts, cap, candidates, NULL); | |
316 | + if (pkg == NULL) { /* user aborts */ | |
317 | + found = -1; | |
318 | + goto l_end; | |
319 | + } | |
320 | + } | |
321 | + | |
322 | + if (pkg == NULL) | |
323 | + pkg = n_array_nth(pkgs, 0); | |
324 | + | |
325 | pkg_hand_mark(ts->pms, pkg); | |
326 | return 1; | |
327 | } | |
328 | @@ -65,7 +84,7 @@ | |
329 | ||
330 | else if (cmprc < 0 && poldek_ts_issetf(ts, POLDEK_TS_DOWNGRADE)) | |
331 | mark = 1; | |
332 | - | |
333 | + | |
334 | if (mark) { | |
335 | found = 1; | |
336 | msgn(1, _("%s: marked as %s's provider"), pkg_id(pkg), | |
337 | @@ -82,10 +101,10 @@ | |
338 | ||
339 | } else { | |
340 | n_assert(0); | |
341 | - | |
342 | } | |
343 | } | |
344 | } | |
345 | + | |
346 | l_end: | |
347 | if (dbpkgs) | |
348 | n_array_free(dbpkgs); | |
349 | @@ -93,20 +112,26 @@ | |
350 | return found; | |
351 | } | |
352 | ||
353 | +/* handles --caplookup */ | |
354 | int in_prepare_icaps(struct poldek_ts *ts) | |
355 | { | |
356 | tn_array *keys; | |
357 | tn_hash *icaps; | |
358 | - int i; | |
359 | - | |
360 | + int i, rc = 1; | |
361 | + | |
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); | |
368 | + | |
369 | + if (prepare_icap(ts, cap, pkgs) == -1) { | |
370 | + rc = -1; | |
371 | + break; | |
372 | + } | |
373 | } | |
374 | + | |
375 | n_array_free(keys); | |
376 | n_hash_free(icaps); | |
377 | - return 1; | |
378 | + return rc; | |
379 | } | |
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 | |
385 | diff -u -r1.2 -r1.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 | |
388 | @@ -138,4 +138,7 @@ | |
389 | int in_process_package(int indent, struct install_ctx *ictx, | |
390 | struct pkg *pkg, int process_as); | |
391 | ||
392 | + | |
393 | +struct pkg *in_choose_equiv(struct poldek_ts *ts, struct capreq *cap, | |
394 | + struct pkg **candidates, struct pkg *defaultpkg); | |
395 | #endif | |
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 | |
401 | diff -u -r1.3 -r1.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 | |
404 | @@ -11,7 +11,7 @@ | |
405 | */ | |
406 | ||
407 | /* | |
408 | - $Id$ | |
409 | + $Id$ | |
410 | */ | |
411 | ||
412 | #include <vfile/vfile.h> | |
413 | @@ -352,7 +352,9 @@ | |
414 | struct install_ctx ictx; | |
415 | n_assert(ts->type == POLDEK_TS_INSTALL); | |
416 | ||
417 | - in_prepare_icaps(ts); | |
418 | + if (in_prepare_icaps(ts) < 0) /* user aborts, no error */ | |
419 | + return 1; | |
420 | + | |
421 | if (unmark_name_dups(ts->pms, ts->ctx->ps->pkgs) == 0) { | |
422 | msgn(1, _("Nothing to do")); | |
423 | return 1; | |
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 | |
429 | diff -u -r1.4 -r1.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 | |
432 | @@ -11,7 +11,7 @@ | |
433 | */ | |
434 | ||
435 | /* | |
436 | - $Id$ | |
437 | + $Id$ | |
438 | */ | |
439 | ||
440 | #include "ictx.h" | |
441 | @@ -439,7 +439,7 @@ | |
442 | ||
443 | l_end: | |
444 | ||
445 | - if (candidates && nsuspkgs) { | |
446 | + if (candidates && nsuspkgs > 1) { | |
447 | n_assert(suspkgs); | |
448 | *candidates = suspkgs; | |
449 | ||
450 | @@ -460,3 +460,16 @@ | |
451 | ictx->uninst_set->dbpkgs); | |
452 | } | |
453 | ||
454 | +struct pkg *in_choose_equiv(struct poldek_ts *ts, struct capreq *cap, | |
455 | + struct pkg **candidates, struct pkg *defaultpkg) | |
456 | +{ | |
457 | + int n; | |
458 | + | |
459 | + if (defaultpkg == NULL) | |
460 | + defaultpkg = candidates[0]; | |
461 | + | |
462 | + n = ts->askpkg_fn(capreq_snprintf_s(cap), candidates, defaultpkg); | |
463 | + if (n == -1) | |
464 | + return NULL; | |
465 | + return candidates[n]; | |
466 | +} | |
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 | |
472 | diff -u -r1.3 -r1.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 | |
475 | @@ -11,7 +11,7 @@ | |
476 | */ | |
477 | ||
478 | /* | |
479 | - $Id$ | |
480 | + $Id$ | |
481 | */ | |
482 | ||
483 | #include "ictx.h" | |
484 | @@ -165,12 +165,15 @@ | |
485 | ||
486 | struct pkg *real_tomark = tomark; | |
487 | if (tomark_candidates) { | |
488 | - int n; | |
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, | |
493 | + tomark); | |
494 | free(tomark_candidates); | |
495 | tomark_candidates = NULL; | |
496 | + | |
497 | + if (real_tomark == NULL) { /* user abort */ | |
498 | + ictx->nerr_fatal++; | |
499 | + return 0; | |
500 | + } | |
501 | } | |
502 | ||
503 | if (in_is_marked_for_removal_by_req(ictx, real_tomark, req)) { |