Jo-Philipp Wich <j...@mein.io> writes:

> Hi,
>
>> Does it impact OpenWrt ? or just some OpenWrt based distributions ?
>> (might influence who need to fix this ;) )
>
> it impacts the usage of the kmod compatibility repositories - apparently
> they're completely ignored by opkg.
>
> This problem was reported in the forum by a user who was unable to
> install openvpn-openssl on a 19.07 snapshot, due to the dependency on
> kmod-tun.
>
> I was able to confirm the problem locally here as well.
> While this might not strictly affect tagged builds, I still wouldn't
> like to ship 19.07 with a known broken version of opkg.

I am not sure I understand the problem correctly...

But if it is the fact that opkg doesn't try to resolve dependencies when
selecting the "best" version of a package, then maybe the attached big
hammer approach will solve it?  At least it works for me...

Without patch:

root@wrt1900ac-1:~# opkg install -V2 --noaction kmod-usb-net
opkg_conf_parse_file: Loading conf file /etc/opkg.conf.
opkg_conf_parse_file: Loading conf file /etc/opkg/customfeeds.conf.
opkg_conf_parse_file: Loading conf file /etc/opkg/distfeeds.conf.
pkg_hash_load_feeds: 
pkg_hash_load_feeds: 
pkg_hash_load_status_files: 
pkg_info_preinstall_check: Updating file owner list.
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for 
apkg=kmod-usb-net:
pkg_hash_fetch_best_installation_candidate: kmod-usb-net 4.19.62 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-net 4.19.78 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-net 4.19.79 
arm_cortex-a9_vfpv3
Installing kmod-usb-net (4.19.79-1) to root...
Downloading 
http://owrt.mork.no/lede/r11240+1-9d5e266cb1f1/targets/mvebu/cortexa9/packages/kmod-usb-net_4.19.79-1_arm_cortex-a9_vfpv3.ipk
pkg_hash_fetch_best_installation_candidate: Using latest version of installed 
package kernel.
pkg_hash_fetch_best_installation_candidate: Using latest version of installed 
package kernel.
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for apkg=kmod-mii:
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.62 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.78 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.79 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: No matching pkg out of 3 
matching_apkgs.
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for apkg=kmod-mii:
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.62 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.78 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.79 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: Using latest version of installed 
package kernel.
pkg_hash_fetch_best_installation_candidate: Using latest version of installed 
package kernel.
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for 
apkg=kmod-usb-core:
pkg_hash_fetch_best_installation_candidate: kmod-usb-core 4.19.62 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-core 4.19.78 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-core 4.19.79 
arm_cortex-a9_vfpv3
satisfy_dependencies_for: This could mean that your package list is out of date 
or that the packages
mentioned above do not yet exist (try 'opkg update'). To proceed in spite
of this problem try again with the '-force-depends' option.
opkg_configure_packages: Configuring unpacked packages.
opkg_configure_packages: Reordering packages before configuring them...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for 
kmod-usb-net:
 *      kernel (= 4.19.79-1-cddfa99a50fa71aee7f2b3bb433cac45)
 * opkg_install_cmd: Cannot install package kmod-usb-net.


With patch:

