From patchwork Thu Jul 28 11:21:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5770 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 4LtpCb0Cj7z40W1 for ; Thu, 28 Jul 2022 11:22:35 +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 4LtpCT6JbPz5Rq; Thu, 28 Jul 2022 11:22:29 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCT5mq5z2ygN; Thu, 28 Jul 2022 11:22:29 +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 4LtpCS45dPz2yXK for ; Thu, 28 Jul 2022 11:22:28 +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 4LtpCR6rcvzq1 for ; Thu, 28 Jul 2022 11:22:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B777E40DA4 for ; Thu, 28 Jul 2022 13:22:27 +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 5DO9bzE7dNC3 for ; Thu, 28 Jul 2022 13:22:25 +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 0FB42560A1; 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=9rUFxUf1AAbfWBE9WTEh0WhONwkT0PPu5TIEnCmoRvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=djLLjCu61e7FzIJo4q/q238rD2Lrfw43UAeL6+Q0C1NtDEd5UBgPDoUS7i37oRwWv LWBtzM1squ5DrW74VwbFK2kzRKFJPawwnvjXe1W+EX7ZeKg+b2SAuv+4nnHlSMUI1R 6j+w4RYDyrGfN/COvIVWU0xDGcqgfJhgY9SvVJ1z7zVDIe47XYKN1MARhnK9CKGLpO FUR+8FA7kZCAqh4inSzIGxU0Vai7rmT0CwmOfOlpRA1NxDkZS3735Uw0pSawH+kJ3T WJwxX8zBO+fxC0IbycETV6rzPBLMGxvLLzu2LMECt+9oY0XWaiECVbSpjL76EdDJl9 rn/pGjsrM/0Dw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 01/10] pakfire: Refactor dblist seperating UI and logic Date: Thu, 28 Jul 2022 13:21:27 +0200 Message-Id: <20220728112136.30218-2-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: 0FB42560A1.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.66932@NxTd32rRoGVMk8fQIc1tFQ ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QAObgjtVux6N5SJUDnyjUgv810leqBSfri9alsM3Y0E=; b=Qgt/L6fwHKVLvBlDf706JXu/31spIp9zluZLz+JygfOoyBcTbHD3qTVWxed6fE7DXruvcO DzNRqlJV9iT+gEHv2xPMq8fbtBCclnKK49PfsgNTOEBRzw6OvcyA05JEOCxSHHtqPc7R7/ wRVQ5vMFv2HptELk8FZ2SUYCculbxEqDuj2aDbTO6N2/pBfV74CB4ziqHkucPp9yPqFgRF LtelCSI/8cCfEoxf5dqpAsGWw9sETyce4uR9tphDJqpBKSRsSXhiBFmZDpzpgcylv60SME P4xl7xIjo8AKu0rSZN/s+SW9gtz1nN9nT1G4OgzZDv60L5EMQyDMGELZFmNrrQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=djLLjCu6; 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=1659007348; a=rsa-sha256; cv=none; b=EG2lGQfOI3EgRlGt2IpulI8pF84qEiFgoGv7WGPJdOIOfjYTMD0KSdm+JOCgkrw+uwu5mb LrhF8S8/Z+uG5hh05YzeW/iSnJ5snZsfsKWAaeyvh3CII6hdhLioNUkvrNb+9NytaWexHR D8EzFcH2FxlyiE+njxCHzvIB74XtIO7Bps5S0MSOAZ1oFmsJqo82raTjndasU5TnFXjUHr 4FSlTwYtjYVIAWlsc4ybpk3y0W4dq2aMP9jKKYnAXlCySZTYsGv78IEUOVv96nVwS2tUP3 1ZlP7coygCJoBEd0E5zRPgwfEqK/Udy5qBNO+YQW82E6NHvKBs1Awn9rvcFyXg== X-Rspamd-Queue-Id: 4LtpCR6rcvzq1 Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=djLLjCu6; 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.34 / 11.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81818744443554]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; MV_CASE(0.50)[]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; R_SPF_ALLOW(-0.20)[+a:c]; 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)]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[disroot.org:+]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; RCVD_COUNT_THREE(0.00)[4]; ARC_NA(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" - Removed UI code from dblist function and refactor it making it return a hash representing the pak db for easier handling of this data. - Moved core update check in dblist to new seperate dbcoreinfo function making it return a hash with current and possibly available core version info. - Update existing calls to dblist - Bring UI parts previously in dblist to pakfire program itself, pakfire.cgi and index.cgi with a few small enhancements: - Translations for 'Core-Update', 'Release', 'Update' and 'Version' - Add currently installed version numbers to installed paks list in pakfire.cgi - Add 'Installed: yes/no' to pakfire list output so people not using colors have this information too. (Partly fixes Bug #12868) - Add update available details to pakfire list output if package has updates available. Signed-off-by: Robin Roevens --- html/cgi-bin/index.cgi | 6 +- html/cgi-bin/pakfire.cgi | 23 ++++- langs/de/cgi-bin/de.pl | 4 + langs/en/cgi-bin/en.pl | 4 + langs/fr/cgi-bin/fr.pl | 4 + langs/nl/cgi-bin/nl.pl | 4 + src/pakfire/lib/functions.pl | 165 ++++++++++++++++++----------------- src/pakfire/pakfire | 99 ++++++++++++++++----- 8 files changed, 202 insertions(+), 107 deletions(-) diff --git a/html/cgi-bin/index.cgi b/html/cgi-bin/index.cgi index 18c26942e..6fecae1ff 100644 --- a/html/cgi-bin/index.cgi +++ b/html/cgi-bin/index.cgi @@ -604,7 +604,11 @@ if ($warnmessage) { &Header::closebox(); } -&Pakfire::dblist("upgrade", "notice"); +my %coredb = &Pakfire::coredbinfo(); +if (defined $coredb{'AvailableRelease'}) { + print "


$Lang::tr{'core notice 1'} $coredb{'Release'} $Lang::tr{'core notice 2'} $coredb{'AvailableRelease'} $Lang::tr{'core notice 3'}"; +} + if ( -e "/var/run/need_reboot" ) { print "
"; print "

$Lang::tr{'needreboot'}!"; diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index 3e8dc5460..cb1272c63 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -403,7 +403,16 @@ print < END - &Pakfire::dblist("upgrade", "forweb"); + my %coredb = &Pakfire::coredbinfo(); + if (defined $coredb{'AvailableRelease'}) { + print "\n"; + } + + my %upgradelist = &Pakfire::dblist("upgrade"); + foreach my $pak (sort keys %upgradelist) { + print "\n"; + } + print < @@ -419,7 +428,11 @@ END @@ -431,7 +444,11 @@ END diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 49c582a1e..179980716 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -653,6 +653,7 @@ 'core notice 1' => 'Hinweis: Es steht eine Aktualisierung von Core-Update', 'core notice 2' => 'auf', 'core notice 3' => 'zur Verfügung.', +'core update' => 'Core-Update', 'could not be opened' => 'konnte nicht geöffnet werden', 'could not connect to' => 'Konnte keine Verbindung herstellen mit', 'could not connect to www ipcop org' => 'Keine Verbindung zu www.ipcop.org möglich', @@ -2012,6 +2013,7 @@ 'ovpnsys log' => 'OVPN-System-Protokoll', 'package failed to install' => 'Programmpaket konnte nicht installiert werden.', 'pagerefresh' => 'Seite wird aktualisiert. Bitte warten.', +'pak update' => 'Paketupdate', 'pakfire accept all' => 'Möchten Sie der Installation aller Pakete zustimmen?', 'pakfire ago' => 'her.', 'pakfire already busy' => 'Pakfire führt bereits eine Aufgabe aus. Bitte versuchen Sie es später erneut.', @@ -2157,6 +2159,7 @@ 'refresh index page while connected' => 'Aktualisiere index.cgi Seite während der Verbindung', 'refresh update list' => 'Aktualisiere Update-Liste', 'registered user rules' => 'Talos VRT-Regelsatz für registrierte Benutzer', +'release' => 'Release', 'released' => 'Freigegeben', 'reload' => 'neu laden', 'remark' => 'Anmerkung', @@ -2868,6 +2871,7 @@ 'valid till' => 'Gültig bis', 'vci number' => 'VCI-Nummer:', 'vendor' => 'Hersteller', +'version' => 'Version', 'view log' => 'Protokoll anzeigen', 'virtual address' => 'Virtuelle Addresse', 'virtual private networking' => 'Virtuelles Privates Netzwerk', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index ae233de8e..b51823177 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -684,6 +684,7 @@ 'core notice 1' => 'Notice: There is a core-update from', 'core notice 2' => 'to', 'core notice 3' => 'available.', +'core update' => 'Core-Update', 'could not be opened' => 'could not be opened.', 'could not connect to' => 'Could not connect to', 'could not connect to www ipcop org' => 'Could not connect to www.ipfire.org', @@ -2065,6 +2066,7 @@ 'ovpnsys log' => 'OVPN-System-Log', 'package failed to install' => 'Package failed to install.', 'pagerefresh' => 'Page is beeing refreshed, please wait.', +'pak update' => 'Update', 'pakfire accept all' => 'Do you want to install all packages?', 'pakfire ago' => 'ago.', 'pakfire already busy' => 'Pakfire is already performing a task. Please try again later.', @@ -2211,6 +2213,7 @@ 'refresh index page while connected' => 'Refresh index.cgi page while connected', 'refresh update list' => 'Refresh update list', 'registered user rules' => 'Talos VRT rules for registered users', +'release' => 'Release', 'released' => 'Released', 'reload' => 'reload', 'remark' => 'Remark', @@ -2935,6 +2938,7 @@ 'valid till' => 'Valid till', 'vci number' => 'VCI number:', 'vendor' => 'Vendor', +'version' => 'Version', 'view log' => 'view log', 'virtual address' => 'Virtual Address', 'virtual private networking' => 'Virtual Private Networking', diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl index 245ec62b6..560b4aa54 100644 --- a/langs/fr/cgi-bin/fr.pl +++ b/langs/fr/cgi-bin/fr.pl @@ -690,6 +690,7 @@ 'core notice 1' => 'Remarque : Une mise à jour est disponible depuis la version', 'core notice 2' => 'vers', 'core notice 3' => '', +'core update' => 'Mise à jour du coeur', 'could not be opened' => 'ne peut pas être ouvert', 'could not connect to' => 'Impossible de se connecter à', 'could not connect to www ipcop org' => 'Impossible de se connecter à www.ipcop.org', @@ -2074,6 +2075,7 @@ 'ovpnsys log' => 'Journal système OVPN', 'package failed to install' => 'L\'installation du paquet a échoué.', 'pagerefresh' => 'La page est en cours d\'actualisation, veuillez patienter.', +'pak update' => 'Mise à jour', 'pakfire accept all' => 'Voulez-vous installer ce(s) paquet(s) ?', 'pakfire ago' => '', 'pakfire already busy' => 'Pakfire est déjà en train d\'effectuer une tâche. Veuillez réessayer plus tard.', @@ -2221,6 +2223,7 @@ 'refresh index page while connected' => 'Actualiser la page index.cgi pendant la connexion', 'refresh update list' => 'Actualiser la liste des mises à jour', 'registered user rules' => 'Règles Sourcefire VRT pour les utilisateurs enregistrés', +'release' => 'Révision', 'released' => 'Disponible', 'reload' => 'Recharger', 'remark' => 'Remarque ', @@ -2946,6 +2949,7 @@ 'valid till' => 'Valide jusqu\'au', 'vci number' => 'Nombre VCI :', 'vendor' => 'Vendeur', +'version' => 'Version', 'view log' => 'Afficher log', 'virtual address' => 'Adresse virtuelle', 'virtual private networking' => 'Réseau privé virtuel (VPN)', diff --git a/langs/nl/cgi-bin/nl.pl b/langs/nl/cgi-bin/nl.pl index 5979873bb..e50a95578 100644 --- a/langs/nl/cgi-bin/nl.pl +++ b/langs/nl/cgi-bin/nl.pl @@ -577,6 +577,7 @@ 'core notice 1' => 'Let op: Er is een core-update van', 'core notice 2' => 'naar', 'core notice 3' => 'beschikbaar.', +'core update' => 'Core-Update', 'could not be opened' => 'kan niet worden geopend.', 'could not connect to' => 'Kan niet verbinden', 'could not connect to www ipcop org' => 'Kan niet verbinden met www.ipfire.org', @@ -1690,6 +1691,7 @@ 'ovpnsys log' => 'OVPN-Systeem-Log', 'package failed to install' => 'Pakket kon niet worden geïnstalleerd.', 'pagerefresh' => 'Pagina wordt ververst, wacht even a.u.b.', +'pak update' => 'Opwaardering', 'pakfire accept all' => 'Wilt u alle pakketten installeren?', 'pakfire ago' => 'geleden.', 'pakfire available addons' => 'Beschikbare extensies:', @@ -1817,6 +1819,7 @@ 'refresh index page while connected' => 'Ververs de index.cgi pagina terwijl verbonden', 'refresh update list' => 'Ververs update-lijst', 'registered user rules' => 'Talos VRT regels voor geregistreerde gebruikers', +'release' => 'Uitgave', 'released' => 'Released', 'reload' => 'herlaad', 'remark' => 'Opmerking', @@ -2484,6 +2487,7 @@ 'valid root certificate already exists' => 'Er bestaat al een geldig root certificaat.', 'valid till' => 'Geldig tot', 'vci number' => 'VCI nummer:', +'version' => 'Versie', 'view log' => 'bekijk log', 'virtual address' => 'Virtueel adres', 'virtual private networking' => 'Virtual Private Networking', diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 505988af9..19160503e 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -44,7 +44,7 @@ my @VALID_KEY_FINGERPRINTS = ( ); # A small color-hash :D -my %color; +our %color; $color{'normal'} = "\033[0m"; $color{'black'} = "\033[0;30m"; $color{'darkgrey'} = "\033[1;30m"; @@ -434,108 +434,113 @@ sub dbgetlist { } } +sub coredbinfo { + ### This subroutine returns core db version information in a hash. + # Usage is without arguments + + eval(`grep "core_" $Conf::dbdir/lists/core-list.db`); + + my %coredb = ( + CoreVersion => $Conf::version, + Release => $Conf::core_mine, + ); + + $coredb{'AvailableRelease'} = $core_release if ("$Conf::core_mine" < "$core_release"); + + return %coredb; +} + sub dblist { - ### This subroutine lists the packages. - # You may also pass a filter: &Pakfire::dblist(filter) - # Usage is always with two arguments. - # filter may be: all, notinstalled, installed + ### This subroutine returns the packages from the packages_list db in a hash. + # It uses the currently cached version of packages_list. To ensure latest + # data, run Pakfire::dbgetlist first. + # You may also pass a filter: &Pakfire::dblist(filter) + # Usage is always with one argument. + # filter may be: + # - "all": list all known paks, + # - "notinstalled": list only not installed paks, + # - "installed": list only installed paks + # - "upgrade": list only upgradable paks + # + # Returned hash format: + # ( "" => ( + # "Installed" => "Yes" or "No" wether the pak is installed, + # "ProgVersion" => Installed program version when "Installed" => "Yes" or + # Available version when "Installed" => No, + # "Release" => Installed pak release number when "Installed" => "Yes" or + # Available pak release number when "Installed" => No, + # "AvailableProgVersion" => Available program version. + # Only defined if an upgrade to a higher version is available, + # "AvailableRelease" => Available pak release version. + # Only defined if an upgrade to a higher version is available + # ), + # ... + # ) + my $filter = shift; - my $forweb = shift; - my @updatepaks; + my %paklist = (); my $file; my $line; - my $prog; my %metadata; my @templine; - - ### Make sure that the list is not outdated. - #dbgetlist("noforce"); - + open(FILE, "<$Conf::dbdir/lists/packages_list.db"); my @db = ; close(FILE); - if ("$filter" eq "upgrade") { - if ("$forweb" ne "forweb" && "$forweb" ne "notice" ) {getcoredb("noforce");} - eval(`grep "core_" $Conf::dbdir/lists/core-list.db`); - if ("$core_release" > "$Conf::core_mine") { - if ("$forweb" eq "forweb") { - print "\n"; - } - elsif ("$forweb" eq "notice") { - print "


$Lang::tr{'core notice 1'} $Conf::core_mine $Lang::tr{'core notice 2'} $core_release $Lang::tr{'core notice 3'}"; - } else { - my $command = "Core-Update $Conf::version\nRelease: $Conf::core_mine -> $core_release\n"; - if ("$Pakfire::enable_colors" eq "1") { - print "$color{'lila'}$command$color{'normal'}\n"; - } else { - print "$command\n"; - } - } - } - + if ("$filter" ne "notinstalled") { opendir(DIR,"$Conf::dbdir/installed"); my @files = readdir(DIR); closedir(DIR); + foreach $file (@files) { next if ( $file eq "." ); next if ( $file eq ".." ); next if ( $file =~ /^old/ ); %metadata = parsemetafile("$Conf::dbdir/installed/$file"); - foreach $prog (@db) { - @templine = split(/\;/,$prog); - if (("$metadata{'Name'}" eq "$templine[0]") && ("$metadata{'Release'}" < "$templine[2]" && "$forweb" ne "notice")) { - push(@updatepaks,$metadata{'Name'}); - if ("$forweb" eq "forweb") { - print "\n"; - } else { - my $command = "Update: $metadata{'Name'}\nVersion: $metadata{'ProgVersion'} -> $templine[1]\nRelease: $metadata{'Release'} -> $templine[2]\n"; - if ("$Pakfire::enable_colors" eq "1") { - print "$color{'lila'}$command$color{'normal'}\n"; - } else { - print "$command\n"; - } - } + foreach $line (@db) { + next unless ($line =~ /.*;.*;.*;/ ); + @templine = split(/\;/,$line); + if (("$metadata{'Name'}" eq "$templine[0]") && ("$metadata{'Release'}" < "$templine[2]")) { + # Add all upgradable paks to list + $paklist{"$metadata{'Name'}"} = { + ProgVersion => $metadata{'ProgVersion'}, + Release => $metadata{'Release'}, + AvailableProgVersion => $templine[1], + AvailableRelease => $templine[2], + Installed => "yes" + }; + last; + } elsif (("$metadata{'Name'}" eq "$templine[0]") && ("$filter" ne "upgrade")) { + # Add installed paks without an upgrade available to list + $paklist{"$metadata{'Name'}"} = { + ProgVersion => $metadata{'ProgVersion'}, + Release => $metadata{'Release'}, + Installed => "yes" + }; + last; } } } - return @updatepaks; - } else { - my $line; - my $use_color; - my @templine; - my $count; - foreach $line (sort @db) { + } + + # Add all not installed paks to list + if (("$filter" ne "upgrade") && ("$filter" ne "installed")) { + foreach $line (@db) { next unless ($line =~ /.*;.*;.*;/ ); - $use_color = ""; @templine = split(/\;/,$line); - if ("$filter" eq "notinstalled") { - next if ( -e "$Conf::dbdir/installed/meta-$templine[0]" ); - } elsif ("$filter" eq "installed") { - next unless ( -e "$Conf::dbdir/installed/meta-$templine[0]" ); - } - $count++; - if ("$forweb" eq "forweb") - { - if ("$filter" eq "notinstalled") { - print "\n"; - } else { - print "\n"; - } - } else { - if ("$Pakfire::enable_colors" eq "1") { - if (&isinstalled("$templine[0]")) { - $use_color = "$color{'red'}" - } else { - $use_color = "$color{'green'}" - } - } - print "${use_color}Name: $templine[0]\nProgVersion: $templine[1]\nRelease: $templine[2]$color{'normal'}\n\n"; - } + next if ((defined $paklist{"$templine[0]"}) || (&isinstalled($templine[0]) == 0)); + + $paklist{"$templine[0]"} = { + ProgVersion => "$templine[1]", + Release => "$templine[2]", + Installed => "no" + }; } - print "$count packages total.\n" unless ("$forweb" eq "forweb"); } + + return %paklist; } sub resolvedeps_one { @@ -910,10 +915,10 @@ sub progress_bar { sub updates_available { # Get packets with updates available - my @upgradepaks = &Pakfire::dblist("upgrade", "noweb"); + my %upgradepaks = &Pakfire::dblist("upgrade"); - # Get the length of the returned array - my $updatecount = scalar @upgradepaks; + # Get the length of the returned hash + my $updatecount = keys %upgradepaks; return "$updatecount"; } diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 6c77695c8..b4930e85d 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -270,14 +270,25 @@ &Pakfire::getcoredb("$force"); } elsif ("$ARGV[0]" eq "upgrade") { + my $use_color = ""; + my $reset_color = ""; + + if ("$Pakfire::enable_colors" eq "1") { + $reset_color = "$Pakfire::color{'normal'}"; + $use_color = "$Pakfire::color{'lightpurple'}"; + } + &Pakfire::upgradecore(); - my @upgradepaks = &Pakfire::dblist("upgrade", "noweb"); + my @deps = (); - - if (@upgradepaks) { + if (my %upgradepaks = &Pakfire::dblist("upgrade")) { # Resolve the dependencies of the to be upgraded packages - @deps = &Pakfire::resolvedeps_recursive(@upgradepaks); + @deps = &Pakfire::resolvedeps_recursive(keys %upgradepaks); + foreach $pak (sort keys %upgradepaks) { + print "${use_color}Update: $pak\nVersion: $upgradepaks{$pak}{'ProgVersion'} -> $upgradepaks{$pak}{'AvailableProgVersion'}\n"; + print "Release: $upgradepaks{$pak}{'Release'} -> $upgradepaks{$pak}{'AvailableRelease'}${reset_color}\n"; + } &Pakfire::message(""); &Pakfire::message("PAKFIRE UPGR: We are going to install all packages listed above."); if ($interactive) { @@ -290,36 +301,78 @@ exit 1; } } - } + + # Download packages + foreach $pak (sort keys %upgradepaks) { + &Pakfire::getpak("$pak", ""); + } - # Download packages - foreach $pak (@upgradepaks) { - &Pakfire::getpak("$pak", ""); + # Download dependencies + foreach $pak (@deps) { + &Pakfire::getpak("$pak", ""); + } + + # Install dependencies first + foreach $pak (@deps) { + &Pakfire::setuppak("$pak"); + } + + # Install all upgrades + foreach $pak (sort keys %upgradepaks) { + &Pakfire::upgradepak("$pak"); + } + } else { + &Pakfire::message("PAKFIRE WARN: No new package upgrades available."); } - # Download dependencies - foreach $pak (@deps) { - &Pakfire::getpak("$pak", ""); + } elsif ("$ARGV[0]" eq "list") { + my $count; + my $use_color = ""; + my $reset_color = ""; + my $filter = "all"; + + if ("$ARGV[1]" =~ /installed|notinstalled/) { + $filter = "$ARGV[1]"; + } else { + &Pakfire::message("PAKFIRE WARN: Not a known option $ARGV[1]") if ($ARGV[1]); } - # Install dependencies first - foreach $pak (@deps) { - &Pakfire::setuppak("$pak"); + my $pak; + my %paklist = &Pakfire::dblist($filter); + + if ("$Pakfire::enable_colors" eq "1") { + $reset_color = "$Pakfire::color{'normal'}"; + $use_color = "$Pakfire::color{'lightgreen'}"; } - # Install all upgrades - foreach $pak (@upgradepaks) { - &Pakfire::upgradepak("$pak"); + foreach $pak (sort keys %paklist) { + if ("$Pakfire::enable_colors" eq "1") { + if ("$paklist{$pak}{'Installed'}" eq "yes") { + if (defined $paklist{$pak}{'AvailableProgVersion'}) { + $use_color = "$Pakfire::color{'lightgreen'}"; + } else { + $use_color = "$Pakfire::color{'green'}"; + } + } else { + $use_color = "$Pakfire::color{'red'}"; + } + } + + print "${use_color}Name: $pak\nProgVersion: $paklist{$pak}{'ProgVersion'}\n"; + print "Release: $paklist{$pak}{'Release'}\nInstalled: $paklist{$pak}{'Installed'}\n"; + if (defined $paklist{$pak}{'AvailableProgVersion'}) { + print "Update available:\n Version: $paklist{$pak}{'ProgVersion'} -> $paklist{$pak}{'AvailableProgVersion'}\n Release: $paklist{$pak}{'Release'} -> $paklist{$pak}{'AvailableRelease'}\n"; + } + print "${reset_color}\n"; + } - } elsif ("$ARGV[0]" eq "list") { - if ("$ARGV[1]" =~ /installed|notinstalled/) { - &Pakfire::dblist("$ARGV[1]", "noweb"); + $count = keys %paklist; + if ($count > 0) { + print "$count packages total.\n"; } else { - &Pakfire::message("PAKFIRE WARN: Not a known option $ARGV[1]") if ($ARGV[1]); - &Pakfire::dblist("all", "noweb"); + &Pakfire::message("PAKFIRE WARN: No packages where found using filter $filter."); } - } elsif ("$ARGV[0]" eq "resolvedeps") { foreach (@ARGV) { next if ("$_" eq "resolvedeps"); From patchwork Thu Jul 28 11:21:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5777 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 4LtpCk2S90z3wvM for ; Thu, 28 Jul 2022 11:22:42 +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 4LtpCc0nbVz5SZ; Thu, 28 Jul 2022 11:22:36 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCb3PnGz303b; Thu, 28 Jul 2022 11:22:35 +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 4LtpCX3dXRz30M7 for ; Thu, 28 Jul 2022 11:22:32 +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 4LtpCW4n6Xz5RT for ; Thu, 28 Jul 2022 11:22:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 7506640E71 for ; Thu, 28 Jul 2022 13:22:31 +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 7IRyfhCdS5lc for ; Thu, 28 Jul 2022 13:22:30 +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 20C92560A4; 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=1659007341; bh=MMlFG0pjag+zV96HQKc1BgBK7VIiTeocHbIIJyckm34=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WD7dKjnl/DeUQ6beDGvLtNoQc+Ie1DCjpwwze5wlawBKV/1JhujzsxuwAx7FDwqx5 Uq5RzT54x69pS2606JqXbhYgW1EKAFofxIl70SsIQtRhPXiAYzJXIlvL2ELZD37cnQ bXJrUHAFPsfPYEmvp/0A/rK++nxAypOuoPlcOrowRDBSdm2ecuEY34mZd45WO/w80/ Ab2pbFc3lniuHr7151UZPZbPgKbCjo5e4qSq24Njp75eksjsTFY8AICIoBAO5OqmXy 66dcDyhYMvYDPn4nOgFkgAX096MIdikPlg8R4cDcKvpdxLoharQKXGrtESF9ywPnnG vSThz+JSu/aWw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 02/10] pakfire: Translate WUI header/footer text Date: Thu, 28 Jul 2022 13:21:28 +0200 Message-Id: <20220728112136.30218-3-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: 20C92560A4.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.88815@GidJDutsXYFzmp0WVz1lGw ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rsXw0+oLg0HTG/c+xeOV+9oY0P2TkYF/EzVzbJoFEeo=; b=Y2S5ZccicNb/1BMnBWeWRekgdGPwPsR1kG8FtnMfHq+kKYmYTm1lcDD29Sd5vNXjyipyR3 7r+/U7NBCVTfVJGsXF9AyWJJ4Mo2auGbko7U4qkgjrhQEayie54SUqyDd0DheZyDQyyyh3 BA6KbRjducYzfv4jf2/sb/c7ygusiwapeL/GwONnIprHvbU7KXvAyaRYmYW7US2LSiZPUL Dtq/W4/x6XcHz0tR1jzDy+1bGftJQpYqurfL80GsIRIeyc4CqBpFqq3gJ63EvUOknmIxdq GxGaqK9hmcsy1bZrQpPgF3yg6HXGS036S4xeBT68zVGsVcdqLiGsCEuJPycKIg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=WD7dKjnl; 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=1659007351; a=rsa-sha256; cv=none; b=QroR4AxuuEWn3ac1nIQT2gFjccZ2DG3XAkdKRLsmdMN9XqtwAAgWKKf5//0BBr9ktPTc8e Sjb9cvRnjAMAbl4HiNqT68NvsZ1Spz23T7avkLdCLpeXACA7rX+EiAY7zVJMS3TJt+mHsC 8E/nJ6ICjhW3ZOwqnFwUt+YAKQh/k1eBg0ZhumedT6VUVvRuPRlNaTL3gCWIC9A1rc6IbP NfmOnKrgIbJO1Z0KlPbtLKpgkzANKoy1mYEpPKLVZcvDm/jgCYtCMNTwRm2BW1j8bqRWNh U97y6SuSMvrjZbqkyecfF+yZlFqPsX0XYzYPqEFSzdZx19GFzDxKpixKuUUTAg== X-Rspamd-Queue-Id: 4LtpCW4n6Xz5RT Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=WD7dKjnl; 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 [-9.25 / 11.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; IP_REPUTATION_HAM(-0.87)[asn: 50673(-0.03), country: NL(-0.01), ip: 178.21.23.139(-0.83)]; DKIM_REPUTATION(-0.83)[-0.82998891953091]; SPF_REPUTATION_HAM(-0.82)[-0.8181876541108]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.27)[disroot.org:s=mail]; MIME_HTML_ONLY(0.20)[]; R_SPF_ALLOW(-0.20)[+a:c]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; 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" Add en/nl/fr/de translations for: - Traffic: In XXX bit/s Out XXX bit/s - IPFire X.XX (xxx) - Core Update XXX ... Signed-off-by: Robin Roevens --- html/html/themes/ipfire/include/functions.pl | 8 ++++---- langs/de/cgi-bin/de.pl | 3 +++ langs/en/cgi-bin/en.pl | 3 +++ langs/fr/cgi-bin/fr.pl | 3 +++ langs/nl/cgi-bin/nl.pl | 3 +++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl index cc976e812..cbd05d109 100644 --- a/html/html/themes/ipfire/include/functions.pl +++ b/html/html/themes/ipfire/include/functions.pl @@ -67,9 +67,9 @@ sub showmenu() { if ($settings{'SPEED'} ne 'off') { print < - Traffic: - In --.-- bit/s   - Out --.-- bit/s + $Lang::tr{'traffic stat title'}: + $Lang::tr{'traffic stat in'} --.-- bit/s   + $Lang::tr{'traffic stat out'} --.-- bit/s
EOF } @@ -202,7 +202,7 @@ sub openpagewithoutmenu { sub closepage () { open(FILE, "; - $system_release =~ s/core/Core Update /; + $system_release =~ s/core/$Lang::tr{'core update'} /; close(FILE); print < 'Verkehr auf', 'traffic shaping' => 'Traffic Shaping', 'traffic shaping settings' => 'Einstellungen der Datenflußkontrolle', +'traffic stat title' => 'ROTER Traffic', +'traffic stat in' => 'Ein', +'traffic stat out' => 'Aus', 'traffic warn level bad' => 'Warnlevel ist nicht gültig', 'trafficblue' => 'WLAN', 'trafficdate' => 'Datum', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index b51823177..73aa4d04a 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2567,6 +2567,9 @@ 'traffic on' => 'Traffic on', 'traffic shaping' => 'Traffic Shaping', 'traffic shaping settings' => 'Traffic Shaping Settings', +'traffic stat title' => 'RED Traffic', +'traffic stat in' => 'In', +'traffic stat out' => 'Out', 'traffic warn level bad' => 'Warnlevel is not correct', 'trafficblue' => 'WLAN', 'trafficdate' => 'Date', diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl index 560b4aa54..9e0bd3449 100644 --- a/langs/fr/cgi-bin/fr.pl +++ b/langs/fr/cgi-bin/fr.pl @@ -2579,6 +2579,9 @@ 'traffic on' => 'Trafic en cours', 'traffic shaping' => 'Arrangement du trafic', 'traffic shaping settings' => 'Réglages de l\'arrangement du trafic', +'traffic stat title' => 'Trafic ROUGE', +'traffic stat in' => 'Entrée', +'traffic stat out' => 'Sortie', 'traffic warn level bad' => 'Le niveau d\'alerte n\'est pas correct', 'trafficblue' => 'WLAN', 'trafficdate' => 'Date', diff --git a/langs/nl/cgi-bin/nl.pl b/langs/nl/cgi-bin/nl.pl index e50a95578..7229a86ae 100644 --- a/langs/nl/cgi-bin/nl.pl +++ b/langs/nl/cgi-bin/nl.pl @@ -2131,6 +2131,9 @@ 'traffic on' => 'Verkeer op', 'traffic shaping' => 'Verkeersregeling', 'traffic shaping settings' => 'Verkeersregeling instellingen', +'traffic stat title' => 'ROOD Verkeer', +'traffic stat in' => 'In', +'traffic stat out' => 'Uit', 'traffic warn level bad' => 'Waarschuwingsniveau is onjuist', 'trafficblue' => 'WLAN', 'trafficdate' => 'Datum', From patchwork Thu Jul 28 11:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5769 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 4LtpCZ1Gqvz3wvM for ; Thu, 28 Jul 2022 11:22:34 +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 4LtpCT0vx5z1Q0; Thu, 28 Jul 2022 11:22:29 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCS4DBnz30H2; Thu, 28 Jul 2022 11:22:28 +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 4LtpCR5VQNz2yVB for ; Thu, 28 Jul 2022 11:22:27 +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 4LtpCQ4QPtzq1 for ; Thu, 28 Jul 2022 11:22:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 8F97140DAC for ; Thu, 28 Jul 2022 13:22:24 +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 OinTtuSii6FI for ; Thu, 28 Jul 2022 13:22:23 +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 2E89A560A7; 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=zncqc1XpUoHk0j3Hy+7Fkcny1pWLPaWJ1/9nVGNPhw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dihGY18ubrx8+Y9zvBuJDOIn+ArC1SbQUNa6hKk9LMn0bEeV5UnMkgbiSPWwl4kOQ fPRWcQlBhhVkpLDmZ4BtTESZygL/zmdeN8FlkeEVgVSrCzlI7hyPbOQpEOcDXLj0Gr GavVCxultfnBlL2XXpCJthsIIqOQuJ6lgKFOCSYnDr1sLpbThfs80/lWMh+f6oq5oY az8nlr7zzpZUpEy2Jv5KH2gE310l1efahyevL1aBy5CGtGo3N4flRs1mcIj4ePmdxo l6ZQvjTUBAk5f6EvkpxpfIykMYiVjpxyRcOUstH7202QJOyOhVONoVwOcL4iB4ce45 e58TQK+xKWVzw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 03/10] pakfire: Replace duplicate code with dblist functioncall Date: Thu, 28 Jul 2022 13:21:29 +0200 Message-Id: <20220728112136.30218-4-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: 2E89A560A7.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.72555@1uT0Nlh+Xi+Wc5uLxj/gQQ ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007346; 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=aKhmZDXMSAY5i5ZQp234wQtO4QFcQ9mqF4Eb9FUM+o8=; b=VxaWyVTz012GtTG18+SHRbnC2AAbDzu9t1dN3FESVDMamvK3rgfr7kLKPq5y7XmhfgkyPH E1R0IoylAYDN1bLZhp6pswvTi43PPFT8zUXefw7aJl2LARRM2h6a4Qo463BLQsbV1h7yiA buh2yagpMqBfwHZFZnlZe1IB5N8MBa86ORJ3BLYDvLMQ2dozN5X9fir4AFSli2rZ9QrUqw 5YkNfA4qsz2Y4d7a7m3JC+TGoupahMkRScJzYo0dNuhfUalNTz4OfthKYxMR0he7MEZCyq QOvz/D4/dmgfu8qRjxHT28syaKW/8SK2x3GOCv9FslUzC0la3+TdP149sK1GDw== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=dihGY18u; 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=1659007346; a=rsa-sha256; cv=none; b=PfLlAQMMMvf2s8MW/ShtDU4mh6AkLcrQRrQP5ftqYHNioR45F3FI/ZyYE1/miznLVsrxSa ggyA8+a8iWZ3lRdg0DRrtQ9Xy0wH524EG+qkPWSzwl208aDNJfL0n6sm6yG5z69bOeINO1 FsB8wdxtyif4RpZoIf6pzYJ+5+WwSV/LksRHroV0nAe5BuOfTy9d1XBCp5VT3+sm7plNyM /3jhqINvlWEsbX77F55ZUMqa0/2XDlgYnVI40+fPjYV/S+rs5mMz/vN3b/dmJOgsAPVxI5 VXbHETqtXajm7aixV+DtC7e60f4soJiojmzfSRZJXa291Jldit3o0h2DjmqQcg== X-Rspamd-Queue-Id: 4LtpCQ4QPtzq1 Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=dihGY18u; 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 [-3.84 / 11.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81830489729047]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; MV_CASE(0.50)[]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+a]; 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)]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; DKIM_TRACE(0.00)[disroot.org:+]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(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" 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\"."); } From patchwork Thu Jul 28 11:21:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5768 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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4LtpCX37Tfz3wvM for ; Thu, 28 Jul 2022 11:22:32 +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 4LtpCS47r1zq1; Thu, 28 Jul 2022 11:22:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCS3M4Rz303Y; Thu, 28 Jul 2022 11:22:28 +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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4LtpCR53pyz2xPh for ; Thu, 28 Jul 2022 11:22:27 +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 4LtpCQ4YF4zxZ for ; Thu, 28 Jul 2022 11:22:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B54C540DA4 for ; Thu, 28 Jul 2022 13:22:25 +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 u4ilLUQhnPC2 for ; Thu, 28 Jul 2022 13:22:24 +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 30EB4560AA; 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=o2JIs3reAY1FkfsE5lRDYfwwACr/Z3O2RPyKukkE2XA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Dk4BtOWcGdZN1cHdt2BKW3zwqeXXXt6Pl7VS3k0mKC4V0lWXUFNw0Hp0PQxyHHlFb FYPbTLwCGk4HOLHb4zrpK6lSNcqpPnhGkK0ZolPUjtwvMNKSohbgxXCIU+6tsF5lWt /Jx4kHDX/a4vbIRYyGC/fV3tyDjt5b+0cVvusaEZF92+u42C1VcUo5boCFm9cQ0ohe xDilSuHiSBwL+5PpESfDA5fMem1KDl94MPll9QGovjDPUrejnNZz23Mi/kl9/pKtP+ 8Gyzt0Mpm6095X5ihbYMzDzOz8HeyrTZYO+FRScOD06ZqyC/64XIqU3Pxo+0HI+Dnd PneRzSbv2T9zg== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 04/10] pakfire: Replace dbgetlist duplicate code Date: Thu, 28 Jul 2022 13:21:30 +0200 Message-Id: <20220728112136.30218-5-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: 30EB4560AA.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.74873@RZXGxqxxHt78JkF77uTWEA ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007346; 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=V7y9ONW8RcW+9O5VxQjqvNP3n7Rkn/S4V/vvBkVpNH4=; b=oKHj6cebTEsjc/PY/WMw2KQEp8J2pSIHNSi7dcdP1kBsJv7qEpQvfXhlLNUmBb3dRztttd JIWCnhe5AJBOPhHCDXT0KUN2TW40OIbfzU9Bp5revbx93rMgrFqPS3YsmISHOHIbZuTmMC od/Yn4/wwLcCea03UuoNiM3EzopLpf+iRsBO2xDJrOIVY9DPkHOyWGJMOzcJE9Q+Vn0kGG LaC/VXGEzbwEOF+XEqEO219Adc8yonL5OUgchF7SAFicN8561MGYT5jWQimfCPFjItFs++ rhZurIpPUGwrXObfcrTnMbplESWAFFHmzR3w0LK7AKqam+wGvT2KEKkOIb3xkg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=Dk4BtOWc; 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=1659007346; a=rsa-sha256; cv=none; b=EmJIIiPWA3mOdEMhdcbzdRyjs7IL7WApMVfB0CH8IL6FpyYKpHQd5nDQfvM0dUdiIETfKJ Ht7Oy6D3JJqifCOuiLvE8eXf9CeMRIUhDa3xLIaR3ADuffbxbvTD9P7s3JV0BHVFQG7saJ cIHZbtdtcOGaOTq6vl0Xk4PISYO6bM4d4cocXJFG7XuJzlYYEHROotvsRuq237C+YInA1U tRJJcLXgYwPEI/hbNWdoa4EckYvxKA4ZbrOIxisA2Ups+G0EilBcc0zcg2Z/2ICiFFJS/s rvITr4N05MQ122YlH1yF2lboR2O1RsJ+DuE1RFVLkta+z/9/THz4RLDuGrySog== X-Rspamd-Queue-Id: 4LtpCQ4YF4zxZ Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=Dk4BtOWc; 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 [-3.84 / 11.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81830489729047]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; MV_CASE(0.50)[]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+a]; 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)]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; DKIM_TRACE(0.00)[disroot.org:+]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(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" Replace dbgetlist code duplicating dblist and getmetafile workings with call to actual dblist and getmetafile functions. Signed-off-by: Robin Roevens --- src/pakfire/lib/functions.pl | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 19160503e..971aa2d59 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -410,9 +410,7 @@ sub dbgetlist { my %metadata; my @templine; - open(FILE, "<$Conf::dbdir/lists/packages_list.db"); - my @db = ; - close(FILE); + my %paklist = &Pakfire::dblist("all"); opendir(DIR,"$Conf::dbdir/meta"); my @files = readdir(DIR); @@ -424,12 +422,12 @@ sub dbgetlist { next if ( $file =~ /^old/ ); %metadata = parsemetafile("$Conf::dbdir/meta/$file"); - foreach $prog (@db) { - @templine = split(/\;/,$prog); - if (("$metadata{'Name'}" eq "$templine[0]") && ("$metadata{'Release'}" ne "$templine[2]")) { - move("$Conf::dbdir/meta/meta-$metadata{'Name'}","$Conf::dbdir/meta/old_meta-$metadata{'Name'}"); - getmetafile($metadata{'Name'}); - } + if ((defined $paklist{"$metadata{'Name'}"}) && ( + ("$paklist{\"$metadata{'Name'}\"}{'Release'}" ne "$metadata{'Release'}") || + (defined $paklist{"$metadata{'Name'}"}{'AvailableRelease'})) + ) { + move("$Conf::dbdir/meta/meta-$metadata{'Name'}","$Conf::dbdir/meta/old_meta-$metadata{'Name'}"); + getmetafile($metadata{'Name'}); } } } From patchwork Thu Jul 28 11:21:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5772 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 4LtpCd42mDz40W1 for ; Thu, 28 Jul 2022 11:22:37 +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 4LtpCV4kvHz4DB; Thu, 28 Jul 2022 11:22:30 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCT6Fdzz30Gm; Thu, 28 Jul 2022 11:22:29 +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 4LtpCS5gpRz2yXK for ; Thu, 28 Jul 2022 11:22:28 +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 4LtpCS4ZTvz1Dp for ; Thu, 28 Jul 2022 11:22:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6D55D40DC8 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 XL-41PmuWDPg 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 3314B560AD; 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=CW5P7niQyfQQJKHfUDg5Psth+VrCVZ+6yO1VIqZYisM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FngmGXEGv5yz749h1nkWdp1Ypi3jyg+eMSOj+7pj6uaCSjQYGoAUlMVGajK/5jgMi 9V0LjSA/TNGRsS9norgR3FYW94f5jS4IHOyZ92sKal5zxAz+Ph7GOZh2S9RxjFe5ra 1oJDMtW8UL/9sOCHMp+BL9DbtN2LPrKXpjNavqeWUy3rx3loPl6STJDR/Jb7EVFsdT o3UNl53nabLJC8NXxOLHqVYkFqZbb+usT7xqRSnaqNSUEPYBor8cNWzIoqDy8lsrlI fpRHLSC+00pQ1FDenwaGnL4Awf65mRnRDlzSZQVroDqNlSdP8Sc/tI0bMNFe4gO7Z1 /ZzEr1KcxJoIg== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 05/10] pakfire: Optimize upgradecore function Date: Thu, 28 Jul 2022 13:21:31 +0200 Message-Id: <20220728112136.30218-6-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: 3314B560AD.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.84174@udNY2CYiRyVPTBO8jaHtpw ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007348; 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=nv0bW+j40YZVZWDwubeoZ9eZxRpLL3mcv0j4m4nJFIE=; b=vZy4xshccbbi3xKvRtfxtE48p2+hvo8/RA4mqg1eDn7k1s4dkaacOVy5pES6W7+uWsqGhm 831h/1FOns9IUZ/uDHyG45y37W/qKmqDku+ZqVfWB5sQEAeDFWkfpxGxIv5Voi2QxQVeoo mo0ut1yZ6APj3t0k/MczJ439Kct8njKmVnHu6NUV2CIrpjVLt0aQ8fbtCIqp4+KbKd0vKh LNqMf3WbFWNHqUWm8eyU8dJfm0+SHxAscIN90K1t9khDuJQ9Xp3+vUNj60MVXM/G1SKj1l BmzeoDX7lCkCIP36pR9Ysfi9QCwYPM6aA/PgtxQZAuCpMqI5P5EgDizNXkS1cQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=FngmGXEG; 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=1659007348; a=rsa-sha256; cv=none; b=xKhiUP6U6/0crQJaCRHjmI6lkVzq4zamIfQelMSfeXnWB4V3JdyoYCcEhYxHeW0rPzpuq5 wdefkhjzOd+GteITjBw4+h7sRSSjOtvAft9+EQElCp9KBQY0XUoeMe+oT0KCCbpONjYaVg +/62Qlb0fxUM3CSgDQG75gV1WZ61NkrLsz/u/Ghk1B7+GDAmzd0VzHKbQHJYA0LJotvhYn pDNG2QWWJv8+dhRBefDsFLw/geqaEZgwZCKComNoXUoTepPXZcrwrJDaRIa8h1FppT+Ghv aNTA3lBQ8MVmWh+i8H2bq5DdwOMVRK68Xv17TGqYypH56zpCHG5E0YqU9JJ7Gw== X-Rspamd-Queue-Id: 4LtpCS4ZTvz1Dp Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=FngmGXEG; 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 [-3.84 / 11.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81818744239513]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; 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)]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; FROM_EQ_ENVFROM(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; DKIM_TRACE(0.00)[disroot.org:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_THREE(0.00)[4]; ARC_NA(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" upgradecore function should just upgrade the core: Moved check if upgrade is necessary to pakfire upgrade code, removing code from upgradecore function duplicating codedbinfo workings. Also adding more vebosity to pakfire upgrade. Signed-off-by: Robin Roevens --- src/pakfire/lib/functions.pl | 47 +++++++++++++++--------------------- src/pakfire/pakfire | 16 +++++++++++- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 971aa2d59..4f0515f62 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -773,35 +773,28 @@ sub setuppak { } sub upgradecore { - getcoredb("noforce"); - eval(`grep "core_" $Conf::dbdir/lists/core-list.db`); - if ("$core_release" > "$Conf::core_mine") { - # Safety check for lazy testers: - # Before we upgrade to the latest release, we re-install the previous release - # to make sure that the tester has always been on the latest version. - my $tree = &get_tree(); - $Conf::core_mine-- if ($tree eq "testing" || $tree eq "unstable"); - - message("CORE UPGR: Upgrading from release $Conf::core_mine to $core_release"); - - my @seq = `seq $Conf::core_mine $core_release`; - shift @seq; - my $release; - foreach $release (@seq) { - chomp($release); - getpak("core-upgrade-$release"); - } - - foreach $release (@seq) { - chomp($release); - upgradepak("core-upgrade-$release"); - } - - system("echo $core_release > $Conf::coredir/mine"); + # Safety check for lazy testers: + # Before we upgrade to the latest release, we re-install the previous release + # to make sure that the tester has always been on the latest version. + my $tree = &get_tree(); + $Conf::core_mine-- if ($tree eq "testing" || $tree eq "unstable"); - } else { - message("CORE INFO: No new upgrades available. You are on release $Conf::core_mine."); + message("CORE UPGR: Upgrading from release $Conf::core_mine to $core_release"); + + my @seq = ($Conf::core_mine .. $core_release); + shift @seq; + my $release; + foreach $release (@seq) { + chomp($release); + getpak("core-upgrade-$release"); } + + foreach $release (@seq) { + chomp($release); + upgradepak("core-upgrade-$release"); + } + + system("echo $core_release > $Conf::coredir/mine"); } sub isinstalled { diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index f23110cf5..351d71216 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -266,7 +266,21 @@ $use_color = "$Pakfire::color{'lightpurple'}"; } - &Pakfire::upgradecore(); + &Pakfire::message("CORE INFO: Checking for Core-Updates..."); + + ### Make sure that the core db is not outdated. + &Pakfire::getcoredb("noforce"); + my %coredb = &Pakfire::coredbinfo(); + + if (defined $coredb{'AvailableRelease'}) { + &Pakfire::upgradecore(); + } else { + &Pakfire::message("CORE INFO: No new Core-Updates available. You are on release ".$coredb{'Release'}); + } + + &Pakfire::message("PAKFIRE INFO: Checking for package updates..."); + ### Make sure that the package list is not outdated. + &Pakfire::dbgetlist("noforce"); my @deps = (); if (my %upgradepaks = &Pakfire::dblist("upgrade")) { 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. From patchwork Thu Jul 28 11:21:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5771 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 4LtpCb5FVkz3wvM for ; Thu, 28 Jul 2022 11:22:35 +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 4LtpCT3N3cz5Rb; Thu, 28 Jul 2022 11:22:29 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCS5Dvhz303b; Thu, 28 Jul 2022 11:22:28 +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 4LtpCR697Gz2yXK for ; Thu, 28 Jul 2022 11:22:27 +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 4LtpCR51H9z1Dp for ; Thu, 28 Jul 2022 11:22:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 5120840DC8 for ; Thu, 28 Jul 2022 13:22:27 +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 YlHmFdpoGvF5 for ; Thu, 28 Jul 2022 13:22:26 +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 428BF560B3; 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=hzmFkHlLHJr0buI/7+DZAN68pqJOMks2+QM/+aPNLYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=T+nmrxFYkIsnmM4aQK/NbQuSb2HloThflRMfB7J14372oQ4yVzAXQb7C/Y3a3qeW1 zSsa6ijZphdArVLvdtFkD4kgNM02YLATZk3JAGVAS55o07c1IlxwOERQkmbqCnLM/q kpS2o/hicMQEW03FjRWxDHnbbEgVpAoK0EbqFZCga42ZDG//8t/uMcmI0Rz+7K6uoC MA4azRY4yf8zVvzbTW4u/gbL8+9Jm09ReUOztRhCkbsdBuaRpspiolF/TMiA0TcS35 yLbznypEhEV0xfZjH7v0D509DEoh5g2Gm4jIfmQ5824Nryw308ITQFpZ1/fUzHYK5s BLUDiWtPMGFgg== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 07/10] pakfire: Refactor status seperating UI and logic Date: Thu, 28 Jul 2022 13:21:33 +0200 Message-Id: <20220728112136.30218-8-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: 428BF560B3.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.77205@KAzKUTsDhoGVdS0TR5z1Bw ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007347; 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=AzFiopZQSyltinsgTuuxyENPFigNmf3BLJ7d8hDLTwA=; b=apOIVIx4XR7B7t4Qh9CZfXxrppVjuIe/5ixbq/DH0+pCtC2WQ+GD2cxknDb3gTivZHOc8U aIaCcssahhTw8B5RtH3WRWRcdoLcAf8yCI/4Umk6NYxprW5nMvLXdA7ZHzlep59RrX6K4o 136FT3ZVV50Kts++7gJqWtTDXXWATOacTx41Gu+6HpNyTwDqV+liaNx/VLaOmorEgAE+5c dlNxW7Xvfh7T7IavXMneUMpycDHbO1+F3ACDZ59gUo3FUsTWOHteUk/2c6D2Su09sQsgCT NysdOGT9D8S2lminssj75pQkXXwUVvgg7MGghheJSR2SQNVBWY2j7gHVY4HcEg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=T+nmrxFY; 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=1659007347; a=rsa-sha256; cv=none; b=b6sRRJPdS7mWIR+t4pN7bq88nlZ/RswuJZSxoQzEIf2ZAQb0P2zTJTJ6S/43beQN2TpkXp 7v4VPZ1bec5eHNe0uNiPlT8xWOL0YJExli7N2ABZ6qYi/5H9mkeZeZjbm1p58BT3jrcX15 H3YA8o5LEPsdlLi14WC0MiApyOckjLC0YP5AKwf8nUu8eHalT0mgG+lUNAbcaWuSoSu4aE QxP1dvLFek0/j9iR0y6HdumvI6dy9KDatAtveYa/M3w6cXXC2AP9g9tYj1tBGZLEaToywr kTnFL0k+6eyHokr2RlT0TcN6y3o2HCYv2Gh2ebc19W9UTnPkocNU9h5TTGxPhw== X-Rspamd-Queue-Id: 4LtpCR51H9z1Dp Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=T+nmrxFY; 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 [-3.84 / 11.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81818744443554]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; 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)]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; FROM_EQ_ENVFROM(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; DKIM_TRACE(0.00)[disroot.org:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_THREE(0.00)[4]; ARC_NA(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" - Removed UI code from status function now returning hash with status properties. - Removed function coreupdate_available as it is now not used anymore - Added UI code to pakfire status routine - Added meaningfull exitcode to status: - 2: Core update available - 3: Pak update available - 4: Reboot required - Error codes can be added together: 2+3 = 5 means both core update and pak update is available Signed-off-by: Robin Roevens --- src/pakfire/lib/functions.pl | 50 +++++++++++++++--------------------- src/pakfire/pakfire | 19 +++++++++++++- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index d8b5c5a26..f87589bc4 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -914,16 +914,6 @@ sub updates_available { return "$updatecount"; } -sub coreupdate_available { - eval(`grep "core_" $Conf::dbdir/lists/core-list.db`); - if ("$core_release" > "$Conf::core_mine") { - return "yes ($core_release)"; - } - else { - return "no"; - } -} - sub reboot_required { if ( -e "/var/run/need_reboot" ) { return "yes"; @@ -934,26 +924,26 @@ sub reboot_required { } sub status { - # General info - my $return = "Core-Version: $Conf::version\n"; - $return .= "Core-Update-Level: $Conf::core_mine\n"; - $return .= "Last update: " . &General::age("/opt/pakfire/db/core/mine") . " ago\n"; - $return .= "Last core-list update: " . &General::age("/opt/pakfire/db/lists/core-list.db") . " ago\n"; - $return .= "Last server-list update: " . &General::age("/opt/pakfire/db/lists/server-list.db") . " ago\n"; - $return .= "Last packages-list update: " . &General::age("/opt/pakfire/db/lists/packages_list.db") . " ago\n"; - - # Get availability of core updates - $return .= "Core-Update available: " . &Pakfire::coreupdate_available() . "\n"; - - # Get availability of package updates - $return .= "Package-Updates available: " . &Pakfire::updates_available() . "\n"; - - # Test if reboot is required - $return .= "Reboot required: " . &Pakfire::reboot_required() . "\n"; - - # Return status text - print "$return"; - exit 1; + ### This subroutine returns pakfire status information in a hash. + # Usage is without arguments + + # Add core version info + my %status = &Pakfire::coredbinfo(); + + # Add last update info + $status{'LastUpdate'} = &General::age("/opt/pakfire/db/core/mine"); + $status{'LastCoreListUpdate'} = &General::age("/opt/pakfire/db/lists/core-list.db"); + $status{'LastServerListUpdate'} = &General::age("/opt/pakfire/db/lists/server-list.db"); + $status{'LastPakListUpdate'} = &General::age("/opt/pakfire/db/lists/packages_list.db"); + + # Add number of available package updates + $status{'CoreUpdateAvailable'} = (defined $status{'AvailableRelease'}) ? "yes" : "no"; + $status{'PakUpdatesAvailable'} = &Pakfire::updates_available(); + + # Add if reboot is required + $status{'RebootRequired'} = &Pakfire::reboot_required(); + + return %status; } sub get_arch() { diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 766d91b81..331204a00 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -412,7 +412,24 @@ system("rm -f /etc/fcron.daily/pakfire-upgrade"); } } elsif ("$ARGV[0]" eq "status") { - &Pakfire::status; + my $exitcode = 0; + my %status = &Pakfire::status; + + print "Core-Version: $status{'CoreVersion'}\n"; + print "Core-Update-Level: $status{'Release'}\n"; + print "Last update: $status{'LastUpdate'} ago\n"; + print "Last core-list update: $status{'LastCoreListUpdate'} ago\n"; + print "Last server-list update: $status{'LastServerListUpdate'} ago\n"; + print "Last packages-list update: $status{'LastPakListUpdate'} ago\n"; + print "Core-Update available: $status{'CoreUpdateAvailable'}"; + print " ($status{'AvailableRelease'})" if ("$status{'CoreUpdateAvailable'}" eq "yes"); + print "\nPackage-Updates available: $status{'PakUpdatesAvailable'}\n"; + print "Reboot required: $status{'RebootRequired'}\n"; + + $exitcode += 2 if ($status{'CoreUpdateAvailable'} eq "yes"); + $exitcode += 3 if ($status{'PakUpdatesAvailable'} eq "yes"); + $exitcode += 4 if ($status{'RebootRequired'} eq "yes"); + exit $exitcode; } else { &Pakfire::usage; } From patchwork Thu Jul 28 11:21:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5774 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 4LtpCg0nqDz40Wd for ; Thu, 28 Jul 2022 11:22:39 +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 4LtpCX5S3Vz5Rh; 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 4LtpCX11DCz30H2; 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 4LtpCV6x0xz2xc4 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 4LtpCV0vGLz1Ll 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 AD16840DC8 for ; Thu, 28 Jul 2022 13:22:29 +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 lPcS_n_1SBvj for ; Thu, 28 Jul 2022 13:22:28 +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 50CF3560B6; 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=BHAm4keprzphaBB7qCurpaqUJHtWWKIjFE8kSZuLlcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g4L+phxTgW+nGetvp52sJvBehLttw5eIgYkzYnrxFAlcMKL7TJh65FWlfBHMpALZ5 tN8iXv29ULpHvByM2Rol9kpY9AGqzMAo102USHJJCD6TbElql/cIyjkO8QpstpYM9H yLKJwLHq8cIrFNctKUd7ByQGpHvsjxJUGRBI7OY6QdtkK5ikkSunepLKLguAA0ogHF OSuzE8Xx8FwlYZonxXCrUm6SXD0yBffHRMsILpRmyyqlEMl2gzh81yiQHJEArjdSyn qgXi9gkOzDcDZztnenEjrwTv7Hcj248Byn+4e27NH6+KIXCiDablRTaijd3DkiWsUz hJ0CtAep0qy5g== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 08/10] pakfire: Replace status duplicate code Date: Thu, 28 Jul 2022 13:21:34 +0200 Message-Id: <20220728112136.30218-9-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: 50CF3560B6.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.93447@83swRzxhHiEduxGW6MHkFA ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007350; 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=/1mD7Di0XkcJyUROMMV2pLJOoTEolmgUe9UZt/WsclA=; b=u27OtalK1IvBCYwF9qg4DDr+OeemAh1rzbaKbaiUplWSrtGv/o0gYrRuaAlNpdb9menjSU Amg27c807RNwQir1RvR/+fWy2yh2QKBEsHgARzfFYtOs3WxpLj38Wgv1bTW+rnGaDTzZUb yQASX2O3guw0ERqUXrtCMul3J4nRDwxJHez9lXgV4Xtn+aTZ4OAfKBDkuW/SZeK8ZxqkZO gtvjvC8lQJYBeuZWZe2+qU1vK5fzOYj4zyzWvJwp8Odn8c/lyoOixV4Jgc23Ipv8wyORXL brvJu5WBo7ZvglUacrWfOaNBt5NGF1ac1ZNLbHjbdRHYXc77YPZtzVWiYGtUhA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=g4L+phxT; 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=1659007350; a=rsa-sha256; cv=none; b=n/yvJdaWMdnLAXGJlDHsM7hp33vGUY330jos9guyiwXTXts4lU9Zl/iMk4SengLTRAB2hE zrd8ZtKbZi0SMBT/uLENI5jjukRm9CU4j4zzu4Wj+7Wdp0qOiio+O5+0SXyhLRBO/sGsP0 2pnodBI2VgYQ17ZzTX9ywPppe/PBBwNdCP1VdvGNvaFVosGwM6QteCVOW2L/ATanVDgQGh 5m5oHQ9yGhAHPv/OAysLL7T+dolFr5FP49y+Yuj7epl8XCE1opo64fgExxT9XKeN6NC1C4 ShNRSs8VOY0f2aHgSo8ulenIyGxuFGgNrrwnmtzcT0xXPoPyBzYjWECvxX3DVg== X-Rspamd-Queue-Id: 4LtpCV0vGLz1Ll Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=g4L+phxT; 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.57 / 11.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81818751467824]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; MIME_HTML_ONLY(0.20)[]; R_SPF_ALLOW(-0.20)[+a:c]; IP_REPUTATION_HAM(-0.04)[asn: 50673(-0.03), country: NL(-0.01), ip: 178.21.23.139(0.00)]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; 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" - Make use of renewed status function in pakfire.cgi removing duplicate code Signed-off-by: Robin Roevens --- html/cgi-bin/pakfire.cgi | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index cb1272c63..42c603c61 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -43,6 +43,9 @@ my $PM_DEFAULT = 'default'; # Default user interface with command processing my $PM_LOGREAD = 'logread'; # Log messages viewer (ignores all commands) my $pagemode = $PM_DEFAULT; +# Get Pakfire status +my %pakfire_status = &Pakfire::status(); + # Load general settings &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings); @@ -84,7 +87,7 @@ if($cgiparams{'ACTION'} eq 'json-getstatus') { my %status = ( 'running' => &_is_pakfire_busy() || "0", 'running_since' => &General::age("$Pakfire::lockfile") || "0s", - 'reboot' => (-e "/var/run/need_reboot") || "0", + 'reboot' => ("$pakfire_status{'RebootRequired'}" eq "yes") || "0", 'failure' => $failure || "0" ); @@ -366,32 +369,26 @@ $selected{"TREE"}{"testing"} = ""; $selected{"TREE"}{"unstable"} = ""; $selected{"TREE"}{$pakfiresettings{"TREE"}} = "selected"; -my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`; -chomp($core_release); -my $core_update_age = &General::age("/opt/pakfire/db/core/mine"); -my $corelist_update_age = &General::age("/opt/pakfire/db/lists/core-list.db"); -my $server_update_age = &General::age("/opt/pakfire/db/lists/server-list.db"); -my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db"); - &Header::openbox("100%", "center", "Pakfire"); print < END -if ( -e "/var/run/need_reboot") { +if ("$pakfire_status{'RebootRequired'}" eq "yes") { print "\t\t$Lang::tr{'needreboot'}!\n"; } + print <$Lang::tr{'pakfire system state'}: $Lang::tr{'available updates'}: - $Lang::tr{'pakfire core update level'}: $core_release + $Lang::tr{'pakfire core update level'}: $pakfire_status{'Release'}
- $Lang::tr{'pakfire last update'} $core_update_age $Lang::tr{'pakfire ago'}
- $Lang::tr{'pakfire last serverlist update'} $server_update_age $Lang::tr{'pakfire ago'}
- $Lang::tr{'pakfire last core list update'} $corelist_update_age $Lang::tr{'pakfire ago'}
- $Lang::tr{'pakfire last package update'} $packages_update_age $Lang::tr{'pakfire ago'} + $Lang::tr{'pakfire last update'} $pakfire_status{'LastUpdate'} $Lang::tr{'pakfire ago'}
+ $Lang::tr{'pakfire last serverlist update'} $pakfire_status{'LastServerListUpdate'} $Lang::tr{'pakfire ago'}
+ $Lang::tr{'pakfire last core list update'} $pakfire_status{'LastCoreListUpdate'} $Lang::tr{'pakfire ago'}
+ $Lang::tr{'pakfire last package update'} $pakfire_status{'LastPakListUpdate'} $Lang::tr{'pakfire ago'}
@@ -403,14 +400,15 @@ print < END - my %coredb = &Pakfire::coredbinfo(); - if (defined $coredb{'AvailableRelease'}) { - print "\n"; + if ("$pakfire_status{'CoreUpdateAvailable'}" eq "yes") { + print "\n"; } - my %upgradelist = &Pakfire::dblist("upgrade"); - foreach my $pak (sort keys %upgradelist) { - print "\n"; + if ($pakfire_status{'PakUpdatesAvailable'} > 0) { + my %upgradelist = &Pakfire::dblist("upgrade"); + foreach my $pak (sort keys %upgradelist) { + print "\n"; + } } print < X-Patchwork-Id: 5776 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 4LtpCj0NnQz40W1 for ; Thu, 28 Jul 2022 11:22:41 +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 4LtpCb32PQz5SF; Thu, 28 Jul 2022 11:22:35 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCb2j4Xz2ys1; Thu, 28 Jul 2022 11:22:35 +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 4LtpCX1prmz2xPh for ; Thu, 28 Jul 2022 11:22:32 +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 4LtpCW1RKLz5RS for ; Thu, 28 Jul 2022 11:22:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id F2B6E40E71 for ; Thu, 28 Jul 2022 13:22:30 +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 dI-pTN734x_z for ; Thu, 28 Jul 2022 13:22:29 +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 54446560B9; 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=1659007341; bh=KP2g0p1gwNlNPkMiQGdoO5CTihSHt7iTvnkHLiniScw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eRVQN2QJ/7w72pGBSCxZ5z/TSVTOyQ1ETnKewiRnbVnrbKWCztsfmfxzOFUuDi+qz qapW0k/Q1i90jkMqlkkZthIbQGsYaaF/dzJiMcX+2cAmXHVxUi+JX644U3y77Pj4GQ 6VkzJDgUJY+emYxAuR3I3CIp39DagLoD6x5uQHz5CU3g5PssY5tuaWEllR2TgOS/GL TdHGDxjyVAkPo61ucKRhsrWKgfaUtLjF9HPkMhJMRMnPsn80Y89LbRq2TNVhZKti8w 1HGEu6dXVjHtu1JkK3GKaAAP1Chqxbb5jdIqVdbBpTGS0cuQf0zjeLAgjdF5Bl/c2O ZvhmNoDrJigPw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 09/10] pakfire: Add getmetadata function Date: Thu, 28 Jul 2022 13:21:35 +0200 Message-Id: <20220728112136.30218-10-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: 54446560B9.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.86485@q7qGGiU8/ukOlJ+YhOKjqw ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007351; 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=gGzmvg/zggJp99jGGGp+297Q5fANMiabgX2X1DMw56E=; b=JbjABVAWshOexmpl4XpteM4GcfMiCfm0rM49AxlH8KHe0oBIShJp4mHW4eictxArH5zj22 DYxBDcQ+XvWJwwwdihmNblH2y6kHwKSPUzWST/40AWm+HD025cekoSv6D/hqSYsTkcPt3N vQ2I9tjYr8IjBsiwv7/pBA4OQXPPBzBfYSM2V5V/qMAgUhhwt/e3PaSx8IeBJLrySRlvwn N/4e8oVfSSxKIpP0jdZjq0BPC6Wl8JxcrbPKNq9nAiUYwnhnjIWcikJ27R6UFJC08RkdGy 7i1G+qk5upkl/J3UlOrLwkMFlHPqgKHK/UbxYeRkKur+8+x+P1RfT4Xdw8LV1Q== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=eRVQN2QJ; 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=1659007351; a=rsa-sha256; cv=none; b=YX+0775hDK9tBGKIdolQkDC8qm6fMkRVxoW1C1uksZQ1YRNKmM4hYrl6LwOojcKR4IVcv3 9tQSN9hcls+IuDmn0YbROqeZ8fl3RNNQqF5y7im1ZZv7D93zvKzBflr/6q+FKGrs4jo+Bf UrGeub/ya9Wyayx2BlJl4VNSAaPfR102zbLaEyBrfr94TlLfS4MD7BeyeVLxpyPl6CTRIU QDuim/muLxUe/NvXM8gXEa3B+V+d7kku6qj5hkBy7sIN5orpOHwg9YVIGu8/tNufoiU9Hw CA7ClngxVK6ZJqEvINIP7M96fqv8cJzAku34+K+3UGr3yLFfCn1rRWV/iWkFtw== X-Rspamd-Queue-Id: 4LtpCW1RKLz5RS Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=eRVQN2QJ; 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.87 / 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.81818758120783]; 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]; IP_REPUTATION_HAM(-0.04)[asn: 50673(-0.03), country: NL(-0.01), ip: 178.21.23.139(0.00)]; MX_GOOD(-0.01)[]; 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 new getmetadata function for easy access to all available metadata of a pak without knowledge about or need to parse pakfire internal db files. - Added new 'pakfire info' functionality for displaying all available metadata of (a) pak(s) to the user, using the new getmetadata. Signed-off-by: Robin Roevens --- src/pakfire/lib/functions.pl | 55 ++++++++++++++++++++++++++++++++++ src/pakfire/pakfire | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index f87589bc4..1ebf98775 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -115,6 +115,7 @@ sub usage { &Pakfire::message(" - Contacts the servers for new lists of paks."); &Pakfire::message(" - Installs the latest version of all paks."); &Pakfire::message(" [installed/notinstalled/upgrade] - Outputs a list with all, installed, available or upgradeable paks."); + &Pakfire::message(" [ ...] - Output pak metadata."); &Pakfire::message(" - Outputs a summary about available core upgrades, updates and a required reboot"); &Pakfire::message(""); &Pakfire::message(" Global options:"); @@ -706,6 +707,60 @@ sub parsemetafile { return %metadata; } +sub getmetadata { + ### This subroutine returns a hash of available info for a package + # Pass package name and type of info as argument: Pakfire::getmetadata(package, type_of_info) + # Type_of_info can be "latest" or "installed" + # Usage is always with two argument. + my ($pak, $type) = @_; + + my %metadata = ( + Name => $pak, + Installed => "no", + Available => "no"); + my %installed_metadata = (); + + my @templine; + my @file; + + ### Get available version information + if ("$type" eq "latest") { + ### Check if package is in packages_list and get latest available version + my %db = Pakfire::dblist("all"); + + if (defined $db{$pak}) { + ### Get and parse latest available metadata + if (getmetafile("$pak")) { + %metadata = parsemetafile("$Conf::dbdir/meta/meta-$pak"); + + $metadata{'Available'} = "yes"; + ### Rename version info fields + $metadata{'AvailableProgVersion'} = delete $metadata{'ProgVersion'}; + $metadata{'AvailableRelease'} = delete $metadata{'Release'}; + } + } + } + + ### Parse installed pak metadata + if (&isinstalled($pak) == 0) { + %installed_metadata = parsemetafile("$Conf::dbdir/installed/meta-$pak"); + + if ("$type" eq "latest" && exists($metadata{'AvailableProgVersion'})) { + ### Add installed version info to latest metadata + $metadata{'ProgVersion'} = $installed_metadata{'ProgVersion'}; + $metadata{'Release'} = $installed_metadata{'Release'}; + } else { + ### Use metadata of installed pak + %metadata = %installed_metadata; + } + $metadata{'Installed'} = 'yes'; + } else { + $metadata{'Installed'} = 'no'; + } + + return %metadata; +} + sub decryptpak { my $pak = shift; diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 331204a00..389c1399d 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -393,6 +393,64 @@ exit 1; } } + } elsif ("$ARGV[0]" eq "info") { + shift; + + my @paks; + my $pak; + foreach $pak (@ARGV) { + unless ("$pak" =~ "^-") { + push(@paks,$pak); + } + } + + unless ("@paks") { + Pakfire::message("PAKFIRE ERROR: missing package name"); + Pakfire::usage; + exit 1; + } + + foreach $pak (@paks) { + my %metadata = Pakfire::getmetadata($pak, "latest"); + + ### Check if pakfile was actually found + if ($metadata{'Installed'} eq "no" && $metadata{'Available'} eq "no") { + Pakfire::message("PAKFIRE WARN: Pak '$pak' not found."); + last; + } + + unless (defined $metadata{'Available'}) { + Pakfire::message("PAKFIRE WARN: Unable to retrieve latest metadata for $pak. Information may be outdated.") + } + + ### Printout metadata in a user friendly format + print "Name: $metadata{'Name'}\n"; + print "Summary: $metadata{'Summary'}\n"; + if ($metadata{'Available'} eq "yes") { + print "Version: $metadata{'AvailableProgVersion'}-$metadata{'AvailableRelease'}\n"; + } else { + print "Version: $metadata{'ProgVersion'}-$metadata{'Release'}\n"; + } + print "Size: " . Pakfire::beautifysize("$metadata{'Size'}") . "\n"; + print "Dependencies: $metadata{'Dependencies'}\n"; + print "Pakfile: $metadata{'File'}\n"; + print "Service InitScripts: $metadata{'Services'}\n"; + print "Installed: $metadata{'Installed'}\n"; + ### Generate a pak status message + if (! defined $metadata{'Available'}) { + print "Status: unknown (an error occured retrieving latest pak metadata)"; + } elsif ($metadata{'Available'} eq "no") { + print "Status: obsolete (version $metadata{'ProgVersion'}-$metadata{'Release'} is installed)\n"; + } elsif ($metadata{'Installed'} eq "yes" && "$metadata{'Release'}" < "$metadata{'AvailableRelease'}") { + print "Status: outdated (version $metadata{'ProgVersion'}-$metadata{'Release'} is installed)\n"; + } elsif ($metadata{'Installed'} eq "yes") { + print "Status: up-to-date\n"; + } else { + print "Status: not installed\n"; + } + print "\n"; + } + } elsif ("$ARGV[0]" eq "resolvedeps") { foreach (@ARGV) { next if ("$_" eq "resolvedeps"); From patchwork Thu Jul 28 11:21:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5775 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 4LtpCh40vtz40Wb for ; Thu, 28 Jul 2022 11:22:40 +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 4LtpCY1sMZz5SH; Thu, 28 Jul 2022 11:22:33 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4LtpCY1cnnz2ygN; Thu, 28 Jul 2022 11:22:33 +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 4LtpCX0fHLz307D for ; Thu, 28 Jul 2022 11:22:32 +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 4LtpCV4hcmzy6 for ; Thu, 28 Jul 2022 11:22:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3379C40E71 for ; Thu, 28 Jul 2022 13:22:30 +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 mC5nCgkR6lml for ; Thu, 28 Jul 2022 13:22:29 +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 62122560BC; 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=1659007341; bh=/E9KwcDHIBWBdwnWmzdNoH7E4zY6rBeUZmU3bcqArYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M0Cr6VqMWcXmFxcQB2wLguMHIqA/zdeoAU4DB0vkGUnO8O51Oob1AOR67jRflnVFr Bjn1gnVKFaUnS92PcOOanwDPnLRQz9+FohmxqLTSGBNoLLMonfkqi7PP74D90yVHKn 36+FCkg5uw467ciLgGNxmd24OtOUKCO9rngb/CcA98hpj0zsgIJjAGjaUTSrgq/BMB wawHsk5aCpxNFfbW9VODCnTrH3hCGRfHVSZPOQMfbK8+smLilIgFBuhbNYmNjOFqCf 80MtCrYwTt7aNn7LssBmJUbn2o+z1Khsxt6jJ0hfYH2WCRUz63ji/293KZfJPVFTnL oXnVcttnEvisQ== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 10/10] pakfire: Replace getmetadata duplicate code Date: Thu, 28 Jul 2022 13:21:36 +0200 Message-Id: <20220728112136.30218-11-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: 62122560BC.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1659612114.81852@mVrn0HMcLIwF4JDzfJqWtg ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1659007350; 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=TrqKt7IjUBir9JfrCSVqHTaotH89uEoY7JW57+hNUwE=; b=hmxbsn/bisrizPFQ98zjC+4nZq80jDTLieQPNH3iaUu3Q8aQB7aYG4Aim3Kt8yhFyu3YDs Ww7K2j14l2rdPT7UNpwk9DnoSi29T9c2rEBC45lEO8TtOltSW1Wknl8zrg3RUqhUTZuYWy 7W/0eU71m3eaVUGUoDPh7NMmMHBKTK7C4jCse9hv7eYtrtKzhlTDhme50hKTj03pHAfsy1 SuIe5be94hp+7956WBiBdRahBmqaOqB2NGapi9d0kIf9eN9Q8aux+jj52N4VGAmveftVHg HSvSJWyuJpb6KK5XXbedg59PKCOk9nH+q/DTyI+QUv66mq/qkeZfgYXpc379rA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=M0Cr6VqM; 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=1659007350; a=rsa-sha256; cv=none; b=XyjQ+rPNTs3TGW/E9ySiCm0TpcotwcPw3EBB56Dbf9kXNelsis90uLtwyzp8I8HqdIMI18 g99UWR/dTJuppvB1HQAf6Yg4A9HCk8oe1h6nRqkSXlvO5u8EhHLm9opDqr8lwbsjqRHvDd X5oyG6oEDRI/cl5UwuFpls6gJxSrf08Gusk/Yz7r2Q8lrCwSZfhKxjPts+K2qmfRTAcUL6 bpRsiWkUwd8bFA5i2GZaQoKqROEG+DVvEpxhB17+93NG1M1/op4V1T2ViJi8al6KPeN26J WNnp6y1xb4ff+THBDbk8ErsPO8fJbtHpYvxxlclu6/aOzsdhb89NzuFV6BLiFA== X-Rspamd-Queue-Id: 4LtpCV4hcmzy6 Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=M0Cr6VqM; 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.57 / 11.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; SPF_REPUTATION_HAM(-0.82)[-0.81818758120783]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; MIME_HTML_ONLY(0.20)[]; R_SPF_ALLOW(-0.20)[+a:c]; IP_REPUTATION_HAM(-0.04)[asn: 50673(-0.03), country: NL(-0.01), ip: 178.21.23.139(0.00)]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; 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" - Use getmetadata function in services.cgi to determine installed addon services to display. Removing code duplication and intel that should only be known by pakfire itself. - Removed hardcoded exclusions: - squid should show up correctly using the new metadata info - mdadm is part of core and will never show up here - alsa, unknown if this problem still exists, but if it is, this should be handled somewhere else. Signed-off-by: Robin Roevens --- html/cgi-bin/services.cgi | 74 ++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index a1dcfd57e..29926ecc3 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -29,6 +29,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "${General::swroot}/graphs.pl"; +require "/opt/pakfire/lib/functions.pl"; my %color = (); my %mainsettings = (); @@ -160,51 +161,44 @@ END my $lines=0; # Used to count the outputlines to make different bgcolor - # Generate list of installed addon pak's - opendir (DIR, "/opt/pakfire/db/installed") || die "Cannot opendir /opt/pakfire/db/installed/: $!"; - my @pak = sort readdir DIR; - closedir(DIR); - - foreach (@pak){ - chomp($_); - next unless (m/^meta-/); - s/^meta-//; - - # Check which of the paks are services - if (-e "/etc/init.d/$_") { - # blacklist some packages - # - # alsa has trouble with the volume saving and was not really stopped - # mdadm should not stopped with webif because this could crash the system - # - if ( $_ eq 'squid' ) { - next; - } - if ( ($_ ne "alsa") && ($_ ne "mdadm") ) { - $lines++; - if ($lines % 2){ - print ""; - $col="bgcolor='$color{'color22'}'"; - }else{ - print ""; - $col="bgcolor='$color{'color20'}'"; - } + my @paks; + my @addon_services; + + # Generate list of installed addon pak services + my %paklist = &Pakfire::dblist("installed"); - print "$_ "; - my $status = isautorun($_,$col); - print "$status "; - print "$Lang::tr{"; - print "$Lang::tr{ "; - my $status = &isrunningaddon($_,$col); - $status =~ s/\\[[0-1]\;[0-9]+m//g; - - chomp($status); - print "$status"; - print ""; + foreach my $pak (keys %paklist) { + my %metadata = &Pakfire::getmetadata($pak, "installed"); + + if ("$metadata{'Services'}") { + foreach my $service (split(/ /, "$metadata{'Services'}")) { + push(@addon_services, $service); } } } + foreach (@addon_services) { + $lines++; + if ($lines % 2){ + print ""; + $col="bgcolor='$color{'color22'}'"; + }else{ + print ""; + $col="bgcolor='$color{'color20'}'"; + } + print "$_ "; + my $status = isautorun($_,$col); + print "$status "; + print "$Lang::tr{"; + print "$Lang::tr{ "; + my $status = isrunningaddon($_,$col); + $status =~ s/\\[[0-1]\;[0-9]+m//g; + + chomp($status); + print "$status"; + print ""; + } + print "\n"; &Header::closebox();