From patchwork Thu Jul 28 11:21:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5773 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 4LtpCf2dkYz3wvM for ; Thu, 28 Jul 2022 11:22:38 +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 4LtpCX48Slz5RS; Thu, 28 Jul 2022 11:22:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCX0Dg5z303b; Thu, 28 Jul 2022 11:22:32 +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 4LtpCV3br1z303j for ; Thu, 28 Jul 2022 11:22:30 +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 4LtpCT1vtTz443 for ; Thu, 28 Jul 2022 11:22:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id F199340DC8 for ; Thu, 28 Jul 2022 13:22:28 +0200 (CEST) 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 o9UNkc_kVQuj for ; Thu, 28 Jul 2022 13:22:27 +0200 (CEST) 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 3FC62560B0; Thu, 28 Jul 2022 13:21:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1659007340; bh=88Hxq6EW17PkHmogU+a+EDnQY5D2NCoE/01nPAtnv24=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gMdxSxGXMIif9w+6UYCIkhfGT46+KCkOaxXAbMhGHqlh/podwDD17NF1ccyzXSnGg f84cLwwEPzmnv2MPIgICtJf+msf65JUA5Eiq832xJzODkrAQkJ8neMhqaUnIHMIgte jLexGyKv1JBA48RSXJDyRTMPUMbTDnvtiJCu1EfVXo7hST7Zgj7hY9ViApn+nTQGi5 UVpRc5Yr6zKH5b1CGhQk9uUDlQ25LgaaKiFi3+IO5jtmQZQk74hPmi5F3ld0RPtj2v zYwH653pfohNqee9gLshYKj8o5d+jNVQO6zQjsQLlNMeuY2S8rgYyUJsEyo2f0XJiz KAJKdwLl9v76A== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 06/10] pakfire: Add list upgrade functionality Date: Thu, 28 Jul 2022 13:21:32 +0200 Message-Id: <20220728112136.30218-7-robin.roevens@disroot.org> In-Reply-To: <20220728112136.30218-1-robin.roevens@disroot.org> References: <20220728112136.30218-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 3FC62560B0.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.79535@lZvVYw/AN1inbFfQrzzXlw ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007349; 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=W5gZgI2Kl6iq77quMbNkzNqjzECP6tFyOwXl4Lu7opk=; b=Pl+RBmKLsVnwr5M77+tF1augYVqrzxWOz+5tQE24HPpjg58iPdjHaX+NLZ9Fu0nz5TCA8V dK+kXbsvF0M6y7jBms+yp76nG3FYX9D+HSBo2l1zzfrjOX07aryJOmuGwmaGILb0kxxpqi WT8b+/+cmeWW9vOO2B9WUTQcL0Iz8QTXzE4m1f2qQgKvflVl4cYivylC5tOHThNKpJgj4n CmwasRkRFm0GegWshH7gGo3/NJ1vLbPGOjwinETgnFncChB89WSY6mHHCkBZY1H3mf9PvN GEdUAC/9wNGtqU9s0PihBkMwoLC+tUv6vh2C61U3g8swb7k51kcF4A5NpqkZcQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=gMdxSxGX; 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-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1659007349; a=rsa-sha256; cv=none; b=RQ9m8sqy2OW2LsmODc7e+oX/8B6f6KpzuAt5aOQfIjGj2/XCqLMWgbWDXPg2rdU5ilgyYu nCEJkuyKoCp1cfs8mgL+6U39ZALsULg1fOZvALpMTnQVqK30oWZ7godJMLFozt5YOQ504k qhZjLHIkNr9WXQNmpjm1J1Aodl8zXS25wPj2IDaon2m2rF+iXHI8GF7KsWvviGSDeDjX++ UrvUODolmQ22RjwCbSZX6HHIWnzX8TnlFvDISmMIvPbCRVhZxjvA7BGJmIi+JD2vHyTf5L WP7kXMns+F66eoBIADTejJENUkuNaWjHIx+5b5yUr6XcYmux8hpjAURhUL5A8w== X-Rspamd-Queue-Id: 4LtpCT1vtTz443 Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=gMdxSxGX; 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 [-7.84 / 11.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; SPF_REPUTATION_HAM(-0.82)[-0.81818744239513]; R_MISSING_CHARSET(0.50)[]; MV_CASE(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)[]; IP_REPUTATION_HAM(-0.01)[asn: 50673(0.00), country: NL(-0.01), ip: 178.21.23.139(0.00)]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; RCVD_COUNT_THREE(0.00)[4]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] 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" - Added possibility to list available upgrades from commandline using 'pakfire list upgrade'. - Added exitcode to 'pakfire list' - Moved 'Pakfire has finished' log message inside END block to always log when pakfire exited. - Fix: allow [options] between 'list' and [installed/notinstalled/ upgrade] parameters (Partly fixes Bug #12868) Signed-off-by: Robin Roevens --- src/pakfire/lib/functions.pl | 2 +- src/pakfire/pakfire | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 4f0515f62..d8b5c5a26 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -114,7 +114,7 @@ sub usage { &Pakfire::message("Usage: pakfire [options] "); &Pakfire::message(" - Contacts the servers for new lists of paks."); &Pakfire::message(" - Installs the latest version of all paks."); - &Pakfire::message(" - Outputs a short list with all available paks."); + &Pakfire::message(" [installed/notinstalled/upgrade] - Outputs a list with all, installed, available or upgradeable paks."); &Pakfire::message(" - Outputs a summary about available core upgrades, updates and a required reboot"); &Pakfire::message(""); &Pakfire::message(" Global options:"); diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 351d71216..766d91b81 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -329,14 +329,18 @@ } elsif ("$ARGV[0]" eq "list") { my $count; + my $coreupdate = 0; my $use_color = ""; my $reset_color = ""; my $filter = "all"; - if ("$ARGV[1]" =~ /installed|notinstalled/) { + shift if ("$ARGV[1]" =~ "^-"); + + if ("$ARGV[1]" =~ /installed|notinstalled|upgrade/) { $filter = "$ARGV[1]"; - } else { - &Pakfire::message("PAKFIRE WARN: Not a known option $ARGV[1]") if ($ARGV[1]); + } elsif ($ARGV[1]) { + &Pakfire::message("PAKFIRE ERROR: Not a known option $ARGV[1]"); + exit 1; } my $pak; @@ -347,6 +351,17 @@ $use_color = "$Pakfire::color{'lightgreen'}"; } + # Check for available core upgrade first if list of upgrades is requested + if ("$filter" eq "upgrade") { + my %coredb = &Pakfire::coredbinfo(); + + if (defined $coredb{'AvailableRelease'}) { + print "${use_color}Core-Update $coredb{'CoreVersion'}\n"; + print "Release: $coredb{'Release'} -> $coredb{'AvailableRelease'}${reset_color}\n\n"; + $coreupdate = 1; + } + } + foreach $pak (sort keys %paklist) { if ("$Pakfire::enable_colors" eq "1") { if ("$paklist{$pak}{'Installed'}" eq "yes") { @@ -373,7 +388,10 @@ if ($count > 0) { print "$count packages total.\n"; } else { - &Pakfire::message("PAKFIRE WARN: No packages where found using filter $filter."); + if (! $coreupdate) { + &Pakfire::message("PAKFIRE WARN: No packages where found using filter $filter."); + exit 1; + } } } elsif ("$ARGV[0]" eq "resolvedeps") { foreach (@ARGV) { @@ -399,9 +417,9 @@ &Pakfire::usage; } - &Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing."); - END { + &Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing."); + # Check if pakfire has been locked in this session. if ($locked) { # Remove lockfile.