root@wrt1900ac-1:~# opkg install -V2 --noaction kmod-usb-net
opkg_conf_parse_file: Loading conf file /etc/opkg.conf.
opkg_conf_parse_file: Loading conf file /etc/opkg/customfeeds.conf.
opkg_conf_parse_file: Loading conf file /etc/opkg/distfeeds.conf.
pkg_hash_load_feeds: 
pkg_hash_load_feeds: 
pkg_hash_load_status_files: 
pkg_info_preinstall_check: Updating file owner list.
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for 
apkg=kmod-usb-net:
pkg_hash_fetch_best_installation_candidate: kmod-usb-net 4.19.62 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-net 4.19.79 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-net 4.19.78 
arm_cortex-a9_vfpv3
Installing kmod-usb-net (4.19.78-1) to root...
Downloading 
http://owrt.mork.no/lede/r11173-8184429b7b15/targets/mvebu/cortexa9/packages/kmod-usb-net_4.19.78-1_arm_cortex-a9_vfpv3.ipk
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for apkg=kmod-mii:
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.62 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.79 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.78 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: No matching pkg out of 3 
matching_apkgs.
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for apkg=kmod-mii:
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.62 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.79 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-mii 4.19.78 arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: 3 matching pkgs for 
apkg=kmod-usb-core:
pkg_hash_fetch_best_installation_candidate: kmod-usb-core 4.19.62 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-core 4.19.79 
arm_cortex-a9_vfpv3
pkg_hash_fetch_best_installation_candidate: kmod-usb-core 4.19.78 
arm_cortex-a9_vfpv3
Installing kmod-mii (4.19.78-1) to root...
Downloading 
http://owrt.mork.no/lede/r11173-8184429b7b15/targets/mvebu/cortexa9/packages/kmod-mii_4.19.78-1_arm_cortex-a9_vfpv3.ipk
opkg_configure_packages: Configuring unpacked packages.
opkg_configure_packages: Reordering packages before configuring them...




Bjørn

>From 45921c3914a48c2e57787e3ba64add8701217336 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bj...@mork.no>
Date: Thu, 17 Oct 2019 13:44:38 +0200
Subject: [PATCH] libopkg: prefer installable packages
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Give packages with unresolvable dependencies a lower priority
when selecting the best candidate.  This makes it possible
to have multiple kmod package repos with higher versions
than the installed kernel, and still be able to install
the matching versions.

Signed-off-by: Bjørn Mork <bj...@mork.no>
---
 libopkg/pkg.c | 24 ++++++++++++++++++++++++
 libopkg/pkg.h |  1 +
 2 files changed, 25 insertions(+)

diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index e5bfe6f61b67..e9261e45019e 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -1084,10 +1084,31 @@ int pkg_version_satisfied(pkg_t * it, pkg_t * ref, const char *op)
 	return 0;
 }
 
+int pkg_is_installable(const pkg_t *pkg)
+{
+	compound_depend_t *dep = pkg_get_depends((pkg_t *)pkg, DEPEND);
+
+	for (; dep && dep->type; dep++) {
+		int i, ok = 0;
+		if (dep->type != DEPEND)
+			continue;
+		for (i = 0; i < dep->possibility_count; i++) {
+			if (pkg_dependence_satisfiable(dep->possibilities[i])) {
+				ok = 1;
+				break;
+			}
+		}
+		if (!ok)
+			return 0;
+	}
+	return 1;
+}
+
 int pkg_name_version_and_architecture_compare(const void *p1, const void *p2)
 {
 	const pkg_t * a = *(const pkg_t **)p1;
 	const pkg_t * b = *(const pkg_t **)p2;
+	int installcmp;
 	int namecmp;
 	int vercmp;
 	int arch_prio1, arch_prio2;
@@ -1097,6 +1118,9 @@ int pkg_name_version_and_architecture_compare(const void *p1, const void *p2)
 		return 0;
 	}
 
+	installcmp = pkg_is_installable(a) - pkg_is_installable(b);
+	if (installcmp)
+		return installcmp;
 	namecmp = strcmp(a->name, b->name);
 	if (namecmp)
 		return namecmp;
diff --git a/libopkg/pkg.h b/libopkg/pkg.h
index 600fc9eaa25c..3ab48cae3813 100644
--- a/libopkg/pkg.h
+++ b/libopkg/pkg.h
@@ -248,6 +248,7 @@ int pkg_merge(pkg_t * oldpkg, pkg_t * newpkg);
 char *pkg_version_str_alloc(pkg_t * pkg);
 
 int pkg_compare_versions(const pkg_t *pkg, const pkg_t *ref_pkg);
+int pkg_is_installable(const pkg_t * pkg);
 int pkg_name_version_and_architecture_compare(const void *a, const void *b);
 int abstract_pkg_name_compare(const void *a, const void *b);
 
-- 
2.20.1

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to