]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/pakfire/pakfire
Fix core28 updater kernel version
[people/pmueller/ipfire-2.x.git] / src / pakfire / pakfire
index 9768836ea527976763f2cfb6a8d0833ee331b553..a9981fd8325f7f867d334d405b48a9895097237f 100644 (file)
@@ -1,4 +1,28 @@
 #!/usr/bin/perl
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+       ### Clean up our environment
+       #
+       delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)};
+       $< = $>;
 
        require "/opt/pakfire/lib/functions.pl";
        
        #
        if ( $0 =~ /pakfire-update$/ ) {
                &Pakfire::message("CRON INFO: Running an update");
+               my $random = int(rand(60));
+               &Pakfire::logger("CRON INFO: Waiting for $random seconds.");
+               sleep($random);
                $ARGV[0] = "update";
                $interactive = 0;
        } elsif ( $0 =~ /pakfire-upgrade$/ ) {
                &Pakfire::message("CRON INFO: Running an upgrade");
+               my $random = int(rand(3600));
+               &Pakfire::logger("CRON INFO: Waiting for $random seconds.");
+               sleep($random);
                $ARGV[0] = "upgrade";
                $interactive = 0;
        }
        } elsif ("$ARGV[0]" eq "upgrade") {
                &Pakfire::upgradecore();
                my @upgradepaks = &Pakfire::dblist("upgrade", "noweb");
-               my @temp;
+               my @temp, $pak;
                
                foreach (@upgradepaks) {
                        @temp = &Pakfire::resolvedeps("$_");
                }
                
                ### Download first
-               foreach (sort @upgradepaks) {
-                       &Pakfire::getpak("$_", "");
+               foreach $pak (sort @upgradepaks) {
+                       system("mv $Conf::dbdir/meta/meta-$pak $Conf::dbdir/meta/old-meta-$pak");
+                       &Pakfire::getpak("$pak", "");
                }
                
-               foreach (sort @upgradepaks) {
-                       &Pakfire::upgradepak("$_");
+               foreach $pak (sort @upgradepaks) {
+                       if (&Pakfire::upgradepak("$pak")) {
+                               system("mv $Conf::dbdir/meta/old-meta-$pak $Conf::dbdir/meta/meta-$pak");
+                       }
                }
                
        } elsif ("$ARGV[0]" eq "list") {
        } 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") {
+               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") {
+               elsif ("$ARGV[1]" eq "upgrades") {
                        system("rm -f /etc/fcron.daily/pakfire-upgrade");
                }
        } else {
                &Pakfire::usage;
        }
 
-&Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing.");
+       &Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing.");
 
-exit 0;
+       exit 0;