Verified Commit 7e559673 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

Remove immediate reboot

This removes immediate reboot possibility from updater.

Original reasoning was to reboot router because update of specific
package broke system so much it can't continue. We never used it. It is
also questionable how such package could break system in a way where
reboot helps. That would have to be kernel module but having some core
systems in module that we would have to do reboot and were unable to
finish update seems like impossible. To finish update we in general need
just filesystem and shell. Existing solution would not work with
theoretical breakage of any of those anyway so it is pretty much useless
feature. Anything this can solve can be also solved by reboot at the end
of update.
parent 37751919
Pipeline #71275 failed with stages
in 4 minutes and 30 seconds
......@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Default connection timeout for download was extended from one minute to ten
minutes.
### Removed
- Possibility to reboot immediatelly after package installation. Reboot after
update is deemed sufficient.
## [67.0.3] - 2020-10-21
### Changed
- pkgupdate's conf.lua now loads scripts with Full security level instead of Local
......
......@@ -407,13 +407,7 @@ reboot::
version works, so it may be delayed for arbitrary amount of time.
finished;;
The reboot needs to be done once the update is finished. It is because the old
version no longer works as expected. The whole update may be delayed because
the need of this update, so the update happens at a time convenient to the
user.
immediate;;
The reboot needs to be done just after the package is set up. This may be
needed when the old version would prevent the rest of the update from
happening.
version no longer works as expected.
replan::
The package has an effect on the updater itself. Therefore, updater have to run
planning again. When this happens is according to value.
......
......@@ -839,12 +839,6 @@ static int lua_reexec(lua_State *L) {
return 0;
}
static int lua_system_reboot(lua_State *L) {
bool stick = lua_toboolean(L, 1);
system_reboot(stick);
return 0;
}
static int lua_get_updater_version(lua_State *L) {
lua_pushstring(L, PACKAGE_VERSION);
return 1;
......@@ -895,7 +889,6 @@ static const struct injected_func injected_funcs[] = {
{ lua_sha256, "sha256" },
{ lua_sha256_file, "sha256_file" },
{ lua_reexec, "reexec" },
{ lua_system_reboot, "system_reboot" },
{ lua_get_updater_version, "get_updater_version" }
};
......
......@@ -209,7 +209,11 @@ function package(_, pkg_name, extra)
if name == "deps" then
extra_check_deps("package", name, value)
elseif name == "reboot" then
if not utils.arr2set({"delayed", "finished", "immediate"})[value] then
if value == "immediate" then
WARN('Package extra option\'s "reboot" value "immediate" is no longer available. Using "finished" instead.')
value = "finished"
end
if not utils.arr2set({"delayed", "finished"})[value] then
error(utils.exception("bad value", "Invalid value " .. value .. " in extra option " .. name .. " for a package"))
end
elseif (name == "order_after" or name == "order_before") then
......
......@@ -51,7 +51,6 @@ local LS_CLEANUP = LS_CLEANUP
local update_state = update_state
local sync = sync
local log_event = log_event
local system_reboot = system_reboot
module "transaction"
......@@ -125,7 +124,6 @@ local function pkg_unpack(operations, status)
old_configs = old_configs,
changed_files = changed_files,
control = control,
reboot_immediate = op.reboot == "immediate"
})
if op.replan then
cleanup_actions.reexec = true
......@@ -195,11 +193,6 @@ local function pkg_move(status, plan, early_remove, errors_collected)
local did_merge = backend.pkg_merge_files(op.dir .. "/data", op.dirs, op.files, op.old_configs)
status[op.control.Package] = op.control
backend.pkg_update_alternatives(status, op.control.Package)
if op.reboot_immediate and did_merge then -- we reboot only if we did merge, if files were already merged then we already rebooted.
-- We can't exit this function, so it could finish from journal after reboot. We stuck execution here.
-- Note: This causes reexecution of already executed preinst scripts.
system_reboot(true)
end
elseif op.op == "remove" and utils.arr2set(utils.multi_index(status, op.name, 'Status') or {})['installed'] then
log_event("R", op.name)
utils.table_merge(all_configs, status[op.name].Conffiles or {})
......
......@@ -442,9 +442,5 @@ uri_internal_get(name)::
is name of requested embedded file. Returns file content. If there is
no file under given name, error is raised.
system_reboot(stick)::
Reboots system. Argument `stick` if set to true results in that this
newer returns.
get_updater_version()::
Returns string containing updater's version.
......@@ -196,7 +196,7 @@ void system_reboot_disable() {
system_reboot_disabled = true;
}
void system_reboot(bool stick) {
void system_reboot() {
if (system_reboot_disabled) {
WARN("System reboot skipped as requested.");
return;
......@@ -205,13 +205,6 @@ void system_reboot(bool stick) {
if (!fork()) {
ASSERT_MSG(execlp("reboot", "reboot", NULL), "Execution of reboot command failed");
}
if (stick) {
sigset_t sigmask;
sigfillset(&sigmask);
while (1) {
ppoll(NULL, 0, NULL, &sigmask);
}
}
}
size_t printf_len(const char *msg, ...) {
......
......@@ -59,14 +59,15 @@ void cleanup_run_all(void); // Run all cleanup functions explicitly
// Disable system reboot. If this function is called before system_reboot is than
// system reboot just prints warning about skipped reboot and returns.
void system_reboot_disable();
// Reboot system. Argument stick signals if updater should stick or continue.
void system_reboot(bool stick);
// Reboot system.
void system_reboot();
// Compute the size needed (including \0) to format given message
size_t printf_len(const char *msg, ...) __attribute__((format(printf, 1, 2)));
// Like sprintf, but returs the string. Expects there's enough space.
char *printf_into(char *dst, const char *msg, ...) __attribute__((format(printf, 2, 3)));
// Like printf, but allocates the data on the stack with alloca and returns. It uses the arguments multiple times, so beware of side effects.
// Like printf, but allocates the data on the stack with alloca and returns.
// It uses the arguments multiple times, so beware of side effects.
#define aprintf(...) printf_into(alloca(printf_len(__VA_ARGS__)), __VA_ARGS__)
// GCC 7+ reports fall troughs but previous versions doesn't understand attribute
......
......@@ -239,7 +239,6 @@ function test_perform_ok()
files = { f = true },
op = "install",
old_configs = { c = "12345678901234567890123456789012" },
reboot_immediate = false
},
{ name = "pkg-rem", op = "remove" }
},
......@@ -387,7 +386,6 @@ function test_perform_collision()
files = { f = true },
op = "install",
old_configs = { c = "1234567890123456" },
reboot_immediate = false
},
{
configs = { c = "1234567890123456" },
......@@ -397,7 +395,6 @@ function test_perform_collision()
files = { f = true },
op = "install",
old_configs = { c = "1234567890123456" },
reboot_immediate = false
}
},
{"<pkg1dir>", "<pkg2dir>"},
......
TESTS += \
%reldir%/help.sys_trans \
%reldir%/install.sys_trans \
%reldir%/reboot-recover.sys_trans \
%reldir%/remove.sys_trans \
%reldir%/remove-nonexistent.sys_trans \
%reldir%/abi-change.sys_update \
......@@ -21,7 +20,6 @@ TESTS += \
%reldir%/postinst.sys_update \
%reldir%/provides-replace.sys_update \
%reldir%/provides.sys_update \
%reldir%/reboot-recover-update.sys_update \
%reldir%/reboot.sys_update \
%reldir%/reinstall-all.sys_update \
%reldir%/replan-no-effect.sys_update \
......
#!/bin/sh
echo Rebooted >> $ROOT_DIR/rebooted
# Wait for some time and kill parent if it still runs
# This handles immediate reboot option
PP=`ps -o ppid= $$`
sleep 2 # Expecting that updater exits in two seconds when "finished" is used is very graceful
if ps $PP >/dev/null; then
# If parent exited we die
echo Killed >> $ROOT_DIR/rebooted
kill -KILL $PP
fi
Package: newpkg
Version: 1
License: GPL-2.0
Section: none
Architecture: all
Installed-Size: 0
Filename: newpkg.ipk
MD5Sum: e11ba2df83d5839c2a63080490666826
SHA256sum: cb93165e82c7d0ab7c878f8da5a9f3e4f874c069c27b559112b823a866d78b8f
Description: Example new package
Package: package
Version: 1
License: GPL-2.0
Section: none
Architecture: all
Installed-Size: 0
Filename: package.ipk
MD5Sum: 2bead58a5f2728659f48bc028cb4f0a3
SHA256sum: cb2463d1123472dc041d6c624502080a2cfd0b21e822364a2e282eafa557f66a
Description: Example package
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment