X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=src%2Fpakfire%2Fpakfire;h=da68454dc6646600cb401be62398734727f7bf59;hp=7ab6f7395c5f2767fea44e4618922b78f7576cd9;hb=d9c6f56c2ea171cbc1fa396feb30d2814b9a818d;hpb=750c1528a4f0234ffa757d1e1443ca66b000b53b diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 7ab6f7395c..da68454dc6 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -1,8 +1,33 @@ #!/usr/bin/perl +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2015 IPFire Team # +# # +# 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 . # +# # +############################################################################### + + ### Clean up our environment + # + delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)}; + $< = $>; require "/opt/pakfire/lib/functions.pl"; my $interactive = 1; + my $force = "noforce"; &Pakfire::logger("PAKFIRE INFO: IPFire Pakfire $Conf::version started!"); &Pakfire::checkcryptodb; @@ -25,10 +50,16 @@ # 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; } @@ -45,6 +76,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" ); } } @@ -101,26 +136,26 @@ exit 1; } - &Pakfire::message(""); - &Pakfire::message(""); - &Pakfire::message("PAKFIRE INFO: Packages to install:"); - foreach $pak (sort @paks) { - my $size = &Pakfire::getsize("$pak"); - $size = &Pakfire::beautifysize($size); - &Pakfire::message("PAKFIRE INFO: $pak \t - $size"); - } - if (@deps) { my %sort = map{ $_, 1 } @deps; - @deps = sort keys %sort; + @deps = keys %sort; &Pakfire::message(""); &Pakfire::message("PAKFIRE INFO: Packages to install for dependencies:"); } - foreach $dep (sort @deps) { + foreach $dep (@deps) { my $size = &Pakfire::getsize("$dep"); $size = &Pakfire::beautifysize($size); &Pakfire::message("PAKFIRE INFO: $dep \t - $size"); } + + &Pakfire::message(""); + &Pakfire::message(""); + &Pakfire::message("PAKFIRE INFO: Packages to install:"); + foreach $pak (@paks) { + my $size = &Pakfire::getsize("$pak"); + $size = &Pakfire::beautifysize($size); + &Pakfire::message("PAKFIRE INFO: $pak \t - $size"); + } my $totalsize; foreach $pak (@all) { @@ -144,26 +179,31 @@ &Pakfire::logger("PAKFIRE INFO: Interaction skipped."); } - my %sort = map{ $_, 1 } @all; - @all = sort keys %sort; +# my %sort = map{ $_, 1 } @all; +# @all = sort keys %sort; ### Download first - foreach $pak (sort @all) { + foreach $pak (@all) { &Pakfire::getpak("$pak", ""); } &Pakfire::message(""); - foreach $pak (sort @all) { + foreach $pak (@deps) { + &Pakfire::setuppak("$pak") if ($pak ne ""); + } + + + foreach $pak (@paks) { &Pakfire::setuppak("$pak") if ($pak ne ""); } + } elsif ("$ARGV[0]" eq "remove") { shift; my @paks; my $pak; - foreach $pak (@ARGV) { unless ("$pak" =~ "^-") { $return = &Pakfire::isinstalled($pak); @@ -171,9 +211,7 @@ &Pakfire::message("PAKFIRE WARN: $pak is not installed"); next; } - push(@paks, $pak); - } } @@ -208,24 +246,21 @@ } elsif ("$ARGV[0]" eq "update") { - my $force = "noforce"; &Pakfire::makeuuid(); &Pakfire::senduuid(); - &Pakfire::getmirrors(); - $force = "force" if ("$ARGV[1]" eq "--force"); + &Pakfire::getmirrors("$force"); &Pakfire::dbgetlist("$force"); - - + &Pakfire::getcoredb("$force"); + } elsif ("$ARGV[0]" eq "upgrade") { + &Pakfire::upgradecore(); my @upgradepaks = &Pakfire::dblist("upgrade", "noweb"); - my @temp; - - foreach (@upgradepaks) { - @temp = &Pakfire::resolvedeps("$_"); - foreach (@temp) { push(@upgradepaks,$_) if $_; } - } - + my @deps = (); + if (@upgradepaks) { + # Resolve the dependencies of the to be upgraded packages + @deps = &Pakfire::resolvedeps_recursive(@upgradepaks); + &Pakfire::message(""); &Pakfire::message("PAKFIRE UPGR: We are going to install all packages listed above."); if ($interactive) { @@ -240,17 +275,33 @@ } } - ### Download first - foreach (sort @upgradepaks) { - &Pakfire::getpak("$_", ""); + # Download packages + foreach $pak (@upgradepaks) { + &Pakfire::getpak("$pak", ""); } - - foreach (sort @upgradepaks) { - &Pakfire::upgradepak("$_"); + + # Download dependencies + foreach $pak (@deps) { + &Pakfire::getpak("$pak", ""); + } + + # Install dependencies first + foreach $pak (@deps) { + &Pakfire::setuppak("$pak"); + } + + # Install all upgrades + foreach $pak (@upgradepaks) { + &Pakfire::upgradepak("$pak"); } } elsif ("$ARGV[0]" eq "list") { - &Pakfire::dblist("all", "noweb"); + if ("$ARGV[1]" =~ /installed|notinstalled/) { + &Pakfire::dblist("$ARGV[1]", "noweb"); + } else { + &Pakfire::message("PAKFIRE WARN: Not a known option $ARGV[1]") if ($ARGV[1]); + &Pakfire::dblist("all", "noweb"); + } } elsif ("$ARGV[0]" eq "resolvedeps") { foreach (@ARGV) { @@ -258,10 +309,22 @@ 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; } -&Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing."); + &Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing."); -exit 0; + exit 0;