summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorAlejandro del Castillo <alejandro.delcastillo@ni.com>2019-06-11 16:46:47 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-29 23:50:43 +0100
commiteecc4121ad3efac4242b023245bccc21439ecc1f (patch)
tree395df86bbc9c371ffc1fdab99cc7190030379c45 /meta/recipes-devtools
parenta872c9619288744f55da64ebf599434053594238 (diff)
downloadpoky-eecc4121ad3efac4242b023245bccc21439ecc1f.tar.gz
opkg: add --ignore-recommends flag
To be used for BAD_RECOMMENDATIONS feature. (From OE-Core rev: 788d97b4f8e4452cef1ba6bb3e565e1b52dbb7de) (From OE-Core rev: 85007cdb260bc77ac4ae5f914b0e3a4408606dfd) (From OE-Core rev: c60f9c47380bb53bd2b54373b72f86006edf326e) Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> [Backport from opkg_0.4.0.bb] Signed-off-by: Quentin Schulz <quentin.schulz@streamunlimited.com> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/opkg/opkg/0001-libopkg-add-add-ignore-recommends-option.patch260
-rw-r--r--meta/recipes-devtools/opkg/opkg_0.3.6.bb1
2 files changed, 261 insertions, 0 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/0001-libopkg-add-add-ignore-recommends-option.patch b/meta/recipes-devtools/opkg/opkg/0001-libopkg-add-add-ignore-recommends-option.patch
new file mode 100644
index 0000000000..11954e9032
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0001-libopkg-add-add-ignore-recommends-option.patch
@@ -0,0 +1,260 @@
1From 2eca28b6a37be92e4e835c51872c7df34ec6dedd Mon Sep 17 00:00:00 2001
2From: Quentin Schulz <quentin.schulz@streamunlimited.com>
3Date: Fri, 31 May 2019 17:30:40 +0200
4Subject: [PATCH] [PATCH] libopkg: add --add-ignore-recommends option
5
6Add option to ignore specific recommended packages. On the libsolv
7backed, this feature will only work on libsolv version > 0.7.2 [1].
8
9[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_openSUSE_libsolv_issues_254&d=DwIBaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=wNcrL2akRn6jfxhHaKavUrJB_C9JAMXtynjLd8ZzgXQ&m=GObNHzFJpWpf_PripIrf-K2RhsktYdAUEieAJexXOKw&s=3G-meChUqClFggFPqsrAxIZBfLnRKIHm62Uuy1X6nQQ&e=
10
11Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
12Signed-off-by: Quentin Schulz <quentin.schulz@streamunlimited.com>
13
14Upstream-Status: Backport
15---
16 libopkg/opkg_conf.c | 2 +
17 libopkg/opkg_conf.h | 1 +
18 .../solvers/internal/pkg_depends_internal.c | 3 +-
19 libopkg/solvers/libsolv/opkg_solver_libsolv.c | 21 ++++++-
20 man/opkg.1.in | 3 +
21 src/opkg.c | 6 ++
22 tests/Makefile | 1 +
23 tests/core/43_add_ignore_recommends.py | 62 +++++++++++++++++++
24 8 files changed, 97 insertions(+), 2 deletions(-)
25 create mode 100644 tests/core/43_add_ignore_recommends.py
26
27diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
28index 06880a1..f2330cd 100644
29--- a/libopkg/opkg_conf.c
30+++ b/libopkg/opkg_conf.c
31@@ -597,6 +597,7 @@ int opkg_conf_init(void)
32 pkg_dest_list_init(&opkg_config->tmp_dest_list);
33 nv_pair_list_init(&opkg_config->arch_list);
34 str_list_init(&opkg_config->exclude_list);
35+ str_list_init(&opkg_config->ignore_recommends_list);
36
37 return 0;
38 }
39@@ -938,6 +939,7 @@ void opkg_conf_deinit(void)
40 pkg_dest_list_deinit(&opkg_config->pkg_dest_list);
41 nv_pair_list_deinit(&opkg_config->arch_list);
42 str_list_deinit(&opkg_config->exclude_list);
43+ str_list_deinit(&opkg_config->ignore_recommends_list);
44
45 if (opkg_config->verbosity >= DEBUG) {
46 hash_print_stats(&opkg_config->pkg_hash);
47diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
48index dc11516..fc42de3 100644
49--- a/libopkg/opkg_conf.h
50+++ b/libopkg/opkg_conf.h
51@@ -61,6 +61,7 @@ typedef struct opkg_conf {
52 pkg_dest_list_t tmp_dest_list;
53 nv_pair_list_t arch_list;
54 str_list_t exclude_list;
55+ str_list_t ignore_recommends_list;
56
57 int restrict_to_default_dest;
58 pkg_dest_t *default_dest;
59diff --git a/libopkg/solvers/internal/pkg_depends_internal.c b/libopkg/solvers/internal/pkg_depends_internal.c
60index cd56d84..5deee70 100644
61--- a/libopkg/solvers/internal/pkg_depends_internal.c
62+++ b/libopkg/solvers/internal/pkg_depends_internal.c
63@@ -228,7 +228,8 @@ int pkg_hash_fetch_unsatisfied_dependencies(pkg_t *pkg,
64 || compound_depend->type == SUGGEST)
65 && (satisfying_pkg->state_want == SW_DEINSTALL
66 || satisfying_pkg->state_want == SW_PURGE
67- || opkg_config->no_install_recommends);
68+ || opkg_config->no_install_recommends
69+ || str_list_contains(&opkg_config->ignore_recommends_list, satisfying_pkg->name));
70 if (ignore) {
71 opkg_msg(NOTICE,
72 "%s: ignoring recommendation for "
73diff --git a/libopkg/solvers/libsolv/opkg_solver_libsolv.c b/libopkg/solvers/libsolv/opkg_solver_libsolv.c
74index bf0b72c..ea00a37 100644
75--- a/libopkg/solvers/libsolv/opkg_solver_libsolv.c
76+++ b/libopkg/solvers/libsolv/opkg_solver_libsolv.c
77@@ -484,6 +484,7 @@ static void pkg2solvable(pkg_t *pkg, Solvable *solvable_out)
78 static void populate_installed_repo(libsolv_solver_t *libsolv_solver)
79 {
80 int i;
81+ Id what;
82
83 pkg_vec_t *installed_pkgs = pkg_vec_alloc();
84
85@@ -507,6 +508,15 @@ static void populate_installed_repo(libsolv_solver_t *libsolv_solver)
86 /* set solvable attributes */
87 pkg2solvable(pkg, solvable);
88
89+ /* if the package is in ignore-recommends-list, disfavor installation */
90+ if (str_list_contains(&opkg_config->ignore_recommends_list, pkg->name)) {
91+ opkg_message(NOTICE, "Disfavor package: %s\n",
92+ pkg->name);
93+ what = pool_str2id(libsolv_solver->pool, pkg->name, 1);
94+ queue_push2(&libsolv_solver->solver_jobs, SOLVER_SOLVABLE_NAME
95+ | SOLVER_DISFAVOR, what);
96+ }
97+
98 /* if the package is not autoinstalled, mark it as user installed */
99 if (!pkg->auto_installed)
100 queue_push2(&libsolv_solver->solver_jobs, SOLVER_SOLVABLE
101@@ -533,7 +543,7 @@ static void populate_available_repos(libsolv_solver_t *libsolv_solver)
102 {
103 int i;
104 Solvable *solvable;
105- Id solvable_id;
106+ Id solvable_id, what;
107
108 pkg_vec_t *available_pkgs = pkg_vec_alloc();
109
110@@ -602,6 +612,15 @@ static void populate_available_repos(libsolv_solver_t *libsolv_solver)
111 solvable = pool_id2solvable(libsolv_solver->pool, solvable_id);
112 pkg2solvable(pkg, solvable);
113
114+ /* if the package is in ignore-recommends-list, disfavor installation */
115+ if (str_list_contains(&opkg_config->ignore_recommends_list, pkg->name)) {
116+ opkg_message(NOTICE, "Disfavor package: %s\n",
117+ pkg->name);
118+ what = pool_str2id(libsolv_solver->pool, pkg->name, 1);
119+ queue_push2(&libsolv_solver->solver_jobs, SOLVER_SOLVABLE_NAME
120+ | SOLVER_DISFAVOR, what);
121+ }
122+
123 /* if the --force-depends option is specified make dependencies weak */
124 if (opkg_config->force_depends)
125 queue_push2(&libsolv_solver->solver_jobs, SOLVER_SOLVABLE
126diff --git a/man/opkg.1.in b/man/opkg.1.in
127index 026fb15..c0d4bf3 100644
128--- a/man/opkg.1.in
129+++ b/man/opkg.1.in
130@@ -143,6 +143,9 @@ conjunction with \fB\--dest\fP
131 \fB\--add-arch <\fIarch\fP>:<\fIprio\fP>\fR
132 Register the package architecture \fIarch\fP with the numeric
133 priority \fIprio\fP. Lower priorities take precedence.
134+.TP
135+\fB\--add-ignore-recommends <\fIname\fP>\fR
136+Register package to be ignored as a recomendee
137 .SS FORCE OPTIONS
138 .TP
139 \fB\--force-depends \fR
140diff --git a/src/opkg.c b/src/opkg.c
141index f23467d..5181065 100644
142--- a/src/opkg.c
143+++ b/src/opkg.c
144@@ -51,6 +51,7 @@ enum {
145 ARGS_OPT_ADD_DEST,
146 ARGS_OPT_SIZE,
147 ARGS_OPT_ADD_EXCLUDE,
148+ ARGS_OPT_ADD_IGNORE_RECOMMENDS,
149 ARGS_OPT_NOACTION,
150 ARGS_OPT_DOWNLOAD_ONLY,
151 ARGS_OPT_NODEPS,
152@@ -110,6 +111,7 @@ static struct option long_options[] = {
153 {"add-dest", 1, 0, ARGS_OPT_ADD_DEST},
154 {"size", 0, 0, ARGS_OPT_SIZE},
155 {"add-exclude", 1, 0, ARGS_OPT_ADD_EXCLUDE},
156+ {"add-ignore-recommends", 1, 0, ARGS_OPT_ADD_IGNORE_RECOMMENDS},
157 {"test", 0, 0, ARGS_OPT_NOACTION},
158 {"tmp-dir", 1, 0, 't'},
159 {"tmp_dir", 1, 0, 't'},
160@@ -235,6 +237,9 @@ static int args_parse(int argc, char *argv[])
161 case ARGS_OPT_ADD_EXCLUDE:
162 str_list_append(&opkg_config->exclude_list, optarg);
163 break;
164+ case ARGS_OPT_ADD_IGNORE_RECOMMENDS:
165+ str_list_append(&opkg_config->ignore_recommends_list, optarg);
166+ break;
167 case ARGS_OPT_SIZE:
168 opkg_config->size = 1;
169 break;
170@@ -335,6 +340,7 @@ static void usage()
171 printf("\t--add-arch <arch>:<prio> Register architecture with given priority\n");
172 printf("\t--add-dest <name>:<path> Register destination with given path\n");
173 printf("\t--add-exclude <name> Register package to be excluded from install\n");
174+ printf("\t--add-ignore-recommends <name> Register package to be ignored as a recomendee\n");
175 printf("\t--prefer-arch-to-version Use the architecture priority package rather\n");
176 printf("\t than the higher version one if more\n");
177 printf("\t than one candidate is found.\n");
178diff --git a/tests/Makefile b/tests/Makefile
179index 148c844..ddf027f 100644
180--- a/tests/Makefile
181+++ b/tests/Makefile
182@@ -38,6 +38,7 @@ REGRESSION_TESTS := core/01_install.py \
183 core/37_globs.py \
184 core/38_install_constrained_version.py \
185 core/39_distupgrade.py \
186+ core/43_add_ignore_recommends.py \
187 regress/issue26.py \
188 regress/issue31.py \
189 regress/issue32.py \
190diff --git a/tests/core/43_add_ignore_recommends.py b/tests/core/43_add_ignore_recommends.py
191new file mode 100644
192index 0000000..7da0096
193--- /dev/null
194+++ b/tests/core/43_add_ignore_recommends.py
195@@ -0,0 +1,62 @@
196+#! /usr/bin/env python3
197+#
198+# Create package 'a' (1.0) which Recommends 'c'.
199+# Install 'a' with --add-ignore-recommends 'c'.
200+# Check that only 'a' (1.0) is installed.
201+# Create package 'b' which Depends on 'c'.
202+# Install 'a' & 'b', with --add-ignore-recommends 'c'.
203+# Verify that 'a','b' & 'c' are installed.
204+# Uninstall 'b' & 'c'.
205+# Create package 'a' (2.0), which Recommends 'c'.
206+# Upgrade 'a' with --add-ignore-recommends 'c'
207+# Verify that only 'a' (2.0) is installed
208+#
209+
210+import os
211+import opk, cfg, opkgcl
212+
213+opk.regress_init()
214+o = opk.OpkGroup()
215+
216+o.add(Package='a', Recommends='c', Version='1.0')
217+o.add(Package='b', Depends='c')
218+o.add(Package='c')
219+o.write_opk()
220+o.write_list()
221+
222+opkgcl.update()
223+
224+opkgcl.install('a', '--add-ignore-recommends c')
225+
226+if not opkgcl.is_installed('a'):
227+ opk.fail("Package 'a' installed but reports as not installed.")
228+
229+if opkgcl.is_installed('c'):
230+ opk.xfail("[libsolv<0.7.3] Package 'c' should not have been installed since it was in --add-ignore-recommends.")
231+
232+opkgcl.remove('a')
233+opkgcl.install('a b', '--add-ignore-recommends c')
234+
235+if not opkgcl.is_installed('a'):
236+ opk.fail("Package 'a' installed but reports as not installed.")
237+
238+if not opkgcl.is_installed('b'):
239+ opk.fail("Package 'b' installed but reports as not installed.")
240+
241+if not opkgcl.is_installed('c'):
242+ opk.fail("Package 'c' should have been installed since 'b' depends on it.")
243+
244+opkgcl.remove('b c', '--force-depends')
245+o.add(Package='a', Recommends='c', Version='2.0')
246+o.write_opk()
247+o.write_list()
248+
249+opkgcl.update()
250+
251+opkgcl.upgrade('a', '--add-ignore-recommends c')
252+
253+if not opkgcl.is_installed('a', '2.0'):
254+ opk.fail("Package 'a (2.0)' installed but reports as not installed.")
255+
256+if opkgcl.is_installed('c'):
257+ opk.fail("Package 'c' should not have been installed since it was in --add-ignore-recommends.")
258--
2592.17.1
260
diff --git a/meta/recipes-devtools/opkg/opkg_0.3.6.bb b/meta/recipes-devtools/opkg/opkg_0.3.6.bb
index 6ebd58b967..b26d30b571 100644
--- a/meta/recipes-devtools/opkg/opkg_0.3.6.bb
+++ b/meta/recipes-devtools/opkg/opkg_0.3.6.bb
@@ -15,6 +15,7 @@ SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz
15 file://opkg.conf \ 15 file://opkg.conf \
16 file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \ 16 file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \
17 file://0001-remove_maintainer_scripts-use-strict-matching.patch \ 17 file://0001-remove_maintainer_scripts-use-strict-matching.patch \
18 file://0001-libopkg-add-add-ignore-recommends-option.patch \
18" 19"
19 20
20SRC_URI[md5sum] = "79e04307f6f54db431c251772d7d987c" 21SRC_URI[md5sum] = "79e04307f6f54db431c251772d7d987c"