From patchwork Wed Mar 9 22:56:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5328 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4KDSJS0zFfz3xqY for ; Wed, 9 Mar 2022 22:57:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4KDSJN36ydz5SQ; Wed, 9 Mar 2022 22:57:24 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4KDSJN29tRz2yt6; Wed, 9 Mar 2022 22:57:24 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4KDSJM2DKcz30Gh for ; Wed, 9 Mar 2022 22:57:23 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4KDSJM1LfCz1DM for ; Wed, 9 Mar 2022 22:57:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C7B9A400A8 for ; Wed, 9 Mar 2022 23:57:22 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P8tIRJmPQxnO for ; Wed, 9 Mar 2022 23:57:21 +0100 (CET) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 571BE1B97A; Wed, 9 Mar 2022 23:57:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1646866641; bh=lpxAIusEYLCDZnMuZVeM4hleB3XLxWxMgGEMxIZWYjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AYNQ1jo2ibLRd09Bg0SCwLhDpFoTrOeXdV3RqQGChglyu8Nyk4v/oaDo0tEuG0c3h k2T14yADTYf22c5bDWWJQ/pDMnKmFIhsQvyCtQ95D2Jfh44eJjfK/C6jaIhOSK+ijZ E/gLN5yAIhEwiqEmyUUGG7IUbSC0Xw8s2Yd8Qq/Sc0U2bFe1W6LTEeRPLLFFxP1ohO HBne99HbWddWzy17ArB6sh16waoSyp08tT4vgzdL3a5N1tzjXu7oBW9a8t+Uygu/dW jnO+E1Vtz/yZhiVL8kGqmZyyfu3No9RiZGR47BS5JacXlqKGM8zGIRB/DIrSF4svtF gauPkPfnLL1Tw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH 2/9] pakfire: Replace duplicate code with dblist functioncall Date: Wed, 9 Mar 2022 23:56:48 +0100 Message-Id: <20220309225655.4472-3-robin.roevens@disroot.org> In-Reply-To: <20220309225655.4472-1-robin.roevens@disroot.org> References: <20220309225655.4472-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 571BE1B97A.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1647471431.47498@FPX115XkRapieg1WMrKVlA ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1646866643; a=rsa-sha256; cv=none; b=Qpc58otQP0TwGmtLWIQTJ7oAhGGsy5m5aazNEBLcRuy7Lvm9+1xl8jd8pdYZRluKLsVxaf xFHcKTmXvbKmW+7Y13o596DMVjlguXIglkY9VH3rCSA/JxfBFQnssMvgIE9guEAHEpc4xk vVfvoO7iiufNX7oil8R7KfKbtvO6u7QQxGI0mroat2PUVSxG7sZYVQ2AiUVR2ICaorFoS3 TEOJCmO7iYB3blZ+DU53uUrebeA3oIxFoXwvUlcJs/DYj33VbDTOdvtsnoGJp7KiXgz5lq wDNgW7Vftr6NrOLibblNKMMIEuM+Xu9CbptxuJn7ZNzo01UHJqlk2VJb9AJs9g== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=AYNQ1jo2; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1646866643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BXpqGdcMNfkG0dY939qYQ08bKMGToZbcP1Dmrhx8o+s=; b=w72epJjgWFkma5xx0h4EKiusdql1NTdCPpb5Ppd8qcP+fgHNBfHzPl39uL6vx7v5GU0mN7 J469ozsshJ87H6qJDX/+lwal1Al26FghMjlU00S4efTH1VIR/hRRzBDyB+6zXP9gnbdPWx yTvpAvGqPDpz6SvjayWzEiJTObLSzJuRiKHDC8vew5CieTk8yPlzmtTDJje3JLxfiKMKJu cuMXvN7DCYd8VbAj95k6FNmb6Eqb73GaicYntmyMUJZV0xxakLOIXpiMcVO5VBQ2K4KVaN V/DaTGlJQwCLIyDtgb+/OVRVCLWa/0SZ4bfqlgBLcjia3PhRW9RdzkQHkaXyqw== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=AYNQ1jo2; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-4.82 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.15)[asn: 50673(-0.33), country: NL(-0.01), ip: 178.21.23.139(-0.82)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-0.98)[-0.982]; SPF_REPUTATION_HAM(-0.68)[-0.6773174338785]; MV_CASE(0.50)[]; R_MISSING_CHARSET(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_SPF_ALLOW(-0.20)[+a:c]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[disroot.org:+]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4KDSJM1LfCz1DM X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Replace pakfire install code duplicating dblist working with call to actual dblist function. Signed-off-by: Robin Roevens --- src/pakfire/pakfire | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index b4930e85d..f23110cf5 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -107,42 +107,30 @@ ### Make sure that the list is not outdated. &Pakfire::dbgetlist("noforce"); - open(FILE, "<$Conf::dbdir/lists/packages_list.db"); - my @db = ; - close(FILE); + my %paklist = &Pakfire::dblist("all"); my $dep; my @deps; my $pak; my @paks; my @temp; - my @templine; - my $found = 0; my $return; my @all; foreach $pak (@ARGV) { unless ("$pak" =~ "^-") { - $return = &Pakfire::isinstalled($pak); - if ($return eq 0) { - &Pakfire::message("PAKFIRE INFO: $pak is already installed"); - next; - } - $found = 0; - foreach (@db) { - @templine = split(/;/,$_); - if ("$templine[0]" eq "$pak" ) { - push(@paks,$pak); - push(@all,$pak); - @temp = &Pakfire::resolvedeps("$pak"); - foreach $dep (@temp) { - push(@deps,$dep) if $dep; - push(@all,$dep) if $dep; - } - $found = 1; - break; + if (defined $paklist{$pak}) { + if ("$paklist{$pak}{'Installed'}" eq "yes") { + &Pakfire::message("PAKFIRE INFO: $pak is already installed"); + next; } - } - if ($found == 0) { + push(@paks,$pak); + push(@all,$pak); + @temp = &Pakfire::resolvedeps("$pak"); + foreach $dep (@temp) { + push(@deps,$dep) if $dep; + push(@all,$dep) if $dep; + } + } else { &Pakfire::message(""); &Pakfire::message("PAKFIRE WARN: The pak \"$pak\" is not known. Please try running \"pakfire update\"."); }