]> git.pld-linux.org Git - packages/poldek.git/blame - poldek-multilib-upgrade.patch
- more fixes
[packages/poldek.git] / poldek-multilib-upgrade.patch
CommitLineData
bf5c5c74
BZ
1diff --git a/install3/misc.c b/install3/misc.c
2index e3d238e..ded4de0 100644
3--- a/install3/misc.c
4+++ b/install3/misc.c
5@@ -16,11 +16,15 @@
6
7 #include "ictx.h"
8
9-int i3_is_pkg_installed(struct poldek_ts *ts, struct pkg *pkg, int *cmprc)
10+int i3_is_pkg_installed(struct poldek_ts *ts, struct pkg *pkg, int *cmprc)
11 {
12 tn_array *dbpkgs = NULL;
13- int n;
14-
15+ int n = 0, freshen = 0;
16+ freshen = ts->getop(ts, POLDEK_OP_FRESHEN)
17+ || poldek_ts_issetf(ts, POLDEK_TS_UPGRADE)
18+ || poldek_ts_issetf(ts, POLDEK_TS_DOWNGRADE)
19+ || poldek_ts_issetf(ts, POLDEK_TS_UPGRADEDIST);
20+
21 n = pkgdb_search(ts->db, &dbpkgs, PMTAG_NAME, pkg->name, NULL, PKG_LDNEVR);
22 n_assert(n >= 0);
23
24@@ -30,17 +34,25 @@ int i3_is_pkg_installed(struct poldek_ts *ts, struct pkg *pkg, int *cmprc)
25 }
26
27 if (poldek_conf_MULTILIB) { /* filter out different architectures */
28- int i;
29 tn_array *arr = n_array_clone(dbpkgs);
30
31 //DBGF("pkg = %s\n", pkg_id(pkg));
32 //pkgs_array_dump(dbpkgs, "before_multilib");
33- for (i=0; i < n_array_size(dbpkgs); i++) {
34+ for (unsigned int i=0; i < n_array_size(dbpkgs); i++) {
35 struct pkg *dbpkg = n_array_nth(dbpkgs, i);
36- if (pkg_is_kind_of(dbpkg, pkg))
37- n_array_push(arr, pkg_link(dbpkg));
38+
39+ msgn(4, "from pkg %s.%s => to pkg %s-%s-%s.%s freshen:%d kind:%d up_arch:%d",
40+ pkg_snprintf_s(dbpkg), pkg_arch(dbpkg), pkg->name, pkg->ver, pkg->rel, pkg_arch(pkg),
41+ freshen, pkg_is_kind_of(dbpkg, pkg), pkg_is_arch_compat(dbpkg, pkg));
42+
43+ // if freshen (upgrade) preffer same arch but
44+ // change from/to noarch depends on which pkg is noarch
45+ // add package if pkg_is_kind_of (have same name and color)
46+ if (pkg_is_kind_of(dbpkg, pkg)
47+ && !(freshen && !pkg_is_arch_compat(dbpkg, pkg)))
48+ n_array_push(arr, pkg_link(dbpkg));
49 }
50-
51+
52 n_array_cfree(&dbpkgs);
53 dbpkgs = arr;
54 n = n_array_size(arr);
55diff --git a/libpoldek.sym b/libpoldek.sym
56index 6c2a356..26e05d5 100644
57--- a/libpoldek.sym
58+++ b/libpoldek.sym
59@@ -71,6 +71,7 @@ pkg_id_snprintf
60 pkg_idevr_snprintf
61 pkg_is_colored_like
62 pkg_is_kind_of
63+pkg_is_arch_compat
64 pkg_link
65 pkg_localpath
66 pkg_match_req
67diff --git a/pkg.h b/pkg.h
68index 8a1d0b2..77acf0a 100644
69--- a/pkg.h
70+++ b/pkg.h
71@@ -43,6 +43,8 @@ struct pkgdir; /* defined in pkgdir/pkgdir.h */
72 ((pkg)->flags & color)
73 #endif /* POLDEK_PKG_DAG_COLOURS */
74
75+#define pkg_is_noarch(pkg) (0 == strcmp(pkg_arch((pkg)), "noarch"))
76+
77 #define pkg_set_prereqed(pkg) ((pkg)->flags |= PKG_ORDER_PREREQ)
78 #define pkg_clr_prereqed(pkg) ((pkg)->flags &= ~PKG_ORDER_PREREQ)
79 #define pkg_is_prereqed(pkg) ((pkg)->flags & PKG_ORDER_PREREQ)
80diff --git a/pkgcmp.c b/pkgcmp.c
81index f123e03..7bf34d4 100644
82--- a/pkgcmp.c
83+++ b/pkgcmp.c
84@@ -88,7 +88,19 @@ int pkg_is_colored_like(const struct pkg *candidate, const struct pkg *pkg)
85 return 1;
86 }
87
88-int pkg_eq_capreq(const struct pkg *pkg, const struct capreq *cr)
89+/* ret : 1 if pkg is cappable to upgrade arch<=>arch, arch<=>noarch */
90+int pkg_is_arch_compat(const struct pkg *candidate, const struct pkg *pkg)
91+{
92+ // if upgrade preffer same arch but
93+ // change from/to noarch depends on which pkg is noarch
94+
95+ int cmp_arch = pkg_cmp_arch(candidate, pkg);
96+ return ( cmp_arch == 0
97+ || (cmp_arch > 0 && pkg_is_noarch(candidate))
98+ || (cmp_arch < 0 && pkg_is_noarch(pkg)));
99+}
100+
101+int pkg_eq_capreq(const struct pkg *pkg, const struct capreq *cr)
102 {
103 return strcmp(pkg->name, capreq_name(cr)) == 0 &&
104 strcmp(pkg->ver, capreq_ver(cr)) == 0 &&
105diff --git a/pkgcmp.h b/pkgcmp.h
d9545c59 106index 6b1b75a..980f675 100644
bf5c5c74
BZ
107--- a/pkgcmp.h
108+++ b/pkgcmp.h
109@@ -17,6 +17,9 @@ int pkg_is_colored_like(const struct pkg *candidate, const struct pkg *pkg);
110 /* same name && arch */
111 int pkg_is_kind_of(const struct pkg *candidate, const struct pkg *pkg);
112
113+/* ret : 0 if pkg is cappable to upgrade arch<=>arch, arch<=>noarch */
114+int pkg_is_arch_compat(const struct pkg *candidate, const struct pkg *pkg);
115+
116 /* strncmp(p1->name, p2->name, strlen(p2->name)) */
117 extern__inline int pkg_ncmp_name(const struct pkg *p1, const struct pkg *p2);
118
d9545c59
BZ
119@@ -27,7 +30,7 @@ int pkg_cmp_name(const struct pkg *p1, const struct pkg *p2);
120 extern__inline int pkg_cmp_id(const struct pkg *p1, const struct pkg *p2);
121
122
123-/* versions only */
124+/* versions only (+epoch) */
125 int pkg_cmp_ver(const struct pkg *p1, const struct pkg *p2);
126 /* EVR only */
127 int pkg_cmp_evr(const struct pkg *p1, const struct pkg *p2);
bf5c5c74
BZ
128diff --git a/upgrade-dist.c b/upgrade-dist.c
129index 458b764..00f34fc 100644
130--- a/upgrade-dist.c
131+++ b/upgrade-dist.c
132@@ -64,8 +64,18 @@ int process_pkg(const struct pkg *dbpkg, struct poldek_ts *ts,
133
134 if (!ts->getop(ts, POLDEK_OP_MULTILIB))
135 break;
136-
137- if (pkg_is_kind_of(pkg, dbpkg))
138+
139+ if (0 != strcmp(dbpkg->name, pkg->name))
140+ {
141+ pkg = NULL;
142+ break;
143+ }
144+
145+ msgn(4, "UPGRADE-DIST from pkg %s.%s => to pkg %s-%s-%s.%s kind:%d up_arch:%d",
146+ pkg_snprintf_s(dbpkg), pkg_arch(dbpkg), pkg->name, pkg->ver, pkg->rel, pkg_arch(pkg),
147+ pkg_is_kind_of(dbpkg, pkg), pkg_is_arch_compat(dbpkg, pkg));
148+
149+ if (pkg_cmp_evr(pkg, dbpkg) > 0 && pkg_is_kind_of(pkg, dbpkg) && pkg_is_arch_compat(pkg, dbpkg))
150 break;
151
152 i++;
This page took 0.093116 seconds and 4 git commands to generate.