1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
pkg_mgr.php
|
5
|
Copyright (C) 2004-2010 Scott Ullrich <sullrich@gmail.com>
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
/*
|
30
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
31
|
pfSense_MODULE: pkgs
|
32
|
*/
|
33
|
|
34
|
##|+PRIV
|
35
|
##|*IDENT=page-system-packagemanager
|
36
|
##|*NAME=System: Package Manager page
|
37
|
##|*DESCR=Allow access to the 'System: Package Manager' page.
|
38
|
##|*MATCH=pkg_mgr.php*
|
39
|
##|-PRIV
|
40
|
|
41
|
ini_set('max_execution_time', '0');
|
42
|
|
43
|
require_once("globals.inc");
|
44
|
require_once("guiconfig.inc");
|
45
|
require_once("pkg-utils.inc");
|
46
|
|
47
|
/* if upgrade in progress, alert user */
|
48
|
if(is_subsystem_dirty('packagelock')) {
|
49
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
50
|
include("head.inc");
|
51
|
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
|
52
|
include("fbegin.inc");
|
53
|
echo "Please wait while packages are reinstalled in the background.";
|
54
|
include("fend.inc");
|
55
|
echo "</body>";
|
56
|
echo "</html>";
|
57
|
exit;
|
58
|
}
|
59
|
|
60
|
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "supportedbybsdperimeter"));
|
61
|
if($pkg_info) {
|
62
|
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
63
|
fwrite($fout, serialize($pkg_info));
|
64
|
fclose($fout);
|
65
|
//$pkg_sizes = get_pkg_sizes();
|
66
|
} else {
|
67
|
$using_cache = true;
|
68
|
$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
|
69
|
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
70
|
$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
|
71
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
72
|
} else {
|
73
|
$savemsg = sprintf(gettext('Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']);
|
74
|
}
|
75
|
}
|
76
|
|
77
|
if (! empty($_GET))
|
78
|
if (isset($_GET['ver']))
|
79
|
$requested_version = htmlspecialchars($_GET['ver']);
|
80
|
|
81
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
82
|
include("head.inc");
|
83
|
|
84
|
?>
|
85
|
|
86
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
87
|
<?php
|
88
|
include("fbegin.inc");
|
89
|
if ($savemsg)
|
90
|
print_info_box($savemsg);
|
91
|
?>
|
92
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
93
|
<tr>
|
94
|
<td>
|
95
|
<?php
|
96
|
$version = rtrim(file_get_contents("/etc/version"));
|
97
|
|
98
|
$tab_array = array();
|
99
|
$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
100
|
// $tab_array[] = array($version . gettext("packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
101
|
// $tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
|
102
|
// $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
|
103
|
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
104
|
display_top_tabs($tab_array);
|
105
|
?>
|
106
|
</td>
|
107
|
</tr>
|
108
|
<tr>
|
109
|
<td>
|
110
|
<div id="mainarea">
|
111
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
|
112
|
<tr>
|
113
|
<td width="10%" class="listhdrr"><?=gettext("Package Name"); ?></td>
|
114
|
<td width="25%" class="listhdrr"><?=gettext("Category"); ?></td>
|
115
|
<!-- <td width="10%" class="listhdrr">Size</td> -->
|
116
|
<td width="5%" class="listhdrr"><?=gettext("Status"); ?></td>
|
117
|
<td width="5%" class="listhdrr"><?=gettext("Package Info"); ?></td>
|
118
|
<td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
|
119
|
</tr>
|
120
|
<?php
|
121
|
if(!$pkg_info) {
|
122
|
echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
123
|
} else {
|
124
|
$pkgs = array();
|
125
|
$instpkgs = array();
|
126
|
if($config['installedpackages']['package'] != "")
|
127
|
foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
|
128
|
$pkg_names = array_keys($pkg_info);
|
129
|
$pkg_keys = array();
|
130
|
|
131
|
foreach($pkg_names as $name)
|
132
|
if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
|
133
|
$pkg_keys = msort($pkg_keys);
|
134
|
if(count($pkg_keys) != 0) {
|
135
|
foreach($pkg_keys as $key) {
|
136
|
$index = &$pkg_info[$key];
|
137
|
if(in_array($index['name'], $instpkgs))
|
138
|
continue;
|
139
|
if($g['platform'] == "nanobsd")
|
140
|
if($index['noembedded'])
|
141
|
continue;
|
142
|
/* If we are on not on HEAD, and the package wants it, skip */
|
143
|
if ($version <> "HEAD" &&
|
144
|
$index['required_version'] == "HEAD" &&
|
145
|
$requested_version <> "other")
|
146
|
continue;
|
147
|
/* If there is no required version, and the requested package
|
148
|
version is not 'none', then skip */
|
149
|
if (empty($index['required_version']) &&
|
150
|
$requested_version <> "none")
|
151
|
continue;
|
152
|
/* If the requested version is not 'other', and the required version is newer than what we have, skip. */
|
153
|
if($requested_version <> "other" &&
|
154
|
(pfs_version_compare("", $version, $index['required_version']) < 0))
|
155
|
continue;
|
156
|
/* If the requestion version is 'other' and we are on the version requested, skip. */
|
157
|
if($requested_version == "other" &&
|
158
|
(pfs_version_compare("", $version, $index['required_version']) == 0))
|
159
|
continue;
|
160
|
/* Package is only for an older version, lets skip */
|
161
|
if($index['maximum_version'] &&
|
162
|
(pfs_version_compare("", $version, $index['maximum_version']) > 0))
|
163
|
continue;
|
164
|
?>
|
165
|
<tr valign="top">
|
166
|
<td class="listlr">
|
167
|
<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
|
168
|
</td>
|
169
|
<td class="listr">
|
170
|
<?= $index['category'] ?>
|
171
|
</td>
|
172
|
<?php
|
173
|
/*
|
174
|
if(!$using_cache) {
|
175
|
$size = get_package_install_size($index['name'], $pkg_sizes);
|
176
|
$size = squash_from_bytes($size[$index['name']], 1);
|
177
|
}
|
178
|
if(!$size)
|
179
|
$size = "Unknown.";
|
180
|
*/
|
181
|
?>
|
182
|
<!--
|
183
|
<td class="listr">
|
184
|
<?= $size ?>
|
185
|
</td>
|
186
|
-->
|
187
|
<td class="listr">
|
188
|
<?=$index['status'] ?>
|
189
|
<br/>
|
190
|
<?=$index['version'] ?>
|
191
|
<br/>
|
192
|
<?=gettext("platform") .": ". $index['required_version'] ?>
|
193
|
<br/>
|
194
|
<?=$index['maximum_version'] ?>
|
195
|
</td>
|
196
|
<td class="listr">
|
197
|
<?php
|
198
|
if($index['pkginfolink']) {
|
199
|
$pkginfolink = $index['pkginfolink'];
|
200
|
echo "<a target='_new' href='$pkginfolink'>". gettext("Package Info") ."</a>";
|
201
|
} else {
|
202
|
echo gettext("No info, check the") . " <a href='http://forum.pfsense.org/index.php/board,15.0.html'>" . gettext("forum") . "</a>";
|
203
|
}
|
204
|
?>
|
205
|
</td>
|
206
|
<td class="listbg" class="listbg" style="overflow: hidden;">
|
207
|
<?= $index['descr'] ?>
|
208
|
</td>
|
209
|
<td valign="middle" class="list" nowrap>
|
210
|
<a onclick="return confirm('<?=gettext("Do you really want to install this package?"); ?>')" href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
|
211
|
</td>
|
212
|
</tr>
|
213
|
<?php
|
214
|
}
|
215
|
} else {
|
216
|
echo "<tr><td colspan='5'><center>" . gettext("There are currently no packages available for installation.") . "</center></td></tr>";
|
217
|
}
|
218
|
}
|
219
|
?>
|
220
|
</table>
|
221
|
</div>
|
222
|
</td>
|
223
|
</tr>
|
224
|
</table>
|
225
|
<?php include("fend.inc"); ?>
|
226
|
</body>
|
227
|
</html>
|