From patchwork Tue Oct 27 02:39:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1388242 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aparcar.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=q/8pylvl; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKwwR49Tcz9sSn for ; Tue, 27 Oct 2020 13:42:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Vv8FKjy0+FY02+aGLwYycDNKM7JeqfuceV79ruxhaIU=; b=q/8pylvlWYB0VFcOFMMx+dHcW9 Bh9txP0+ZcP0uMggZiliDuvCoVEIx7D7o0oacrmNTHdTA4OHtLtQw7gZ76Htw6TX0aXS6QKiDqt5e 4eLt0JDRvY8WdncrCe50R4ubO00cut/iraJS28JRMHoBLAIwBgDWoZ9eVgmsn1iIyeB1gOuot43Oh a/qauqwrBYsz0oqUNmDrbdB/s6NxkVB8/WA9OpFRc35EzANijZ5B+xFI4djZUjgLSrjVPdbsqgL+A KpsbHf7CZszMyCM9nE79U1pQqUMEX2rQdAnnucA1zopiIZnFu26ImpEPQwoKka4wF+uKgunRVt3Ab AeRTLphw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXEuB-0005Dw-Ct; Tue, 27 Oct 2020 02:40:11 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXEu8-0005D9-CG for openwrt-devel@lists.openwrt.org; Tue, 27 Oct 2020 02:40:09 +0000 X-Originating-IP: 72.234.141.215 Received: from dawn.lan (udp224251uds.hawaiiantel.net [72.234.141.215]) (Authenticated sender: mail@aparcar.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPA id 9998F24000B; Tue, 27 Oct 2020 02:40:01 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH opkg v2] pkg_hash: don't suggest incompatible packages Date: Mon, 26 Oct 2020 16:39:57 -1000 Message-Id: <20201027023957.1228316-1-mail@aparcar.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_224008_515779_9889B0AF X-CRM114-Status: GOOD ( 12.94 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.193 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Spooren Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Up until now opkg would suggest packages with unsatisfied dependencies as installable candidates. This is a frequent issue for the kmod feed in snapshot images. In these cases opkg suggest a newer kmod version than compatible with the installed kernel, because the same package is available both in the kmods archive and the target specific packages feed. This commit fixes the issue by dropping all package problematic candidates by checking if all their dependencies could be installed. Signed-off-by: Paul Spooren --- v2: - Only resolve dependencies if architecture is selected and package is not already added. That should save some precious CPU cycles. libopkg/pkg_hash.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 52c64ff..6715ebd 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -20,6 +20,7 @@ #include "hash_table.h" #include "pkg.h" #include "opkg_message.h" +#include "pkg_depends.h" #include "pkg_vec.h" #include "pkg_hash.h" #include "parse_util.h" @@ -376,10 +377,23 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg, if ((arch_priority > 0) && (!pkg_vec_contains(matching_pkgs, maybe))) { - max_count++; - abstract_pkg_vec_insert(matching_apkgs, - maybe->parent); - pkg_vec_insert(matching_pkgs, maybe); + char **unresolved = NULL; + pkg_vec_t *depends = pkg_vec_alloc(); + pkg_hash_fetch_unsatisfied_dependencies(maybe, depends, + &unresolved); + + if (!unresolved) { + max_count++; + abstract_pkg_vec_insert(matching_apkgs, + maybe->parent); + pkg_vec_insert(matching_pkgs, maybe); + } else { + char **tmp = unresolved; + while (tmp) + free(*(tmp++)); + free(unresolved); + } + pkg_vec_free(depends); } }