Pakfire laedt die Listen jetzt besser und hat eine veraenderte Oberflaeche bekommen.

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@852 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2007-08-29 10:14:06 +00:00
parent 7d01d5256d
commit 377560fbff
4 changed files with 120 additions and 58 deletions

View File

@@ -111,11 +111,13 @@ sub pinghost {
sub fetchfile {
my $getfile = shift;
my $gethost = shift;
my (@server, $host, $proto, $file, $allok, $i);
my (@server, $host, $proto, $file, $i);
my $allok = 0;
logger("DOWNLOAD STARTED: $getfile") unless ($bfile =~ /^counter\?.*/);
use File::Basename;
$bfile = basename("$getfile");
logger("DOWNLOAD STARTED: $getfile") unless ($bfile =~ /^counter\?.*/);
$i = 0;
while (($allok == 0) && $i < 5) {
@@ -210,40 +212,46 @@ sub fetchfile {
}
sub getmirrors {
my $force = shift;
my $age;
use File::Copy;
logger("MIRROR: Trying to get a mirror list.");
if ( -e "$Conf::dbdir/lists/server-list.db" ) {
my @stat = stat("$Conf::dbdir/lists/server-list.db");
my $time = time();
$age = $time - $stat[9];
$force = "force" if ("$age" >= "3600");
logger("MIRROR INFO: server-list.db is $age seconds old. - DEBUG: $force");
} else {
# Force an update.
$age = "86401";
$force = "force";
}
if ("$age" gt "86400") {
if ("$force" eq "force") {
fetchfile("$Conf::version/lists/server-list.db", "$Conf::mainserver");
move("$Conf::cachedir/server-list.db", "$Conf::dbdir/lists/server-list.db");
}
}
sub getcoredb {
my $force = shift;
my $age;
use File::Copy;
logger("CORE: Trying to get a core list.");
if ( -e "$Conf::dbdir/lists/core-list.db" ) {
my @stat = stat("$Conf::dbdir/lists/core-list.db");
my $time = time();
$age = $time - $stat[9];
$force = "force" if ("$age" >= "3600");
logger("CORE INFO: core-list.db is $age seconds old. - DEBUG: $force");
} else {
# Force an update.
$age = "3601";
$force = "force";
}
if ("$age" gt "3600") {
if ("$force" eq "force") {
fetchfile("lists/core-list.db", "");
move("$Conf::cachedir/core-list.db", "$Conf::dbdir/lists/core-list.db");
}
@@ -256,7 +264,7 @@ sub selectmirror {
my $count = 0;
while (!(open(FILE, "<$Conf::dbdir/lists/server-list.db")) && ($count lt 5)) {
$count++;
getmirrors();
getmirrors("noforce");
}
if ($count == 5) {
message("MIRROR ERROR: Could not find or download a server list");
@@ -315,12 +323,14 @@ sub dbgetlist {
my @stat = stat("$Conf::dbdir/lists/packages_list.db");
my $time = time();
$age = $time - $stat[9];
$force = "force" if ("$age" >= "3600");
logger("DB INFO: packages_list.db is $age seconds old. - DEBUG: $force");
} else {
# Force an update.
$age = "3601";
$force = "force";
}
if (("$age" gt "3600") || ("$force" eq "force")) {
if ("$force" eq "force") {
fetchfile("lists/packages_list.db", "");
move("$Conf::cachedir/packages_list.db", "$Conf::dbdir/lists/packages_list.db");
}
@@ -342,14 +352,14 @@ sub dblist {
my @templine;
### Make sure that the list is not outdated.
dbgetlist("noforce");
#dbgetlist("noforce");
open(FILE, "<$Conf::dbdir/lists/packages_list.db");
my @db = <FILE>;
close(FILE);
if ("$filter" eq "upgrade") {
getcoredb();
getcoredb("noforce");
eval(`grep "core_" $Conf::dbdir/lists/core-list.db`);
if ("$core_release" gt "$Conf::core_mine") {
if ("$forweb" eq "forweb") {
@@ -631,7 +641,7 @@ sub setuppak {
}
sub upgradecore {
getcoredb();
getcoredb("noforce");
eval(`grep "core_" $Conf::dbdir/lists/core-list.db`);
if ("$core_release" gt "$Conf::core_mine") {
message("CORE UPGR: Upgrading from release $Conf::core_mine to $core_release");

View File

@@ -3,6 +3,7 @@
require "/opt/pakfire/lib/functions.pl";
my $interactive = 1;
my $force = "noforce";
&Pakfire::logger("PAKFIRE INFO: IPFire Pakfire $Conf::version started!");
&Pakfire::checkcryptodb;
@@ -45,6 +46,10 @@
# Turn off shell colors - Bad for displaying in webinterface
$Pakfire::enable_colors = 0 if ("$_" eq "--no-colors");
# Turn on force mode
$force = "force" if ("$_" eq "-f" );
$force = "force" if ("$_" eq "--force" );
}
}
@@ -207,9 +212,9 @@
} elsif ("$ARGV[0]" eq "update") {
&Pakfire::makeuuid();
&Pakfire::senduuid();
&Pakfire::getmirrors();
&Pakfire::dbgetlist("noforce");
&Pakfire::getcoredb();
&Pakfire::getmirrors("$force");
&Pakfire::dbgetlist("$force");
&Pakfire::getcoredb("$force");
} elsif ("$ARGV[0]" eq "upgrade") {
&Pakfire::upgradecore();
@@ -259,6 +264,18 @@
next if ("$_" =~ "^-");
&Pakfire::resolvedeps("$_");
}
} elsif ("$ARGV[0]" eq "enable") {
if ("$ARGV[1]" eq "updates") {
system("ln -s ../../opt/pakfire/pakfire /etc/fcron.daily/pakfire-update");
elsif ("$ARGV[1]" eq "upgrades") {
system("ln -s ../../opt/pakfire/pakfire /etc/fcron.daily/pakfire-upgrade");
}
} elsif ("$ARGV[0]" eq "disable") {
if ("$ARGV[1]" eq "updates") {
system("rm -f /etc/fcron.daily/pakfire-update");
elsif ("$ARGV[1]" eq "upgrades") {
system("rm -f /etc/fcron.daily/pakfire-upgrade");
}
} else {
&Pakfire::usage;
}