aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/opkg/opkg/0008-select_higher_version.patch
blob: a9b039c5a06d5e1a1848004dce03b91d10e42d7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Add the --prefer-arch-to-version option

If there were more than one candidate which had the same pkg name in the
candidate list, for example, the same pkg with different versions, then
it would use the last one which was the highest version one in the past,
but it will use the higher arch priority when this option is specified.

Upstream-Status: Pending

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 libopkg/opkg_conf.h |    1 +
 libopkg/pkg_hash.c  |   18 +++++++++++++++---
 src/opkg-cl.c       |    9 +++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
--- a/libopkg/opkg_conf.h
+++ b/libopkg/opkg_conf.h
@@ -77,6 +77,7 @@ struct opkg_conf
      int force_removal_of_essential_packages;
      int force_postinstall;
      int force_remove;
+     int prefer_arch_to_version;
      int check_signature;
      int nodeps; /* do not follow dependencies */
      char *offline_root;
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c
--- a/libopkg/pkg_hash.c
+++ b/libopkg/pkg_hash.c
@@ -376,10 +376,22 @@ pkg_hash_fetch_best_installation_candidate(abstract_pkg_t *apkg,
           if (constraint_fcn(matching, cdata)) {
              opkg_msg(DEBUG, "Candidate: %s %s.\n",
 			     matching->name, matching->version) ;
-             good_pkg_by_name = matching;
 	     /* It has been provided by hand, so it is what user want */
-             if (matching->provided_by_hand == 1)
-                break;
+             if (matching->provided_by_hand == 1) {
+                 good_pkg_by_name = matching;
+                 break;
+             }
+             /* Respect to the arch priorities when given alternatives */
+             if (good_pkg_by_name && conf->prefer_arch_to_version) {
+                 if (matching->arch_priority >= good_pkg_by_name->arch_priority) {
+                     good_pkg_by_name = matching;
+                     opkg_msg(DEBUG, "%s %s wins by priority.\n",
+                         matching->name, matching->version) ;
+                 } else
+                     opkg_msg(DEBUG, "%s %s wins by priority.\n",
+                         good_pkg_by_name->name, good_pkg_by_name->version) ;
+             } else
+                 good_pkg_by_name = matching;
           }
      }
 
diff --git a/src/opkg-cl.c b/src/opkg-cl.c
--- a/src/opkg-cl.c
+++ b/src/opkg-cl.c
@@ -42,6 +42,7 @@ enum {
 	ARGS_OPT_FORCE_SPACE,
 	ARGS_OPT_FORCE_POSTINSTALL,
 	ARGS_OPT_FORCE_REMOVE,
+	ARGS_OPT_PREFER_ARCH_TO_VERSION,
 	ARGS_OPT_ADD_ARCH,
 	ARGS_OPT_ADD_DEST,
 	ARGS_OPT_NOACTION,
@@ -83,6 +84,8 @@ static struct option long_options[] = {
 	{"force_postinstall", 0, 0, ARGS_OPT_FORCE_POSTINSTALL},
 	{"force-remove", 0, 0, ARGS_OPT_FORCE_REMOVE},
 	{"force_remove", 0, 0, ARGS_OPT_FORCE_REMOVE},
+	{"prefer-arch-to-version", 0, 0, ARGS_OPT_PREFER_ARCH_TO_VERSION},
+	{"prefer-arch-to-version", 0, 0, ARGS_OPT_PREFER_ARCH_TO_VERSION},
 	{"noaction", 0, 0, ARGS_OPT_NOACTION},
 	{"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
 	{"nodeps", 0, 0, ARGS_OPT_NODEPS},
@@ -173,6 +176,9 @@ args_parse(int argc, char *argv[])
 		case ARGS_OPT_FORCE_REMOVE:
 			conf->force_remove = 1;
 			break;
+		case ARGS_OPT_PREFER_ARCH_TO_VERSION:
+			conf->prefer_arch_to_version = 1;
+			break;
 		case ARGS_OPT_NODEPS:
 			conf->nodeps = 1;
 			break;
@@ -271,6 +277,9 @@ usage()
 	printf("\t--offline-root <dir>	offline installation of packages.\n");
 	printf("\t--add-arch <arch>:<prio>	Register architecture with given priority\n");
 	printf("\t--add-dest <name>:<path>	Register destination with given path\n");
+	printf("\t--prefer-arch-to-version\t 	Use the architecture priority package rather\n");
+	printf("\t				than the higher version one if more\n");
+	printf("\t				than one candidate is found.\n");
 
 	printf("\nForce Options:\n");
 	printf("\t--force-depends		Install/remove despite failed dependencies\n");
-- 
1.7.1