From patchwork Sat Oct 17 19:12:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1383767 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=tlzFNn5N; 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 4CDCQz6NV1z9sSf for ; Sun, 18 Oct 2020 06:15:38 +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=MxOw/oi09OJHxr5sj0QStxFNYdISuYJxHV3vMveUNts=; b=tlzFNn5N2Fnoc7ZIx2prsBpacS Z8DNElG+F1gzPaLMCq+xnkDW6VFC6gXaBq0OEWg9tJcl++uGLZMRPiXrTOReSSKaKa70dKBG16tFL 9CcEQdgpwj/sUqTFlzld5z2rExEBnldt5L4e97AaYEv+Vie1qnTwLlRmb31nxSzmbfYYidCOpXaGp aioI5RcfgoYDcMb1/2d/R3dyyyy8VZwKC/KCxDltC3WilS3tZDZHN8S66WNb5+HwBUhWIQQPBOVCe gUiknevaBDDb6Gd+2W20iHiPz75BRzFyejFw1KociZ/elxtxQ/wVFB9X8M9THYkJDgmfVPDJUYdMd c5dA8aBg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTrdh-000617-4T; Sat, 17 Oct 2020 19:13:13 +0000 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTrdc-00060l-Pv for openwrt-devel@lists.openwrt.org; Sat, 17 Oct 2020 19:13:10 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPA id 32A8C60006; Sat, 17 Oct 2020 19:12:59 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH opkg] pkg_hash: don't suggest incompatible packages Date: Sat, 17 Oct 2020 09:12:48 -1000 Message-Id: <20201017191248.1558259-1-mail@aparcar.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201017_151308_952223_3422992D X-CRM114-Status: GOOD ( 13.35 ) 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.195 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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: jo@mein.io, 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 --- libopkg/pkg_hash.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 52c64ff..0d9b55b 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" @@ -373,14 +374,27 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg, arch_priority, pkg_get_string(maybe, PKG_VERSION)); /* We make sure not to add the same package twice. Need to search for the reason why they show up twice sometimes. */ - if ((arch_priority > 0) - && - (!pkg_vec_contains(matching_pkgs, maybe))) { + char **unresolved = NULL; + pkg_vec_t *depends = pkg_vec_alloc(); + pkg_hash_fetch_unsatisfied_dependencies(maybe, depends, + &unresolved); + + if (!unresolved && + (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); } + + if (unresolved) { + char **tmp = unresolved; + while (tmp) + free(*(tmp++)); + free(unresolved); + } + pkg_vec_free(depends); } if (vec->len > 0 && matching_pkgs->len < 1)