Revision 2d26ee5e
Added by Sjon Hortensius over 10 years ago
etc/inc/pkg-utils.inc | ||
---|---|---|
83 | 83 |
if(!is_dir("/usr/local/pkg") or !is_dir("/usr/local/pkg/pf")) { |
84 | 84 |
conf_mount_rw(); |
85 | 85 |
safe_mkdir("/usr/local/pkg"); |
86 |
safe_mkdir("/usr/local/pkg/pf");
|
|
86 |
safe_mkdir("/usr/local/pkg/pf"); |
|
87 | 87 |
conf_mount_ro(); |
88 | 88 |
} |
89 | 89 |
|
... | ... | |
95 | 95 |
* RESULT |
96 | 96 |
* none |
97 | 97 |
* NOTES |
98 |
*
|
|
98 |
* |
|
99 | 99 |
******/ |
100 | 100 |
function remove_freebsd_package($packagestring) { |
101 |
// The packagestring passed in must be the full PBI package name,
|
|
102 |
// as displayed by the pbi_info utility. e.g. "package-1.2.3_4-i386"
|
|
101 |
// The packagestring passed in must be the full PBI package name, |
|
102 |
// as displayed by the pbi_info utility. e.g. "package-1.2.3_4-i386" |
|
103 | 103 |
// It must NOT have ".pbi" on the end. |
104 | 104 |
$links = get_pbi_binaries(escapeshellarg($packagestring)); |
105 | 105 |
foreach($links as $link) |
... | ... | |
177 | 177 |
|
178 | 178 |
$freebsd_machine = php_uname("m"); |
179 | 179 |
$params = array( |
180 |
"pkg" => $pkgs,
|
|
181 |
"info" => $info,
|
|
180 |
"pkg" => $pkgs, |
|
181 |
"info" => $info, |
|
182 | 182 |
"freebsd_version" => get_freebsd_version(), |
183 | 183 |
"freebsd_machine" => $freebsd_machine |
184 | 184 |
); |
... | ... | |
191 | 191 |
|
192 | 192 |
$freebsd_machine = php_uname("m"); |
193 | 193 |
$params = array( |
194 |
"pkg" => $pkgs,
|
|
194 |
"pkg" => $pkgs, |
|
195 | 195 |
"freebsd_version" => get_freebsd_version(), |
196 | 196 |
"freebsd_machine" => $freebsd_machine |
197 | 197 |
); |
... | ... | |
235 | 235 |
if(platform_booting() != true) |
236 | 236 |
stop_service(get_pkg_internal_name($package)); |
237 | 237 |
sync_package($idx, true, true); |
238 |
if($pkg_interface == "console")
|
|
238 |
if($pkg_interface == "console") |
|
239 | 239 |
echo "\n" . gettext("Syncing packages:"); |
240 | 240 |
} |
241 | 241 |
|
... | ... | |
251 | 251 |
* package is installed. |
252 | 252 |
*/ |
253 | 253 |
function is_freebsd_pkg_installed($pkg) { |
254 |
if(!$pkg)
|
|
254 |
if(!$pkg) |
|
255 | 255 |
return; |
256 | 256 |
$output = ""; |
257 | 257 |
$_gb = exec("/usr/local/sbin/pbi_info " . escapeshellarg($pkg) . ' 2>/dev/null', $output, $retval); |
... | ... | |
300 | 300 |
else |
301 | 301 |
$prefix = "/usr/local/pkg/"; |
302 | 302 |
// Ensure that the prefix exists to avoid installation errors. |
303 |
if(!is_dir($prefix))
|
|
303 |
if(!is_dir($prefix)) |
|
304 | 304 |
exec("/bin/mkdir -p {$prefix}"); |
305 | 305 |
if(!file_exists($prefix . $depend_file)) |
306 | 306 |
log_error(sprintf(gettext("The %s package is missing required dependencies and must be reinstalled."), $package['name'])); |
... | ... | |
376 | 376 |
function sync_package($pkg_name, $sync_depends = true, $show_message = false) { |
377 | 377 |
global $config, $config_parsed; |
378 | 378 |
global $builder_package_install; |
379 |
|
|
380 |
// If this code is being called by pfspkg_installer
|
|
379 |
|
|
380 |
// If this code is being called by pfspkg_installer |
|
381 | 381 |
// which the builder system uses then return (ignore). |
382 | 382 |
if($builder_package_install) |
383 | 383 |
return; |
384 |
|
|
384 |
|
|
385 | 385 |
if(empty($config['installedpackages']['package'])) |
386 | 386 |
return; |
387 | 387 |
if(!is_numeric($pkg_name)) { |
... | ... | |
443 | 443 |
if(isset($item_config['nosync'])) |
444 | 444 |
continue; |
445 | 445 |
if (!empty($item_config['include_file'])) { |
446 |
if (file_exists($item_config['include_file']))
|
|
446 |
if (file_exists($item_config['include_file'])) |
|
447 | 447 |
require_once($item_config['include_file']); |
448 | 448 |
else { |
449 | 449 |
log_error("Not calling package sync code for dependency {$item_config['name']} of {$package['name']} because some include files are missing."); |
... | ... | |
604 | 604 |
/* safe side. Write config below will send to ro again. */ |
605 | 605 |
conf_mount_rw(); |
606 | 606 |
|
607 |
if($pkg_interface == "console")
|
|
607 |
if($pkg_interface == "console") |
|
608 | 608 |
echo "\n"; |
609 | 609 |
/* fetch package information if needed */ |
610 | 610 |
if(empty($pkg_info) or !is_array($pkg_info[$package])) { |
... | ... | |
618 | 618 |
if (!$force_install) { |
619 | 619 |
$compatible = true; |
620 | 620 |
$version = rtrim(file_get_contents("/etc/version")); |
621 |
|
|
621 |
|
|
622 | 622 |
if (isset($pkg_info['required_version'])) |
623 | 623 |
$compatible = (pfs_version_compare("", $version, $pkg_info['required_version']) >= 0); |
624 | 624 |
if (isset($pkg_info['maximum_version'])) |
625 | 625 |
$compatible = $compatible && (pfs_version_compare("", $version, $pkg_info['maximum_version']) <= 0); |
626 |
|
|
626 |
|
|
627 | 627 |
if (!$compatible) { |
628 | 628 |
log_error(sprintf(gettext('Package %s is not supported on this version.'), $pkg_info['name'])); |
629 | 629 |
$static_output .= sprintf(gettext("Package %s is not supported on this version."), $pkg_info['name']); |
630 | 630 |
update_status($static_output); |
631 |
|
|
631 |
|
|
632 | 632 |
conf_mount_ro(); |
633 | 633 |
return -1; |
634 | 634 |
} |
... | ... | |
675 | 675 |
log_error(sprintf(gettext("Successfully installed package: %s."), $pkg_info['name'])); |
676 | 676 |
$static_output .= gettext("done.") . "\n"; |
677 | 677 |
update_output_window($static_output); |
678 |
if($pkg_info['after_install_info'])
|
|
679 |
update_output_window($pkg_info['after_install_info']);
|
|
678 |
if($pkg_info['after_install_info']) |
|
679 |
update_output_window($pkg_info['after_install_info']); |
|
680 | 680 |
} |
681 | 681 |
} |
682 | 682 |
|
... | ... | |
709 | 709 |
$static_output .= sprintf(gettext("The %s package is not installed.%sInstallation aborted."), $pkg, "\n\n"); |
710 | 710 |
update_output_window($static_output); |
711 | 711 |
if($pkg_interface <> "console") { |
712 |
echo "\n<script type=\"text/javascript\">document.progressbar.style.visibility='hidden';</script>";
|
|
713 |
echo "\n<script type=\"text/javascript\">document.progholder.style.visibility='hidden';</script>";
|
|
712 |
echo "\n<script>document.getElementById('progressbar').style.visibility='hidden';</script>";
|
|
713 |
echo "\n<script>document.getElementById('progholder').style.visibility='hidden';</script>";
|
|
714 | 714 |
} |
715 | 715 |
sleep(1); |
716 | 716 |
return false; |
... | ... | |
719 | 719 |
|
720 | 720 |
/* pkg_add the package and its dependencies */ |
721 | 721 |
if($pkg_info['depends_on_package_base_url'] != "") { |
722 |
if($pkg_interface == "console")
|
|
722 |
if($pkg_interface == "console") |
|
723 | 723 |
echo "\n"; |
724 | 724 |
update_status(gettext("Installing") . " " . $pkg_info['name'] . " " . gettext("and its dependencies.")); |
725 | 725 |
$static_output .= gettext("Downloading") . " " . $pkg_info['name'] . " " . gettext("and its dependencies... "); |
... | ... | |
736 | 736 |
update_output_window($static_output); |
737 | 737 |
pkg_debug(gettext("Package WAS NOT installed properly.") . "\n"); |
738 | 738 |
if($pkg_interface <> "console") { |
739 |
echo "\n<script type=\"text/javascript\">document.progressbar.style.visibility='hidden';</script>";
|
|
740 |
echo "\n<script type=\"text/javascript\">document.progholder.style.visibility='hidden';</script>";
|
|
739 |
echo "\n<script>document.getElementById('progressbar').style.visibility='hidden';</script>";
|
|
740 |
echo "\n<script>document.getElementById('progholder').style.visibility='hidden';</script>";
|
|
741 | 741 |
} |
742 | 742 |
sleep(1); |
743 | 743 |
return false; |
... | ... | |
893 | 893 |
update_output_window($static_output); |
894 | 894 |
pkg_debug(gettext("Unable to load package configuration. Installation aborted.") ."\n"); |
895 | 895 |
if($pkg_interface <> "console") { |
896 |
echo "\n<script type=\"text/javascript\">document.progressbar.style.visibility='hidden';</script>";
|
|
897 |
echo "\n<script type=\"text/javascript\">document.progholder.style.visibility='hidden';</script>";
|
|
896 |
echo "\n<script>document.getElementById('progressbar').style.visibility='hidden';</script>";
|
|
897 |
echo "\n<script>document.getElementById('progholder').style.visibility='hidden';</script>";
|
|
898 | 898 |
} |
899 | 899 |
sleep(1); |
900 | 900 |
return false; |
... | ... | |
919 | 919 |
$pkg_var_db_dir = glob("/var/db/pkg/{$pkg}*"); |
920 | 920 |
// If this package has dependency then return true |
921 | 921 |
foreach($pkg_var_db_dir as $pvdd) { |
922 |
if (file_exists("{$vardb}/{$pvdd}/+REQUIRED_BY") && count(file("{$vardb}/{$pvdd}/+REQUIRED_BY")) > 0)
|
|
922 |
if (file_exists("{$vardb}/{$pvdd}/+REQUIRED_BY") && count(file("{$vardb}/{$pvdd}/+REQUIRED_BY")) > 0) |
|
923 | 923 |
return true; |
924 |
}
|
|
924 |
} |
|
925 | 925 |
// Did not find a record of dependencies, so return false. |
926 | 926 |
return false; |
927 | 927 |
} |
... | ... | |
929 | 929 |
function delete_package($pkg) { |
930 | 930 |
global $config, $g, $static_output, $vardb; |
931 | 931 |
|
932 |
if(!$pkg)
|
|
932 |
if(!$pkg) |
|
933 | 933 |
return; |
934 | 934 |
|
935 | 935 |
// Note: $pkg has the full PBI package name followed by ".pbi". Strip off ".pbi". |
... | ... | |
959 | 959 |
$static_output .= sprintf(gettext("The %s package is not installed.%sDeletion aborted."), $pkg, "\n\n"); |
960 | 960 |
update_output_window($static_output); |
961 | 961 |
if($pkg_interface <> "console") { |
962 |
echo "\n<script type=\"text/javascript\">document.progressbar.style.visibility='hidden';</script>";
|
|
963 |
echo "\n<script type=\"text/javascript\">document.progholder.style.visibility='hidden';</script>";
|
|
962 |
echo "\n<script>document.getElementById('progressbar').style.visibility='hidden';</script>";
|
|
963 |
echo "\n<script>document.getElementById('progholder').style.visibility='hidden';</script>";
|
|
964 | 964 |
} |
965 | 965 |
ob_flush(); |
966 | 966 |
sleep(1); |
... | ... | |
1133 | 1133 |
$static_output .= "done.\n"; |
1134 | 1134 |
update_output_window($static_output); |
1135 | 1135 |
} |
1136 |
|
|
1136 |
|
|
1137 | 1137 |
conf_mount_ro(); |
1138 | 1138 |
/* remove config.xml entries */ |
1139 | 1139 |
$static_output .= gettext("Configuration... "); |
... | ... | |
1311 | 1311 |
|
1312 | 1312 |
/* Get pfsense version*/ |
1313 | 1313 |
$version = rtrim(file_get_contents("/etc/version")); |
1314 |
|
|
1314 |
|
|
1315 | 1315 |
if($g['platform'] == "nanobsd") |
1316 |
if($index['noembedded'])
|
|
1316 |
if($index['noembedded']) |
|
1317 | 1317 |
return true; |
1318 |
|
|
1318 |
|
|
1319 | 1319 |
/* If we are on not on HEAD, and the package wants it, skip */ |
1320 | 1320 |
if ($version <> "HEAD" && $index['required_version'] == "HEAD" && $requested_version <> "other") |
1321 | 1321 |
return true; |
1322 |
|
|
1322 |
|
|
1323 | 1323 |
/* If there is no required version, and the requested package version is not 'none', then skip */ |
1324 | 1324 |
if (empty($index['required_version']) && $requested_version <> "none") |
1325 | 1325 |
return true; |
1326 |
|
|
1326 |
|
|
1327 | 1327 |
/* If the requested version is not 'other', and the required version is newer than what we have, skip. */ |
1328 | 1328 |
if($requested_version <> "other" && (pfs_version_compare("", $version, $index['required_version']) < 0)) |
1329 | 1329 |
return true; |
1330 |
|
|
1330 |
|
|
1331 | 1331 |
/* If the requestion version is 'other' and we are on the version requested, skip. */ |
1332 | 1332 |
if($requested_version == "other" && (pfs_version_compare("", $version, $index['required_version']) == 0)) |
1333 | 1333 |
return true; |
1334 |
|
|
1334 |
|
|
1335 | 1335 |
/* Package is only for an older version, lets skip */ |
1336 | 1336 |
if($index['maximum_version'] && (pfs_version_compare("", $version, $index['maximum_version']) > 0)) |
1337 | 1337 |
return true; |
1338 |
|
|
1339 |
/* Do not skip package list */
|
|
1338 |
|
|
1339 |
/* Do not skip package list */ |
|
1340 | 1340 |
return false; |
1341 | 1341 |
} |
1342 | 1342 |
|
Also available in: Unified diff
initial rewrite of package management pages