]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/pakfire/pakfire
3 require "/opt/pakfire/lib/functions.pl";
7 &Pakfire
::logger
("### IPFire Pakfire $Conf::version started!");
8 &Pakfire
::checkcryptodb
;
10 ### Check if we are running as root
12 my $user = qx(whoami
);
14 unless ( "$user" eq "root" ) {
15 &Pakfire
::message
("You must run pakfire as user root!");
25 $interactive = 0 if ("$_" eq "--non-interactive");
26 $interactive = 0 if ("$_" eq "-y");
30 if ("$ARGV[0]" eq "install") {
33 ### Make sure that the list is not outdated.
34 &Pakfire
::dbgetlist
("noforce");
36 open(FILE
, "<$Conf::dbdir/lists/packages_list.db");
49 foreach $pak (@ARGV) {
50 unless ("$pak" =~ "^-") {
51 $return = &Pakfire
::isinstalled
($pak);
53 &Pakfire
::message
("Package $pak is already installed.");
58 @templine = split(/;/,$_);
59 if ("$templine[0]" eq "$pak" ) {
62 @temp = &Pakfire
::resolvedeps
("$pak");
63 foreach $dep (@temp) {
64 push(@deps,$dep) if $dep;
65 push(@all,$dep) if $dep;
71 &Pakfire
::message
("");
72 &Pakfire
::message
("The pak \"$pak\" is not known. Please try running \"pakfire update\".") if ($found == 0);
77 &Pakfire
::message
("No packages to install. Exiting...");
81 &Pakfire
::message
("");
82 &Pakfire
::message
("");
83 &Pakfire
::message
("### Packages to install:");
84 foreach $pak (sort @paks) {
85 my $size = &Pakfire
::getsize
("$pak");
86 $size = &Pakfire
::beautifysize
($size);
87 &Pakfire
::message
("# $pak \t\t - $size");
91 my %sort = map{ $_, 1 } @deps;
92 @deps = sort keys %sort;
93 &Pakfire
::message
("");
94 &Pakfire
::message
("### Packages to install for dependencies:");
96 foreach $dep (sort @deps) {
97 my $size = &Pakfire
::getsize
("$dep");
98 $size = &Pakfire
::beautifysize
($size);
99 &Pakfire
::message
("# $dep \t\t - $size");
103 foreach $pak (@all) {
104 $totalsize = ($totalsize + &Pakfire
::getsize
("$pak"));
106 $totalsize = &Pakfire
::beautifysize
($totalsize);
107 &Pakfire
::message
("");
108 &Pakfire
::message
("### Total size: \t ~ $totalsize");
109 &Pakfire
::message
("");
112 &Pakfire
::message
("Is this okay? [y/N]");
115 &Pakfire
::logger
("Answer: $ret");
117 &Pakfire
::message
("Installation aborted.");
122 my %sort = map{ $_, 1 } @all;
123 @all = sort keys %sort;
126 foreach $pak (sort @all) {
127 &Pakfire
::message
("# --> Downloading: $pak");
128 &Pakfire
::getpak
("$pak", "");
131 foreach $pak (sort @all) {
132 &Pakfire
::setuppak
("$pak") if ($pak ne "");
135 } elsif ("$ARGV[0]" eq "remove") {
138 } elsif ("$ARGV[0]" eq "update") {
139 my $force = "noforce";
140 &Pakfire
::makeuuid
();
141 &Pakfire
::senduuid
();
142 &Pakfire
::getmirrors
();
143 $force = "force" if ("$ARGV[1]" eq "--force");
144 &Pakfire
::dbgetlist
("$force");
147 } elsif ("$ARGV[0]" eq "upgrade") {
148 my @upgradepaks = &Pakfire
::dblist
("upgrade", "noweb");
151 foreach (@upgradepaks) {
152 @temp = &Pakfire
::resolvedeps
("$_");
153 foreach (@temp) { push(@upgradepaks,$_) if $_; }
157 &Pakfire
::message
("");
158 &Pakfire
::message
("We are going to install all packages listed above.");
160 &Pakfire
::message
("Is this okay? [y/N]");
163 &Pakfire
::logger
("Answer: $ret");
165 &Pakfire
::message
("Installation aborted.");
172 foreach (sort @upgradepaks) {
173 &Pakfire
::message
("# --> Downloading: $_");
174 &Pakfire
::getpak
("$_", "");
177 foreach (sort @upgradepaks) {
178 &Pakfire
::upgradepak
("$_");
181 } elsif ("$ARGV[0]" eq "list") {
182 &Pakfire
::dblist
("all", "noweb");
184 } elsif ("$ARGV[0]" eq "resolvedeps") {
186 next if ("$_" eq "resolvedeps");
187 &Pakfire
::resolvedeps
("$_");