DHCP Webseite angepasst damit beim speichern auch die rc links gesetzt werden
[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 }
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;
99e6df8e
MT
33
34 ### Make sure that the list is not outdated.
35 &Pakfire::dbgetlist("noforce");
36
37 open(FILE, "<$Conf::dbdir/lists/packages_list.db");
38 my @db = <FILE>;
39 close(FILE);
40
41 my $dep;
a08c3a2e 42 my @deps;
99e6df8e 43 my $pak;
a08c3a2e
MT
44 my @paks;
45 my @temp;
99e6df8e
MT
46 my @templine;
47 my $found = 0;
4b122800 48 my @all;
99e6df8e
MT
49 foreach $pak (@ARGV) {
50 unless ("$pak" =~ "^-") {
51 $found = 0;
52 foreach (@db) {
53 @templine = split(/;/,$_);
54 if ("$templine[0]" eq "$pak" ) {
55 push(@paks,$pak);
56 push(@all,$pak);
57 @temp = &Pakfire::resolvedeps("$pak");
58 foreach $dep (@temp) {
59 push(@deps,$dep) if $dep;
60 push(@all,$dep) if $dep;
61 }
62 $found = 1;
63 break;
64 }
65 }
66 &Pakfire::message("\nThe pak \"$pak\" is not known. Please try running \"pakfire update\".") if ($found == 0);
5b2a12ff 67 }
a08c3a2e 68 }
97520ed5 69
1bd42c89 70 &Pakfire::message("\n\n### Packages to install:");
a08c3a2e 71 foreach (sort @paks) {
1bd42c89
MT
72 my $size = &Pakfire::getsize("$_");
73 $size = &Pakfire::beautifysize($size);
74 &Pakfire::message("# $_ \t\t - $size");
75 }
76
4b122800 77 &Pakfire::message("\n### Packages to install for dependencies:") if @deps;
a08c3a2e 78 foreach (sort @deps) {
1bd42c89
MT
79 my $size = &Pakfire::getsize("$_");
80 $size = &Pakfire::beautifysize($size);
81 &Pakfire::message("# $_ \t\t - $size");
82 }
4b122800
MT
83
84 my $totalsize;
85 foreach (@all) {
86 $totalsize = ($totalsize + &Pakfire::getsize("$_"));
87 }
1bd42c89 88 $totalsize = &Pakfire::beautifysize($totalsize);
4b122800 89 &Pakfire::message("\n### Total size: \t ~ $totalsize\n");
1bd42c89
MT
90
91 if ($interactive) {
92 &Pakfire::message("Is this okay? [y/N]");
93 my $ret = <STDIN>;
94 chomp($ret);
95 &Pakfire::logger("Answer: $ret");
96 if ( $ret ne "y" ) {
97 &Pakfire::message("Installation aborted.");
98 exit 1;
99 }
100 }
a08c3a2e
MT
101
102 ### Download first
103 foreach (sort @all) {
104 &Pakfire::message("# --> Downloading: $_");
105 &Pakfire::getpak("$_", "");
106 }
c1ae1ad6 107
a08c3a2e 108 foreach (sort @all) {
1bd42c89
MT
109 &Pakfire::setuppak("$_");
110 }
5b2a12ff 111 &Pakfire::lock("off");
1bd42c89
MT
112
113 } elsif ("$ARGV[0]" eq "remove") {
114
115
116 } elsif ("$ARGV[0]" eq "update") {
5b2a12ff 117 my $force = "noforce";
8e58bd37
MT
118 &Pakfire::makeuuid();
119 &Pakfire::senduuid();
c3df33af 120 &Pakfire::getmirrors();
5b2a12ff
MT
121 $force = "force" if ("$ARGV[1]" eq "--force");
122 &Pakfire::dbgetlist("$force");
afabe9f7 123
4b122800
MT
124
125 } elsif ("$ARGV[0]" eq "upgrade") {
99e6df8e
MT
126 my @upgradepaks = &Pakfire::dblist("upgrade", "noweb");
127 my @temp;
128
129 foreach (@upgradepaks) {
130 @temp = &Pakfire::resolvedeps("$_");
131 foreach (@temp) { push(@upgradepaks,$_) if $_; }
132 }
133
134 if (@upgradepaks) {
135 &Pakfire::message("");
136 &Pakfire::message("We are going to install all packages listed above.");
137 if ($interactive) {
138 &Pakfire::message("Is this okay? [y/N]");
139 my $ret = <STDIN>;
140 chomp($ret);
141 &Pakfire::logger("Answer: $ret");
142 if ( $ret ne "y" ) {
143 &Pakfire::message("Installation aborted.");
144 exit 1;
145 }
146 }
147 }
148
149 ### Download first
150 foreach (sort @upgradepaks) {
151 &Pakfire::message("# --> Downloading: $_");
152 &Pakfire::getpak("$_", "");
153 }
154
155 foreach (sort @upgradepaks) {
156 &Pakfire::upgradepak("$_");
157 }
4b122800 158
afabe9f7 159 } elsif ("$ARGV[0]" eq "list") {
5b2a12ff
MT
160 &Pakfire::dblist("all", "noweb");
161
162 } elsif ("$ARGV[0]" eq "resolvedeps") {
163 foreach (@ARGV) {
164 next if ("$_" eq "resolvedeps");
165 &Pakfire::resolvedeps("$_");
166 }
167
168 } else {
169 &Pakfire::usage;
1bd42c89 170 }
99e6df8e
MT
171
172exit 0;