Samba-Update auf neues Patchlevel. Jaja, die Sicherheitsluecken oder sowas...
[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::logger("### IPFire Pakfire $Conf::version started!");
8         &Pakfire::checkcryptodb;
9
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) {
20                 &Pakfire::usage;
21         }
22         
23         foreach (@ARGV) {
24                 if ("$_" =~ "^-") {
25                         $interactive = 0 if ("$_" eq "--non-interactive");
26                         $interactive = 0 if ("$_" eq "-y");
27                 }
28         }
29
30         if ("$ARGV[0]" eq "install") {
31                 &Pakfire::lock("on");
32                 shift;
33                 my @deps;
34                 my @paks;
35                 my @temp;
36                 my @all;
37                 foreach (@ARGV) {
38                         unless ("$_" =~ "^-") {
39                                 push(@paks,$_) if $_;
40                         }
41                 }
42                 
43                 foreach (@paks) {
44                         @temp = &Pakfire::resolvedeps("$_");
45                         foreach (@temp) { push(@deps,$_) if $_; }
46                 }
47                 
48                 foreach (@paks) {
49                   push(@all,$_) if $_;
50                 }
51                 foreach (@deps) {
52                   push(@all,$_) if $_;
53                 }
54
55                 &Pakfire::message("\n\n### Packages to install:");
56                 foreach (sort @paks) {
57                   my $size = &Pakfire::getsize("$_");
58                         $size = &Pakfire::beautifysize($size);
59                   &Pakfire::message("# $_  \t\t - $size");
60                 }
61                 
62                 &Pakfire::message("\n### Packages to install for dependencies:") if @deps;
63                 foreach (sort @deps) {
64                   my $size = &Pakfire::getsize("$_");
65                         $size = &Pakfire::beautifysize($size);
66                   &Pakfire::message("# $_  \t\t - $size");
67                 }
68                 
69                 my $totalsize;
70                 foreach (@all) {
71                         $totalsize = ($totalsize + &Pakfire::getsize("$_"));
72                 }
73                 $totalsize = &Pakfire::beautifysize($totalsize);
74                 &Pakfire::message("\n### Total size: \t ~ $totalsize\n");
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                 }
86
87                 ### Download first
88                 foreach (sort @all) {
89                         &Pakfire::message("# --> Downloading: $_");
90                         &Pakfire::getpak("$_", "");
91                 }
92
93                 foreach (sort @all) {
94                         &Pakfire::setuppak("$_");
95                 }
96                 &Pakfire::lock("off");
97                 
98         } elsif ("$ARGV[0]" eq "remove") {
99         
100         
101         } elsif ("$ARGV[0]" eq "update") {
102                 my $force = "noforce";
103                 &Pakfire::makeuuid();
104                 &Pakfire::senduuid();
105                 &Pakfire::getmirrors();
106                 $force = "force" if ("$ARGV[1]" eq "--force");
107                 &Pakfire::dbgetlist("$force");
108                 
109         
110         } elsif ("$ARGV[0]" eq "upgrade") {
111                 &Pakfire::dblist("upgrade", "noweb");
112                 
113         } elsif ("$ARGV[0]" eq "list") {
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;
124         }