Kleine Fixes am Pakfire - brauche Binary.
[people/pmueller/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!");
c1ae1ad6 8
1bd42c89
MT
9 ### Check if we are running as root
10 #
11 my $user = qx(whoami);
12 chomp($user);
13 unless ( "$user" eq "root" ) {
14 &Pakfire::message("You must run pakfire as user root!");
15 exit 1;
16 }
17
18 unless (@ARGV) {
19 &Pakfire::message("Usage: pakfire <install|remove> <pak(s)>");
20 &Pakfire::message(" <update>");
21 &Pakfire::message(" <upgrade>");
22 exit 1;
23 }
c1ae1ad6 24
1bd42c89
MT
25 if ("$ARGV[0]" eq "install") {
26 shift;
a08c3a2e
MT
27 my @deps;
28 my @paks;
29 my @temp;
1bd42c89 30 foreach (@ARGV) {
a08c3a2e
MT
31 push(@paks,$_);
32 }
33 foreach (@paks) {
34 @temp = &Pakfire::resolvedeps("$_");
35 foreach (@temp) { push(@deps,$_) if $_; }
1bd42c89
MT
36 }
37
a08c3a2e 38 my @all;
1bd42c89
MT
39 foreach (@paks) {
40 push(@all,$_);
41 }
42 foreach (@deps) {
43 push(@all,$_);
44 }
97520ed5 45
1bd42c89 46 &Pakfire::message("\n\n### Packages to install:");
a08c3a2e 47 foreach (sort @paks) {
1bd42c89
MT
48 my $size = &Pakfire::getsize("$_");
49 $size = &Pakfire::beautifysize($size);
50 &Pakfire::message("# $_ \t\t - $size");
51 }
52
53 &Pakfire::message("\n### Packages to install for dependencies:");
a08c3a2e 54 foreach (sort @deps) {
1bd42c89
MT
55 my $size = &Pakfire::getsize("$_");
56 $size = &Pakfire::beautifysize($size);
57 &Pakfire::message("# $_ \t\t - $size");
58 }
97520ed5 59
a08c3a2e 60 my $totalsize = &Pakfire::addsizes("@all");
1bd42c89
MT
61 $totalsize = &Pakfire::beautifysize($totalsize);
62 &Pakfire::message("\n### Download size: \t ~ $totalsize");
63
64 if ($interactive) {
65 &Pakfire::message("Is this okay? [y/N]");
66 my $ret = <STDIN>;
67 chomp($ret);
68 &Pakfire::logger("Answer: $ret");
69 if ( $ret ne "y" ) {
70 &Pakfire::message("Installation aborted.");
71 exit 1;
72 }
73 }
74
75 &Pakfire::message("### Installing all packages:");
a08c3a2e
MT
76 foreach (sort @all) { &Pakfire::message("# --> $_"); }
77 &Pakfire::message("");
78
79 ### Download first
80 foreach (sort @all) {
81 &Pakfire::message("# --> Downloading: $_");
82 &Pakfire::getpak("$_", "");
83 }
c1ae1ad6 84
a08c3a2e 85 foreach (sort @all) {
1bd42c89
MT
86 &Pakfire::setuppak("$_");
87 }
c1ae1ad6 88
1bd42c89
MT
89
90 } elsif ("$ARGV[0]" eq "remove") {
91
92
93 } elsif ("$ARGV[0]" eq "update") {
8e58bd37
MT
94 &Pakfire::makeuuid();
95 &Pakfire::senduuid();
c3df33af 96 &Pakfire::getmirrors();
afabe9f7
MT
97
98 } elsif ("$ARGV[0]" eq "list") {
99 &Pakfire::dblist("noweb");
1bd42c89 100 }