Pakfire holt nun Systemupdates.

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@751 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2007-08-09 16:04:04 +00:00
parent 17487f44fd
commit 2aa6d448d1
5 changed files with 64 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ etc/fcron.daily/pakfire-update
#opt/pakfire
opt/pakfire/cache
#opt/pakfire/db
opt/pakfire/db/core
opt/pakfire/db/installed
opt/pakfire/db/lists
opt/pakfire/db/meta

View File

@@ -51,7 +51,7 @@ md5 :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
@$(PREBUILD)
@rm -rf $(DIR_APP)
-mkdir -p /opt/pakfire/{db/{meta,lists,rootfiles,installed},etc,lib,tmp} \
-mkdir -p /opt/pakfire/{db/{meta,lists,rootfiles,installed,core},etc,lib,tmp} \
/var/log/pakfire /var/cache/pakfire
cp -fRv $(DIR_SRC)/src/pakfire/* $(DIR_APP)
mv -vf $(DIR_APP)/pakfire.conf $(DIR_APP)/etc/

View File

@@ -214,8 +214,8 @@ sub getmirrors {
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");
if ( -e "$Conf::dbdir/lists/server-list.db" ) {
my @stat = stat("$Conf::dbdir/lists/server-list.db");
my $time = time();
$age = $time - $stat[9];
} else {
@@ -229,6 +229,27 @@ sub getmirrors {
}
}
sub getcoredb {
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];
} else {
# Force an update.
$age = "3601";
}
if ("$age" gt "3600") {
fetchfile("lists/core-list.db", "");
move("$Conf::cachedir/core-list.db", "$Conf::dbdir/lists/core-list.db");
}
}
sub selectmirror {
### Check if there is a current server list and read it.
# If there is no list try to get one.
@@ -296,10 +317,10 @@ sub dbgetlist {
$age = $time - $stat[9];
} else {
# Force an update.
$age = "86401";
$age = "3601";
}
if (("$age" gt "86400") || ("$force" eq "force")) {
if (("$age" gt "3600") || ("$force" eq "force")) {
fetchfile("lists/packages_list.db", "");
move("$Conf::cachedir/packages_list.db", "$Conf::dbdir/lists/packages_list.db");
}
@@ -594,6 +615,32 @@ sub setuppak {
return $return;
}
sub upgradecore {
getcoredb();
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");
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");
} else {
message("CORE ERROR: No new upgrades available. You are on release $Conf::core_mine.");
}
}
sub isinstalled {
my $pak = shift;
if ( open(FILE,"<$Conf::dbdir/installed/meta-$pak") ) {

View File

@@ -208,9 +208,11 @@
&Pakfire::makeuuid();
&Pakfire::senduuid();
&Pakfire::getmirrors();
&Pakfire::dbgetlist("force");
&Pakfire::dbgetlist("noforce");
&Pakfire::getcoredb();
} elsif ("$ARGV[0]" eq "upgrade") {
&Pakfire::upgradecore();
my @upgradepaks = &Pakfire::dblist("upgrade", "noweb");
my @temp;

View File

@@ -8,6 +8,7 @@ $mainserver = "pakfire.ipfire.org";
$cachedir = "/opt/pakfire/cache";
$dbdir = "/opt/pakfire/db";
$coredir = "/opt/pakfire/db/core";
$tmpdir = "/opt/pakfire/tmp";
$logdir = "/opt/pakfire/logs";
@@ -16,4 +17,11 @@ if ( -e "$dbdir/uuid" ) {
chomp($uuid);
}
if ( -e "$coredir/mine" ) {
$core_mine = `cat $coredir/mine`;
chomp($core_mine);
} else {
$core_mine = "0";
}
1;