]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
pakfire: Replace duplicate code with dblist functioncall
authorRobin Roevens <robin.roevens@disroot.org>
Thu, 28 Jul 2022 11:21:29 +0000 (13:21 +0200)
committerPeter Müller <peter.mueller@ipfire.org>
Thu, 28 Jul 2022 13:44:29 +0000 (13:44 +0000)
Replace pakfire install code duplicating dblist working with call
to actual dblist function.

Signed-off-by: Robin Roevens <robin.roevens@disroot.org>
src/pakfire/pakfire

index b4930e85da2bdcbe004b50847bf153a0c5120b6f..f23110cf5da04198b81cd219e22330f4ce047933 100644 (file)
                ### Make sure that the list is not outdated.
                &Pakfire::dbgetlist("noforce");
 
-               open(FILE, "<$Conf::dbdir/lists/packages_list.db");
-               my @db = <FILE>;
-               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\".");
                                }