fix(prerm/postinst): use BIN_PATH stop, clear flock in postinst, always return true; fix(install): verify package VERSION not just existence on APK error
This commit is contained in:
+6
-4
@@ -1760,17 +1760,19 @@ pkg_install_files() {
|
||||
if [ $rc -ne 0 ]; then
|
||||
# apk may report warnings as errors even though the package installed successfully
|
||||
# (e.g., ip-full conflict with ip, missing optional deps, etc.)
|
||||
# Check if at least one of the requested packages is now installed
|
||||
# Verify the CORRECT version is now installed, not just any version.
|
||||
local pkg_file
|
||||
for pkg_file in "$@"; do
|
||||
local pkg_name
|
||||
local pkg_name pkg_expected_ver pkg_actual_ver
|
||||
pkg_name="$(basename "$pkg_file" | sed 's/\.[^.]*$//; s/_[0-9].*$//')"
|
||||
if pkg_is_installed "$pkg_name"; then
|
||||
pkg_expected_ver="$(basename "$pkg_file" | sed 's/^[^_]*_//; s/\.apk$//')"
|
||||
pkg_actual_ver="$(apk info "$pkg_name" 2>/dev/null | head -1 | sed "s/${pkg_name}-//")"
|
||||
if [ "$pkg_actual_ver" = "$pkg_expected_ver" ]; then
|
||||
warn "Package manager reported non-critical errors during installation (package is installed OK)"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
log_line "FAIL apk install output reported error (exit $rc)"
|
||||
log_line "FAIL apk install failed (exit $rc); package was rolled back"
|
||||
return $rc
|
||||
fi
|
||||
else
|
||||
|
||||
@@ -130,14 +130,14 @@ function prerm_cleanup(action) {
|
||||
|
||||
remember_upgrade_state(action);
|
||||
if (!PACKAGE_TEST_MODE) {
|
||||
// 1. Kill retry_start_on_wan_up and other background init.d/tachyon
|
||||
// processes that continuously spawn new flock -w 1000 waiters.
|
||||
system("ps 2>/dev/null | awk '/init.d\\/tachyon/{print $1}' | while read _pid; do kill -9 \"$_pid\" 2>/dev/null; done; true");
|
||||
// 2. Kill any remaining flock -w 1000 waiters (rc.common serialization lock).
|
||||
// 1. Kill all /etc/init.d/tachyon background processes (retry_start_on_wan_up
|
||||
// and other procd triggers) — these continuously spawn new flock -w 1000
|
||||
// waiters that deadlock any subsequent init.d call.
|
||||
system("ps 2>/dev/null | awk '/\/etc\/init.d\/tachyon/{print $1}' | while read _pid; do kill -9 \"$_pid\" 2>/dev/null; done; true");
|
||||
// 2. Kill any remaining flock -w 1000 waiters.
|
||||
system("sleep 1; ps 2>/dev/null | awk '/flock 1000/{print $1}' | while read _pid; do kill -9 \"$_pid\" 2>/dev/null; done; true");
|
||||
// 3. Stop service via ubus (no rc.common/flock involved).
|
||||
system("ubus call service delete '{\"name\":\"tachyon\"}' 2>/dev/null; true");
|
||||
system("sleep 1; timeout 5 " + shell_quote(INIT_PATH) + " stop >/dev/null 2>&1; true");
|
||||
// 3. Stop via tachyon binary (lifecycle.uc) — bypasses rc.common, no flock.
|
||||
system(shell_quote(BIN_PATH) + " stop >/dev/null 2>&1; true");
|
||||
restore_dnsmasq_if_needed();
|
||||
remove_managed_sing_box();
|
||||
}
|
||||
@@ -149,9 +149,13 @@ function postinst_restore() {
|
||||
if (env("IPKG_INSTROOT", "") != "" || !path_exists(PACKAGE_UPGRADE_STATE))
|
||||
return true;
|
||||
|
||||
let started = command_success_from_args([ INIT_PATH, "start" ]);
|
||||
// Kill any flock waiters that appeared since prerm ran (procd re-triggers
|
||||
// retry_start_on_wan_up between prerm and postinst).
|
||||
system("ps 2>/dev/null | awk '/\/etc\/init.d\/tachyon/{print $1}' | while read _pid; do kill -9 \"$_pid\" 2>/dev/null; done; true");
|
||||
system("sleep 1; ps 2>/dev/null | awk '/flock 1000/{print $1}' | while read _pid; do kill -9 \"$_pid\" 2>/dev/null; done; true");
|
||||
command_success_from_args([ INIT_PATH, "start" ]);
|
||||
unlink_if_exists(PACKAGE_UPGRADE_STATE);
|
||||
return started;
|
||||
return true; // never roll back the upgrade due to service start failure
|
||||
}
|
||||
|
||||
function luci_cache_globs() {
|
||||
|
||||
Reference in New Issue
Block a user