From 2aa6d448d1f3321e0b016b58401d83da94c4fa65 Mon Sep 17 00:00:00 2001 From: ms Date: Thu, 9 Aug 2007 16:04:04 +0000 Subject: [PATCH] Pakfire holt nun Systemupdates. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@751 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/rootfiles/ver_full/pakfire | 1 + lfs/pakfire | 2 +- src/pakfire/lib/functions.pl | 55 ++++++++++++++++++++++++++++--- src/pakfire/pakfire | 4 ++- src/pakfire/pakfire.conf | 8 +++++ 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/config/rootfiles/ver_full/pakfire b/config/rootfiles/ver_full/pakfire index 5dddca4cf..e66ca6ea8 100644 --- a/config/rootfiles/ver_full/pakfire +++ b/config/rootfiles/ver_full/pakfire @@ -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 diff --git a/lfs/pakfire b/lfs/pakfire index f09d18fde..d953da546 100644 --- a/lfs/pakfire +++ b/lfs/pakfire @@ -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/ diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 46297ccb3..337016286 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -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") ) { diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 750e6e00b..d262ac384 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -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; diff --git a/src/pakfire/pakfire.conf b/src/pakfire/pakfire.conf index 5c758e997..b7bed9c6b 100644 --- a/src/pakfire/pakfire.conf +++ b/src/pakfire/pakfire.conf @@ -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; -- 2.39.2