Pakfire Fixes.
[people/pmueller/ipfire-2.x.git] / src / pakfire / pakfire
1 #!/usr/bin/perl
2
3 require "/opt/pakfire/lib/functions.pl";
4
5 my $interactive = 1;
6
7 &Pakfire::message("### Welcome to IPFire Pakfire $Conf::version!");
8
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 }
24
25 if ("$ARGV[0]" eq "install") {
26 shift;
27 my @deps = ();
28 my @paks = @ARGV;
29 foreach (@ARGV) {
30 @deps = &Pakfire::resolvedeps("$_");
31 }
32
33 my @all = ();
34 foreach (@paks) {
35 push(@all,$_);
36 }
37 foreach (@deps) {
38 push(@all,$_);
39 }
40
41 &Pakfire::message("\n\n### Packages to install:");
42 foreach (@paks) {
43 my $size = &Pakfire::getsize("$_");
44 $size = &Pakfire::beautifysize($size);
45 &Pakfire::message("# $_ \t\t - $size");
46 }
47
48 &Pakfire::message("\n### Packages to install for dependencies:");
49 foreach (@deps) {
50 my $size = &Pakfire::getsize("$_");
51 $size = &Pakfire::beautifysize($size);
52 &Pakfire::message("# $_ \t\t - $size");
53 }
54
55 my $totalsize = &Pakfire::addsizes(@all);
56 $totalsize = &Pakfire::beautifysize($totalsize);
57 &Pakfire::message("\n### Download size: \t ~ $totalsize");
58
59 if ($interactive) {
60 &Pakfire::message("Is this okay? [y/N]");
61 my $ret = <STDIN>;
62 chomp($ret);
63 &Pakfire::logger("Answer: $ret");
64 if ( $ret ne "y" ) {
65 &Pakfire::message("Installation aborted.");
66 exit 1;
67 }
68 }
69
70 &Pakfire::message("### Installing all packages:");
71
72 foreach (@all) {
73 &Pakfire::setuppak("$_");
74 }
75
76
77 } elsif ("$ARGV[0]" eq "remove") {
78
79
80 } elsif ("$ARGV[0]" eq "update") {
81 &Pakfire::getmirrors();
82 &Pakfire::dbgetlist();
83 }