Detect binary packages installed but not registered in the system and do it during boot

This commit is contained in:
Renato Botelho 2016-03-03 15:02:39 -03:00
parent c86db913df
commit bed6c19b3c
2 changed files with 36 additions and 1 deletions

View File

@ -452,6 +452,37 @@ function get_pkg_info($pkgs = 'all', $info = 'all', $only_local = false) {
return $result;
}
/*
* If binary pkg is installed but post-install tasks were not
* executed yet, fo it now.
* This scenario can happen when a pkg is pre-installed during
* build phase, and at this point, cannot find a running system
* to register itself in config.xml and also execute custom
* install functions
*/
function register_all_installed_packages() {
global $g, $config, $pkg_interface;
$pkg_info = get_pkg_info('all', 'all', true);
foreach ($pkg_info as $pkg) {
if (!isset($pkg['installed'])) {
continue;
}
pkg_remove_prefix($pkg['name']);
if (is_package_installed($pkg['name'])) {
continue;
}
update_status(sprintf(gettext(
"Running last steps of %s installation.") . "\n",
$pkg['name']));
install_package_xml($pkg['name']);
}
}
/*
* resync_all_package_configs() Force packages to setup their configuration and rc.d files.
* This function may also print output to the terminal indicating progress.

View File

@ -31,6 +31,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("pkg-utils.inc");
function rescue_detect_keypress() {
// How long do you want the script to wait before moving on (in seconds)
$timeout=9;
@ -411,7 +413,6 @@ if (file_exists("/sbin/shutdown.old")) {
/* Resync / Reinstall packages if need be */
if (file_exists('/conf/needs_package_sync') &&
($g['platform'] == $g['product_name'] || $g['platform'] == "nanobsd")) {
require_once("pkg-utils.inc");
mark_subsystem_dirty('packagelock');
if (package_reinstall_all()) {
@unlink('/conf/needs_package_sync');
@ -419,6 +420,9 @@ if (file_exists('/conf/needs_package_sync') &&
clear_subsystem_dirty('packagelock');
}
/* Detect installed binary pkgs that are not registered in the system */
register_all_installed_packages();
/* Give syslogd a kick after everything else has been initialized, otherwise it can occasionally
fail to route syslog messages properly on both IPv4 and IPv6 */
system_syslogd_start();