Samba-Update auf neues Patchlevel. Jaja, die Sicherheitsluecken oder sowas...
[ipfire-2.x.git] / src / pakfire / pakfire
CommitLineData
c3df33af 1#!/usr/bin/perl
c1ae1ad6 2
1bd42c89
MT
3 require "/opt/pakfire/lib/functions.pl";
4
5 my $interactive = 1;
6
afabe9f7 7 &Pakfire::logger("### IPFire Pakfire $Conf::version started!");
cde0e116 8 &Pakfire::checkcryptodb;
c1ae1ad6 9
1bd42c89
MT
10 ### Check if we are running as root
11 #
12 my $user = qx(whoami);
13 chomp($user);
14 unless ( "$user" eq "root" ) {
15 &Pakfire::message("You must run pakfire as user root!");
16 exit 1;
17 }
18
19 unless (@ARGV) {
5b2a12ff 20 &Pakfire::usage;
1bd42c89 21 }
4b122800
MT
22
23 foreach (@ARGV) {
24 if ("$_" =~ "^-") {
25 $interactive = 0 if ("$_" eq "--non-interactive");
26 $interactive = 0 if ("$_" eq "-y");
27 }
28 }
c1ae1ad6 29
1bd42c89 30 if ("$ARGV[0]" eq "install") {
5b2a12ff 31 &Pakfire::lock("on");
1bd42c89 32 shift;
a08c3a2e
MT
33 my @deps;
34 my @paks;
35 my @temp;
4b122800 36 my @all;
1bd42c89 37 foreach (@ARGV) {
4b122800
MT
38 unless ("$_" =~ "^-") {
39 push(@paks,$_) if $_;
5b2a12ff 40 }
a08c3a2e 41 }
4b122800 42
a08c3a2e
MT
43 foreach (@paks) {
44 @temp = &Pakfire::resolvedeps("$_");
45 foreach (@temp) { push(@deps,$_) if $_; }
1bd42c89
MT
46 }
47
1bd42c89 48 foreach (@paks) {
4b122800 49 push(@all,$_) if $_;
1bd42c89
MT
50 }
51 foreach (@deps) {
4b122800 52 push(@all,$_) if $_;
1bd42c89 53 }
97520ed5 54
1bd42c89 55 &Pakfire::message("\n\n### Packages to install:");
a08c3a2e 56 foreach (sort @paks) {
1bd42c89
MT
57 my $size = &Pakfire::getsize("$_");
58 $size = &Pakfire::beautifysize($size);
59 &Pakfire::message("# $_ \t\t - $size");
60 }
61
4b122800 62 &Pakfire::message("\n### Packages to install for dependencies:") if @deps;
a08c3a2e 63 foreach (sort @deps) {
1bd42c89
MT
64 my $size = &Pakfire::getsize("$_");
65 $size = &Pakfire::beautifysize($size);
66 &Pakfire::message("# $_ \t\t - $size");
67 }
4b122800
MT
68
69 my $totalsize;
70 foreach (@all) {
71 $totalsize = ($totalsize + &Pakfire::getsize("$_"));
72 }
1bd42c89 73 $totalsize = &Pakfire::beautifysize($totalsize);
4b122800 74 &Pakfire::message("\n### Total size: \t ~ $totalsize\n");
1bd42c89
MT
75
76 if ($interactive) {
77 &Pakfire::message("Is this okay? [y/N]");
78 my $ret = <STDIN>;
79 chomp($ret);
80 &Pakfire::logger("Answer: $ret");
81 if ( $ret ne "y" ) {
82 &Pakfire::message("Installation aborted.");
83 exit 1;
84 }
85 }
a08c3a2e
MT
86
87 ### Download first
88 foreach (sort @all) {
89 &Pakfire::message("# --> Downloading: $_");
90 &Pakfire::getpak("$_", "");
91 }
c1ae1ad6 92
a08c3a2e 93 foreach (sort @all) {
1bd42c89
MT
94 &Pakfire::setuppak("$_");
95 }
5b2a12ff 96 &Pakfire::lock("off");
1bd42c89
MT
97
98 } elsif ("$ARGV[0]" eq "remove") {
99
100
101 } elsif ("$ARGV[0]" eq "update") {
5b2a12ff 102 my $force = "noforce";
8e58bd37
MT
103 &Pakfire::makeuuid();
104 &Pakfire::senduuid();
c3df33af 105 &Pakfire::getmirrors();
5b2a12ff
MT
106 $force = "force" if ("$ARGV[1]" eq "--force");
107 &Pakfire::dbgetlist("$force");
afabe9f7 108
4b122800
MT
109
110 } elsif ("$ARGV[0]" eq "upgrade") {
111 &Pakfire::dblist("upgrade", "noweb");
112
afabe9f7 113 } elsif ("$ARGV[0]" eq "list") {
5b2a12ff
MT
114 &Pakfire::dblist("all", "noweb");
115
116 } elsif ("$ARGV[0]" eq "resolvedeps") {
117 foreach (@ARGV) {
118 next if ("$_" eq "resolvedeps");
119 &Pakfire::resolvedeps("$_");
120 }
121
122 } else {
123 &Pakfire::usage;
1bd42c89 124 }