2 ===================================================================
3 RCS file: /cvsroot/installer/poldek/main.c,v
4 retrieving revision 1.110.4.14
5 retrieving revision 1.110.4.15
6 diff -u -r1.110.4.14 -r1.110.4.15
7 --- main.c 6 Jun 2004 20:47:51 -0000 1.110.4.14
8 +++ main.c 2 Jul 2004 17:42:39 -0000 1.110.4.15
19 #define OPT_INST_DOWNGRADE 1058
20 #define OPT_INST_UNIQNAMES 'Q'
22 -#define OPT_RPMONLY_FORCE 1059
23 -#define OPT_RPMONLY_NODEPS 1060
24 +#define OPT_CAPLOOKUP 1059
25 +#define OPT_RPMONLY_FORCE 1070
26 +#define OPT_RPMONLY_NODEPS 1071
29 #define OPT_UNINSTALL 'e'
32 {0,0,0,0, N_("Packages spec:"), 65},
33 {"pset", OPT_PKGSET, "FILE", 0, N_("Take package set definition from FILE"), 65 },
34 {"pkgset", 0, 0, OPTION_ALIAS | OPTION_HIDDEN, 0, 65 }, /* backward compat */
35 +{"caplookup", OPT_CAPLOOKUP, 0, 0,
36 + N_("Look into package capabilities & files to resolve packages"), 65 },
40 {"nevr", OPT_NEVR, "\"NAME [[E:][V[-R]]]\"", OPTION_HIDDEN,
43 {"nodeps", OPT_INST_NODEPS, 0, 0,
44 N_("Install packages with broken dependencies"), 71 },
47 {"force", OPT_INST_FORCE, 0, 0,
48 N_("Be unconcerned"), 71 },
52 n_array_push(argsp->pkgdef_sets, arg);
56 + argsp->inst.flags |= INSTS_CAPLOOKUP;
60 if (argsp->mjrmode != MODE_SRCLIST)
61 Index: pkgset-install.c
62 ===================================================================
63 RCS file: /cvsroot/installer/poldek/pkgset-install.c,v
64 retrieving revision 1.82.4.10
65 retrieving revision 1.82.4.11
66 diff -u -r1.82.4.10 -r1.82.4.11
67 --- pkgset-install.c 22 Jun 2004 17:13:35 -0000 1.82.4.10
68 +++ pkgset-install.c 2 Jul 2004 17:42:39 -0000 1.82.4.11
79 logn(LOGERR, msg, pkg_snprintf_s(pkg), eqs, giveup);
82 - } else if (is_hand_marked && !freshen) { /* msg without "freshen" */
83 - msgn(0, msg, pkg_snprintf_s(pkg), eqs, skiped);
85 + } else if (is_hand_marked) {
89 + msgn(vl, msg, pkg_snprintf_s(pkg), eqs, skiped);
93 @@ -2331,11 +2333,10 @@
98 -int unmark_name_dups(tn_array *pkgs)
99 +static int unmark_name_dups(tn_array *pkgs)
101 struct pkg *pkg, *pkg2;
105 if (n_array_size(pkgs) < 2)
107 @@ -2349,7 +2350,8 @@
109 if (!pkg_is_marked(pkg))
114 DBGF("%s\n", pkg_snprintf_s(pkg));
117 @@ -2360,6 +2362,7 @@
122 if (i == n_array_size(pkgs))
124 pkg2 = n_array_nth(pkgs, i);
125 @@ -2367,9 +2370,100 @@
134 +int prepare_icap(struct upgrade_s *upg, const char *capname, tn_array *pkgs)
138 + struct capreq *cap = capreq_new_name_a(capname);
140 + dbpkgs = rpm_get_provides_dbpkgs(upg->inst->db->dbh, cap, NULL, 0);
141 + if (dbpkgs == NULL) {
143 + if (upg->inst->flags & INSTS_FRESHEN)
146 + pkg = n_array_nth(pkgs, 0);
147 + pkg_hand_mark(pkg);
151 + n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev);
153 + for (i=0; i < n_array_size(dbpkgs); i++) {
154 + struct dbpkg *dbpkg = n_array_nth(dbpkgs, i);
155 + int n = n_array_bsearch_idx_ex(pkgs, dbpkg->pkg,
156 + (tn_fn_cmp)pkg_cmp_name);
158 + DBGF("%s: %s\n", capname, pkg_snprintf_s0(dbpkg->pkg));
163 + for (; n < n_array_size(pkgs); n++) {
164 + struct pkg *pkg = n_array_nth(pkgs, n);
165 + int cmprc, mark = 0;
167 + DBGF("%s: %s cmp %s\n", capname, pkg_snprintf_s(pkg),
168 + pkg_snprintf_s0(dbpkg->pkg));
169 + if (pkg_cmp_name(pkg, dbpkg->pkg) != 0)
172 + cmprc = pkg_cmp_name_evr(pkg, dbpkg->pkg);
176 + else if (cmprc == 0 && upg->inst->flags & INSTS_REINSTALL)
179 + else if (cmprc < 0 && upg->inst->flags & INSTS_DOWNGRADE)
184 + msgn(1, "%s: marked as %s provider", pkg_snprintf_s(pkg),
187 + pkg_hand_mark(pkg);
190 + } else if (cmprc <= 0) {
191 + char *eqs = cmprc == 0 ? "equal" : "newer";
192 + msgn(1, "%s: %s version of %s is installed (%s), skipped",
193 + capname, eqs, pkg_snprintf_s0(dbpkg->pkg),
194 + pkg_snprintf_s(pkg));
204 + n_array_free(dbpkgs);
210 +int prepare_icaps(struct upgrade_s *upg)
215 + keys = n_hash_keys_cp(upg->inst->icaps);
216 + for (i=0; i < n_array_size(keys); i++) {
217 + const char *cap = n_array_nth(keys, i);
218 + tn_array *pkgs = n_hash_get(upg->inst->icaps, cap);
219 + prepare_icap(upg, cap, pkgs);
221 + n_array_free(keys);
225 int pkgset_install(struct pkgset *ps, struct inst_s *inst,
226 struct install_info *iinf)
227 @@ -2381,13 +2475,15 @@
228 if (inst->flags & INSTS_INSTALL)
229 n_assert((inst->flags & INSTS_UPGRADE) == 0);
232 packages_mark(ps->pkgs, 0, PKG_INTERNALMARK | PKG_INDIRMARK);
234 - unmark_name_dups(ps->pkgs);
236 - mem_info(1, "ENTER pkgset_install:");
237 + mem_info(2, "ENTER pkgset_install:");
238 init_upgrade_s(&upg, ps, inst);
239 + prepare_icaps(&upg);
240 + if (unmark_name_dups(ps->pkgs) == 0) {
241 + msgn(1, _("Nothing to do"));
245 is_particle = inst->flags & INSTS_PARTICLE;
247 @@ -2421,8 +2517,11 @@
252 + if (nmarked == 0) {
253 + msgn(1, _("Nothing to do"));
259 inst->flags &= ~INSTS_PARTICLE;
261 ===================================================================
262 RCS file: /cvsroot/installer/poldek/pkgset.c,v
263 retrieving revision 1.55.4.3
264 retrieving revision 1.55.4.4
265 diff -u -r1.55.4.3 -r1.55.4.4
266 --- pkgset.c 6 Jun 2004 20:47:51 -0000 1.55.4.3
267 +++ pkgset.c 2 Jul 2004 17:42:40 -0000 1.55.4.4
278 inst->rpmopts = n_array_new(4, free, (tn_fn_cmp)strcmp);
279 inst->hold_patterns = n_array_new(4, free, (tn_fn_cmp)strcmp);
280 inst->ign_patterns = n_array_new(4, free, (tn_fn_cmp)strcmp);
281 + inst->icaps = n_hash_new(21, (tn_fn_free)n_array_free);
284 struct pkgset *pkgset_new(unsigned optflags)
289 +static int pkgset_mark_bycap(struct pkgset *ps, struct inst_s *inst,
290 + const struct pkgdef *pdef)
294 + n_assert(inst->flags & INSTS_CAPLOOKUP);
296 + pkgs = pkgset_lookup_cap(ps, pdef->pkg->name);
297 + if (pkgs == NULL || n_array_size(pkgs) == 0) {
298 + logn(LOGERR, _("mark: %s not found"), pdef->pkg->name);
300 + n_array_free(pkgs);
307 + msgn(2, "%s: %d package(s) found:", pdef->pkg->name,
308 + n_array_size(pkgs));
309 + for (i=0; i<n_array_size(pkgs); i++)
310 + msgn(2, " - %s", pkg_snprintf_s(n_array_nth(pkgs, i)));
314 + n_hash_insert(inst->icaps, pdef->pkg->name, pkgs);
315 + return n_array_size(pkgs);
321 -int pkgset_mark_pkgdef_exact(struct pkgset *ps, const struct pkgdef *pdef,
323 +int pkgset_mark_pkgdef_exact(struct pkgset *ps, struct inst_s *inst,
324 + const struct pkgdef *pdef, int nodeps)
326 int i, marked = 0, matched = 0;
327 struct pkg *pkg, tmpkg, *findedpkg;
328 @@ -851,10 +883,13 @@
330 i = n_array_bsearch_idx_ex(ps->pkgs, pdef->pkg, (tn_fn_cmp)pkg_cmp_name);
332 + if (inst->flags & INSTS_CAPLOOKUP)
333 + return pkgset_mark_bycap(ps, inst, pdef);
334 logn(LOGERR, _("mark: %s not found"), pdef->pkg->name);
339 findedpkg = pkg = n_array_nth(ps->pkgs, i);
341 if (pkg_match_pkgdef(pkg, pdef)) {
347 if (!marked && !matched)
348 logn(LOGERR, _("mark: %s: versions not match"), pdef->pkg->name);
358 +static int pkgset_mark_verify_icaps(struct inst_s *inst)
363 + keys = n_hash_keys_cp(inst->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(inst->icaps, cap);
368 + for (j=0; j < n_array_size(pkgs); j++) {
369 + struct pkg *pkg = n_array_nth(pkgs, j);
370 + if (pkg_is_marked(pkg)) {
371 + logn(LOGNOTICE, "%s: removed cap due to %s is marked",
372 + cap, pkg_snprintf_s0(pkg));
373 + n_hash_remove(inst->icaps, cap);
378 + n_array_free(keys);
379 + return n_hash_size(inst->icaps);
383 int pkgset_mark_usrset(struct pkgset *ps, struct usrpkgset *ups,
386 int i, nerr = 0, nodeps = 0, npatterns = 0;
388 + n_hash_clean(inst->icaps);
389 packages_mark(ps->pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK);
390 //pkgset_mark(ps, PS_MARK_OFF_ALL);
393 for (i=0; i<n_array_size(ups->pkgdefs); i++) {
394 struct pkgdef *pdef = n_array_nth(ups->pkgdefs, i);
395 if (pdef->tflags & (PKGDEF_REGNAME | PKGDEF_PKGFILE)) {
396 - if (!pkgset_mark_pkgdef_exact(ps, pdef, nodeps))
397 + if (!pkgset_mark_pkgdef_exact(ps, inst, pdef, nodeps))
400 } else if (pdef->tflags & PKGDEF_PATTERN) {
403 } else if (pdef->tflags & PKGDEF_VIRTUAL) { /* VIRTUAL implies OPTIONAL */
408 if (pdef->pkg == NULL) {
409 @@ -1010,7 +1071,7 @@
410 if ((inst->flags & INSTS_CONFIRM_INST) && inst->ask_fn &&
411 inst->ask_fn(0, "Install %s? [y/N]", pdef->pkg->name));
413 - if (!pkgset_mark_pkgdef_exact(ps, pdef, nodeps))
414 + if (!pkgset_mark_pkgdef_exact(ps, inst, pdef, nodeps))
418 @@ -1036,7 +1097,8 @@
419 logn(LOGERR, _("Buggy package set."));
424 + pkgset_mark_verify_icaps(inst);
428 @@ -1056,8 +1118,40 @@
429 return n_array_nth(ps->pkgs, i);
432 +tn_array *pkgset_lookup_cap(struct pkgset *ps, const char *capname)
434 + struct pkg **suspkgs, pkgsbuf[1024];
435 + int i, nsuspkgs = 0, found = 0;
436 + tn_array *pkgs = NULL;
437 + struct capreq *cap = capreq_new_name_a(capname);
439 + DBGF("%s\n", capname);
441 + found = psreq_lookup(ps, cap, &suspkgs, (struct pkg **)pkgsbuf, &nsuspkgs);
442 + if (found && nsuspkgs) {
443 + struct pkg **matches;
444 + int nmatches = 0, strict;
447 + matches = alloca(sizeof(*matches) * nsuspkgs);
448 + strict = ps->flags & PSVERIFY_MERCY ? 0 : 1;
449 + if (psreq_match_pkgs(NULL, cap, strict, suspkgs,
450 + nsuspkgs, matches, &nmatches)) {
452 + pkgs = n_array_new(nmatches, NULL,
453 + (tn_fn_cmp)pkg_cmp_name_evr_rev);
455 + if (nmatches > 0) {
456 + for (i=0; i < nmatches; i++)
457 + n_array_push(pkgs, matches[i]);
465 -tn_array *pkgset_lookup_cap(struct pkgset *ps, const char *capname)
466 +tn_array *pkgset_lookup_cap_OLD(struct pkgset *ps, const char *capname)
468 const struct capreq_idx_ent *ent;
469 tn_array *pkgs = NULL;
471 ===================================================================
472 RCS file: /cvsroot/installer/poldek/pkgset.h,v
473 retrieving revision 1.37.4.2
474 retrieving revision 1.37.4.3
475 diff -u -r1.37.4.2 -r1.37.4.3
476 --- pkgset.h 16 Feb 2004 19:39:57 -0000 1.37.4.2
477 +++ pkgset.h 2 Jul 2004 17:42:40 -0000 1.37.4.3
481 #ifndef POLDEK_PKGSET_H
482 #define POLDEK_PKGSET_H
485 #define INSTS_JUSTFETCH (1 << 10)
486 #define INSTS_JUSTPRINT (1 << 11)
487 #define INSTS_JUSTPRINT_N (1 << 12) /* names, not filenames */
489 #define INSTS_JUSTPRINTS (INSTS_JUSTPRINT | INSTS_JUSTPRINT_N)
490 +#define INSTS_CAPLOOKUP (1 << 13)
493 #define INSTS_MKDBDIR (1 << 15) /* --mkdir */
495 tn_array *rpmopts; /* rpm cmdline opts (char *opts[]) */
496 tn_array *rpmacros; /* rpm macros to pass to cmdline (char *opts[]) */
497 tn_array *hold_patterns;
498 - tn_array *ign_patterns;
499 + tn_array *ign_patterns;
502 int (*askpkg_fn)(const char *, struct pkg **pkgs, struct pkg *deflt);
503 int (*ask_fn)(int default_a, const char *, ...);
505 ===================================================================
506 RCS file: /cvsroot/installer/poldek/Attic/rpm.c,v
507 retrieving revision 1.41.4.4
508 retrieving revision 1.41.4.5
509 diff -u -r1.41.4.4 -r1.41.4.5
510 --- rpm.c 28 Jun 2004 20:18:39 -0000 1.41.4.4
511 +++ rpm.c 2 Jul 2004 17:42:40 -0000 1.41.4.5
523 rpmdb_it_init(db, &it, RPMITER_CAP, capreq_name(cap));
524 while ((dbrec = rpmdb_it_get(&it))) {
525 - if (dbpkg_array_has(unistdbpkgs, dbrec->recno))
526 + if (unistdbpkgs && dbpkg_array_has(unistdbpkgs, dbrec->recno))
531 ===================================================================
532 RCS file: /cvsroot/installer/poldek/Attic/usrset.c,v
533 retrieving revision 1.12.6.1
534 retrieving revision 1.12.6.2
535 diff -u -r1.12.6.1 -r1.12.6.2
536 --- usrset.c 30 Dec 2003 18:19:52 -0000 1.12.6.1
537 +++ usrset.c 2 Jul 2004 17:42:40 -0000 1.12.6.2
548 if (*p == '\0' || *p == '#')
551 - while (*p && !isalnum(*p)) {
552 + while (*p && !isalnum(*p) && *p != '/') {
555 case '!': /* for backward compatybility */
560 - if (!isalnum(*p)) {
561 + if (!isalnum(*p) && *p != '/') {
563 logn(LOGERR, _("%s:%d: syntax error"), fpath, nline);
568 pdef = n_malloc(sizeof(*pdef) +
569 - (virtname ? strlen(virtname) + 1 : 0));
570 + (virtname ? strlen(virtname) + 1 : 0));
571 pdef->tflags = tflags | deftyp;