commit und geh weg
[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!");
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 }
c1ae1ad6 22
1bd42c89 23 if ("$ARGV[0]" eq "install") {
5b2a12ff 24 &Pakfire::lock("on");
1bd42c89 25 shift;
a08c3a2e
MT
26 my @deps;
27 my @paks;
28 my @temp;
1bd42c89 29 foreach (@ARGV) {
5b2a12ff
MT
30 if ("$_" =~ "^--") {
31 $interactive = 0 if ("$_" eq "--non-interactive");
32 } else {
33 push(@paks,$_);
34 }
a08c3a2e
MT
35 }
36 foreach (@paks) {
37 @temp = &Pakfire::resolvedeps("$_");
38 foreach (@temp) { push(@deps,$_) if $_; }
1bd42c89
MT
39 }
40
a08c3a2e 41 my @all;
1bd42c89
MT
42 foreach (@paks) {
43 push(@all,$_);
44 }
45 foreach (@deps) {
46 push(@all,$_);
47 }
97520ed5 48
1bd42c89 49 &Pakfire::message("\n\n### Packages to install:");
a08c3a2e 50 foreach (sort @paks) {
1bd42c89
MT
51 my $size = &Pakfire::getsize("$_");
52 $size = &Pakfire::beautifysize($size);
53 &Pakfire::message("# $_ \t\t - $size");
54 }
55
56 &Pakfire::message("\n### Packages to install for dependencies:");
a08c3a2e 57 foreach (sort @deps) {
1bd42c89
MT
58 my $size = &Pakfire::getsize("$_");
59 $size = &Pakfire::beautifysize($size);
60 &Pakfire::message("# $_ \t\t - $size");
61 }
97520ed5 62
a08c3a2e 63 my $totalsize = &Pakfire::addsizes("@all");
1bd42c89
MT
64 $totalsize = &Pakfire::beautifysize($totalsize);
65 &Pakfire::message("\n### Download size: \t ~ $totalsize");
66
67 if ($interactive) {
68 &Pakfire::message("Is this okay? [y/N]");
69 my $ret = <STDIN>;
70 chomp($ret);
71 &Pakfire::logger("Answer: $ret");
72 if ( $ret ne "y" ) {
73 &Pakfire::message("Installation aborted.");
74 exit 1;
75 }
76 }
a08c3a2e
MT
77
78 ### Download first
79 foreach (sort @all) {
80 &Pakfire::message("# --> Downloading: $_");
81 &Pakfire::getpak("$_", "");
82 }
c1ae1ad6 83
a08c3a2e 84 foreach (sort @all) {
1bd42c89
MT
85 &Pakfire::setuppak("$_");
86 }
5b2a12ff 87 &Pakfire::lock("off");
1bd42c89
MT
88
89 } elsif ("$ARGV[0]" eq "remove") {
90
91
92 } elsif ("$ARGV[0]" eq "update") {
5b2a12ff 93 my $force = "noforce";
8e58bd37
MT
94 &Pakfire::makeuuid();
95 &Pakfire::senduuid();
c3df33af 96 &Pakfire::getmirrors();
5b2a12ff
MT
97 $force = "force" if ("$ARGV[1]" eq "--force");
98 &Pakfire::dbgetlist("$force");
afabe9f7
MT
99
100 } elsif ("$ARGV[0]" eq "list") {
5b2a12ff
MT
101 &Pakfire::dblist("all", "noweb");
102
103 } elsif ("$ARGV[0]" eq "resolvedeps") {
104 foreach (@ARGV) {
105 next if ("$_" eq "resolvedeps");
106 &Pakfire::resolvedeps("$_");
107 }
108
109 } else {
110 &Pakfire::usage;
1bd42c89 111 }