mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix sysinstall hook markers not being installed and prefix logic.
Document the compatibility hooks behavior while here.
This commit is contained in:
parent
37b1bf5e75
commit
5f84c38bc8
9 changed files with 51 additions and 32 deletions
|
@ -80,6 +80,8 @@ into
|
||||||
.Pa /oldsrc .
|
.Pa /oldsrc .
|
||||||
.It Sy system Ns "=" Ns Oo Sy no "|" yes Oc (default Sy yes ) .
|
.It Sy system Ns "=" Ns Oo Sy no "|" yes Oc (default Sy yes ) .
|
||||||
Install the new system.
|
Install the new system.
|
||||||
|
The upgrade hooks are run if needed as described in
|
||||||
|
.Xr following-development 7 .
|
||||||
This will run
|
This will run
|
||||||
.Xr update-initrd 8
|
.Xr update-initrd 8
|
||||||
and if
|
and if
|
||||||
|
|
|
@ -28,6 +28,9 @@ and
|
||||||
.Xr sysupgrade 8
|
.Xr sysupgrade 8
|
||||||
programs automatically handle compatibility issues when upgrading an existing
|
programs automatically handle compatibility issues when upgrading an existing
|
||||||
system to a new build.
|
system to a new build.
|
||||||
|
This is done using upgrade hooks built into the programs that are run if the
|
||||||
|
installation does not have the appropriate files in
|
||||||
|
.Pa /share/sysinstall/hooks .
|
||||||
They can handle incompatible ABI changes and automatically fix configuration
|
They can handle incompatible ABI changes and automatically fix configuration
|
||||||
files and other issues.
|
files and other issues.
|
||||||
.Pp
|
.Pp
|
||||||
|
|
|
@ -117,6 +117,9 @@ The upgrader will take the appropriate actions:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -bullet -compact
|
.Bl -bullet -compact
|
||||||
.It
|
.It
|
||||||
|
Running any upgrade hooks needed to migrate the installation across incompatible
|
||||||
|
changes.
|
||||||
|
.It
|
||||||
Updating the system.
|
Updating the system.
|
||||||
.It
|
.It
|
||||||
Updating the ports.
|
Updating the ports.
|
||||||
|
|
|
@ -48,6 +48,9 @@ install: all
|
||||||
cp sysinstall.8 $(DESTDIR)$(MANDIR)/man8/sysinstall.8
|
cp sysinstall.8 $(DESTDIR)$(MANDIR)/man8/sysinstall.8
|
||||||
cp sysmerge.8 $(DESTDIR)$(MANDIR)/man8/sysmerge.8
|
cp sysmerge.8 $(DESTDIR)$(MANDIR)/man8/sysmerge.8
|
||||||
cp sysupgrade.8 $(DESTDIR)$(MANDIR)/man8/sysupgrade.8
|
cp sysupgrade.8 $(DESTDIR)$(MANDIR)/man8/sysupgrade.8
|
||||||
|
mkdir -p $(DESTDIR)$(DATADIR)/sysinstall/hooks
|
||||||
|
# TODO: After releasing Sortix 1.1, remove this compatibility.
|
||||||
|
touch $(DESTDIR)$(DATADIR)/sysinstall/hooks/sortix-1.1-random-seed
|
||||||
|
|
||||||
sysinstall: $(SYSINSTALL_OBJS)
|
sysinstall: $(SYSINSTALL_OBJS)
|
||||||
$(CC) $(SYSINSTALL_OBJS) -o $@ -lmount
|
$(CC) $(SYSINSTALL_OBJS) -o $@ -lmount
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2017, 2018 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2016, 2017, 2018, 2020, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* hooks.c
|
* hooks.c
|
||||||
* Upgrade compatibility hooks.
|
* Upgrade hooks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
// incompatible operating system change is made that needs additional actions.
|
// incompatible operating system change is made that needs additional actions.
|
||||||
// These files are part of the system manifest and their lack can be tested
|
// These files are part of the system manifest and their lack can be tested
|
||||||
// in upgrade_prepare, but not in upgrade_finalize (as they would have been
|
// in upgrade_prepare, but not in upgrade_finalize (as they would have been
|
||||||
// installed there). If a file is lacking, then a hook should be run taking
|
// installed by then). If a file is lacking, then a hook should be run taking
|
||||||
// the needed action. For instance, if /etc/foo becomes the different /etc/bar,
|
// the needed action. For instance, if /etc/foo becomes the different /etc/bar,
|
||||||
// then /share/sysinstall/hooks/osname-x.y-bar would be made, and if it is
|
// then /share/sysinstall/hooks/osname-x.y-bar would be made, and if it is
|
||||||
// absent then upgrade_prepare converts /etc/foo to /etc/bar. The file is then
|
// absent then upgrade_prepare converts /etc/foo to /etc/bar. The file is then
|
||||||
|
@ -41,22 +41,29 @@
|
||||||
//
|
//
|
||||||
// Hooks are meant to run once. However, they must handle if the upgrade fails
|
// Hooks are meant to run once. However, they must handle if the upgrade fails
|
||||||
// between the hook running and the hook file being installed when the system
|
// between the hook running and the hook file being installed when the system
|
||||||
// manifest is installed.
|
// manifest is installed. I.e. they need to be reentrant and idempotent.
|
||||||
//
|
//
|
||||||
// If this system is used, follow the instructions in following-development(7)
|
// If this system is used, follow the instructions in following-development(7)
|
||||||
// and add an entry in that manual page about the change.
|
// and add an entry in that manual page about the change.
|
||||||
__attribute__((used))
|
__attribute__((used))
|
||||||
static bool hook_needs_to_be_run(const char* target_prefix, const char* hook)
|
static bool hook_needs_to_be_run(const char* source_prefix,
|
||||||
|
const char* target_prefix,
|
||||||
|
const char* hook)
|
||||||
{
|
{
|
||||||
char* path;
|
char* source_path;
|
||||||
if ( asprintf(&path, "%sshare/sysinstall/hooks/%s",
|
char* target_path;
|
||||||
|
if ( asprintf(&source_path, "%s/share/sysinstall/hooks/%s",
|
||||||
|
source_prefix, hook) < 0 ||
|
||||||
|
asprintf(&target_path, "%s/share/sysinstall/hooks/%s",
|
||||||
target_prefix, hook) < 0 )
|
target_prefix, hook) < 0 )
|
||||||
{
|
{
|
||||||
warn("asprintf");
|
warn("malloc");
|
||||||
_exit(2);
|
_exit(2);
|
||||||
}
|
}
|
||||||
bool result = access_or_die(path, F_OK) < 0;
|
bool result = access_or_die(source_path, F_OK) == 0 &&
|
||||||
free(path);
|
access_or_die(target_path, F_OK) < 0;
|
||||||
|
free(source_path);
|
||||||
|
free(target_path);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,13 +78,14 @@ void upgrade_prepare(const struct release* old_release,
|
||||||
(void) target_prefix;
|
(void) target_prefix;
|
||||||
|
|
||||||
// TODO: After releasing Sortix 1.1, remove this compatibility.
|
// TODO: After releasing Sortix 1.1, remove this compatibility.
|
||||||
if ( hook_needs_to_be_run(target_prefix, "sortix-1.1-random-seed") )
|
if ( hook_needs_to_be_run(source_prefix, target_prefix,
|
||||||
|
"sortix-1.1-random-seed") )
|
||||||
{
|
{
|
||||||
char* random_seed_path;
|
char* random_seed_path = join_paths(target_prefix, "/boot/random.seed");
|
||||||
if ( asprintf(&random_seed_path, "%sboot/random.seed", target_prefix) < 0 )
|
if ( !random_seed_path )
|
||||||
{
|
{
|
||||||
warn("asprintf");
|
warn("malloc");
|
||||||
_exit(1);
|
_exit(2);
|
||||||
}
|
}
|
||||||
if ( access_or_die(random_seed_path, F_OK) < 0 )
|
if ( access_or_die(random_seed_path, F_OK) < 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2016, 2020 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* hooks.h
|
* hooks.h
|
||||||
* Upgrade compatibility hooks.
|
* Upgrade hooks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HOOKS_H
|
#ifndef HOOKS_H
|
||||||
|
|
|
@ -27,6 +27,9 @@ installs the
|
||||||
manifest from the tix repository in the
|
manifest from the tix repository in the
|
||||||
.Ar source
|
.Ar source
|
||||||
directory, as well as all the ports found.
|
directory, as well as all the ports found.
|
||||||
|
Upgrade hooks will be run if further actions are needed to migrate the system to
|
||||||
|
the new version as described in
|
||||||
|
.Xr following-development 7 .
|
||||||
The
|
The
|
||||||
.Xr initrd 7
|
.Xr initrd 7
|
||||||
is regenerated using
|
is regenerated using
|
||||||
|
@ -41,8 +44,7 @@ It is meant to be used as part of the development process to upgrade to locally
|
||||||
built versions.
|
built versions.
|
||||||
The
|
The
|
||||||
.Xr sysupgrade 8
|
.Xr sysupgrade 8
|
||||||
program is by contrast an interactive program, meant to help upgrading across
|
program is by contrast an interactive program.
|
||||||
much larger development distances.
|
|
||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width "12345678"
|
.Bl -tag -width "12345678"
|
||||||
|
@ -67,14 +69,14 @@ directory and restore the old
|
||||||
and
|
and
|
||||||
.Xr initrd 7 .
|
.Xr initrd 7 .
|
||||||
.It Fl \-hook-finalize
|
.It Fl \-hook-finalize
|
||||||
Run the pre-installation compatibility hooks.
|
Run the post-upgrade hooks.
|
||||||
This is meant to be used by the old
|
This is meant to be used by the old
|
||||||
.Nm
|
.Nm
|
||||||
when it invokes the new
|
when it invokes the new
|
||||||
.Nm
|
.Nm
|
||||||
during a non-waiting upgrade.
|
during a non-waiting upgrade.
|
||||||
.It Fl \-hook-prepare
|
.It Fl \-hook-prepare
|
||||||
Run the post-prepare compatibility hooks.
|
Run the pre-upgrade hooks.
|
||||||
This is meant to be used by the old
|
This is meant to be used by the old
|
||||||
.Nm
|
.Nm
|
||||||
when it invokes the new
|
when it invokes the new
|
||||||
|
@ -124,6 +126,8 @@ the current system release
|
||||||
.It Pa /etc/upgrade.conf
|
.It Pa /etc/upgrade.conf
|
||||||
controls the bootloader upgrade behavior (see
|
controls the bootloader upgrade behavior (see
|
||||||
.Xr upgrade.conf 5 )
|
.Xr upgrade.conf 5 )
|
||||||
|
.It Pa /share/sysinstall/hooks
|
||||||
|
A file per upgrade hook indicating that it doesn't need to be run.
|
||||||
.It Pa /sysmerge
|
.It Pa /sysmerge
|
||||||
pending upgrade is stored here
|
pending upgrade is stored here
|
||||||
.El
|
.El
|
||||||
|
|
|
@ -278,13 +278,11 @@ int main(int argc, char* argv[])
|
||||||
new_release.pretty_name, source);
|
new_release.pretty_name, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibility hooks that runs before the old system is replaced.
|
// Upgrade hooks that runs before the old system is replaced.
|
||||||
if ( run_prepare )
|
if ( run_prepare )
|
||||||
{
|
{
|
||||||
if ( my_prepare )
|
if ( my_prepare )
|
||||||
{
|
upgrade_prepare(&old_release, &new_release, source, "");
|
||||||
upgrade_prepare(&old_release, &new_release, source, "/");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* new_sysmerge = join_paths(source, "sbin/sysmerge");
|
char* new_sysmerge = join_paths(source, "sbin/sysmerge");
|
||||||
|
@ -331,13 +329,11 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibility hooks that run after the new system is installed.
|
// Upgrade hooks that run after the new system is installed.
|
||||||
if ( run_finalize )
|
if ( run_finalize )
|
||||||
{
|
{
|
||||||
if ( my_finalize )
|
if ( my_finalize )
|
||||||
{
|
upgrade_finalize(&old_release, &new_release, source, "");
|
||||||
upgrade_finalize(&old_release, &new_release, source, "/");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* new_sysmerge = join_paths(source, "sbin/sysmerge");
|
char* new_sysmerge = join_paths(source, "sbin/sysmerge");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2016, 2021 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2015, 2016, 2020, 2021 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -807,7 +807,7 @@ int main(void)
|
||||||
// untracked or moved from one manifest to another.
|
// untracked or moved from one manifest to another.
|
||||||
if ( conf.system )
|
if ( conf.system )
|
||||||
{
|
{
|
||||||
upgrade_prepare(target_release, &new_release, "/", "");
|
upgrade_prepare(target_release, &new_release, "", ".");
|
||||||
install_manifest("system", "", ".");
|
install_manifest("system", "", ".");
|
||||||
}
|
}
|
||||||
if ( has_manifest("src") )
|
if ( has_manifest("src") )
|
||||||
|
@ -848,7 +848,7 @@ int main(void)
|
||||||
if ( conf.ports )
|
if ( conf.ports )
|
||||||
install_ports("", ".");
|
install_ports("", ".");
|
||||||
if ( conf.system )
|
if ( conf.system )
|
||||||
upgrade_finalize(target_release, &new_release, "/", "");
|
upgrade_finalize(target_release, &new_release, "", ".");
|
||||||
if ( conf.system )
|
if ( conf.system )
|
||||||
{
|
{
|
||||||
printf(" - Creating initrd...\n");
|
printf(" - Creating initrd...\n");
|
||||||
|
|
Loading…
Reference in a new issue