Pakfire: Update also the meta db at package list update.
authorArne Fitzenreiter <arne_f@ipfire.org>
Mon, 2 Nov 2009 15:18:10 +0000 (16:18 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Mon, 2 Nov 2009 15:18:10 +0000 (16:18 +0100)
This prevent using old dependencies at package update.

config/rootfiles/core/33/filelists/files
src/pakfire/lib/functions.pl
src/pakfire/pakfire

index 0037af1..5bbe9c9 100644 (file)
@@ -1 +1,3 @@
 etc/system-release
+opt/pakfire/pakfire
+opt/pakfire/lib/functions.pl
index ff330b5..8d4a7da 100644 (file)
@@ -369,6 +369,51 @@ sub dbgetlist {
                fetchfile("lists/packages_list.db", "");
                move("$Conf::cachedir/packages_list.db", "$Conf::dbdir/lists/packages_list.db");
        }
+
+       # Update the meta database if new packages was in the package list
+       my @meta;
+       my $file;
+       my $line;
+       my $prog;
+       my ($name, $version, $release);
+       my @templine;
+
+       open(FILE, "<$Conf::dbdir/lists/packages_list.db");
+       my @db = <FILE>;
+       close(FILE);
+
+       opendir(DIR,"$Conf::dbdir/meta");
+       my @files = readdir(DIR);
+       closedir(DIR);
+       foreach $file (@files) {
+               next if ( $file eq "." );
+               next if ( $file eq ".." );
+               next if ( $file =~ /^old/ );
+               open(FILE, "<$Conf::dbdir/meta/$file");
+               @meta = <FILE>;
+               close(FILE);
+               foreach $line (@meta) {
+                       @templine = split(/\: /,$line);
+                       if ("$templine[0]" eq "Name") {
+                               $name = $templine[1];
+                               chomp($name);
+                       } elsif ("$templine[0]" eq "ProgVersion") {
+                               $version = $templine[1];
+                               chomp($version);
+                       } elsif ("$templine[0]" eq "Release") {
+                               $release = $templine[1];
+                               chomp($release);
+                       }
+               }
+               foreach $prog (@db) {
+                       @templine = split(/\;/,$prog);
+                       if (("$name" eq "$templine[0]") && ("$release" ne "$templine[2]")) {
+                               move("$Conf::dbdir/meta/meta-$name","$Conf::dbdir/meta/old_meta-$name");
+                               fetchfile("meta/meta-$name", "");
+                               move("$Conf::cachedir/meta-$name", "$Conf::dbdir/meta/meta-$name");
+                       }
+               }
+       }
 }
 
 sub dblist {
index 4201c25..3d0270a 100644 (file)
                
                ### Download first
                foreach $pak (@upgradepaks) {
-                       system("mv $Conf::dbdir/meta/meta-$pak $Conf::dbdir/meta/old-meta-$pak");
+                       #system("mv $Conf::dbdir/meta/meta-$pak $Conf::dbdir/meta/old-meta-$pak");
                        &Pakfire::getpak("$pak", "");
                }
                
                foreach $pak (@upgradepaks) {
                        if (&Pakfire::upgradepak("$pak")) {
-                               system("mv $Conf::dbdir/meta/old-meta-$pak $Conf::dbdir/meta/meta-$pak");
+                               #system("mv $Conf::dbdir/meta/old-meta-$pak $Conf::dbdir/meta/meta-$pak");
                        }
                }