From: Daan De Meyer Date: Mon, 25 Sep 2023 07:48:09 +0000 (+0200) Subject: Rename $SCRIPT to $CHROOT_SCRIPT X-Git-Tag: v18~44^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c009af9eff2dcf791a141b27effdf55e4cd461b;p=thirdparty%2Fmkosi.git Rename $SCRIPT to $CHROOT_SCRIPT This refers to a path in the chroot so let's make sure the naming is consistent. We keep the old name as well for now to keep backwards compat. --- diff --git a/NEWS.md b/NEWS.md index e93431d22..a5b40c9d4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # mkosi Changelog +## v18 + +- `$SCRIPT` was renamed in favor of `$CHROOT_SCRIPT`. `$SCRIPT` can + still be used but is considered deprecated. + ## v17.1 - Fixed bug where `--autologin` was broken when used in combination with diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 1289e5ac8..ebbabf111 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -261,6 +261,7 @@ def run_prepare_script(state: MkosiState, build: bool) -> None: env = dict( SCRIPT="/work/prepare", + CHROOT_SCRIPT="/work/prepare", SRCDIR=str(Path.cwd()), CHROOT_SRCDIR="/work/src", BUILDROOT=str(state.root), @@ -310,6 +311,7 @@ def run_build_script(state: MkosiState) -> None: WITH_TESTS=one_zero(state.config.with_tests), WITH_NETWORK=one_zero(state.config.with_network), SCRIPT="/work/build-script", + CHROOT_SCRIPT="/work/build-script", SRCDIR=str(Path.cwd()), CHROOT_SRCDIR="/work/src", DESTDIR=str(state.install_dir), @@ -361,6 +363,7 @@ def run_postinst_script(state: MkosiState) -> None: env = dict( SCRIPT="/work/postinst", + CHROOT_SCRIPT="/work/postinst", SRCDIR=str(Path.cwd()), CHROOT_SRCDIR="/work/src", OUTPUTDIR=str(state.staging), @@ -399,6 +402,7 @@ def run_finalize_script(state: MkosiState) -> None: env = dict( SCRIPT="/work/finalize", + CHROOT_SCRIPT="/work/finalize", SRCDIR=str(Path.cwd()), CHROOT_SRCDIR="/work/src", OUTPUTDIR=str(state.staging), diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 091c5f6cb..85092a4a6 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -1312,8 +1312,8 @@ supported: Scripts executed by mkosi receive the following environment variables: -* `$SCRIPT` contains the path to the running script relative to the - image root directory. The primary usecase for this variable is in +* `$CHROOT_SCRIPT` contains the path to the running script relative to + the image root directory. The primary usecase for this variable is in combination with the `mkosi-chroot` script. See the description of `mkosi-chroot` below for more information. @@ -1369,20 +1369,21 @@ available via `$PATH` to simplify common usecases. * `mkosi-chroot`: This script will chroot into the image and execute the given command. On top of chrooting into the image, it will also mount various files and directories (`$SRCDIR`, `$DESTDIR`, `$BUILDDIR`, - `$OUTPUTDIR`, `$SCRIPT`) into the image and modify the corresponding - environment variables to point to the locations inside the image. It - will also mount APIVFS filesystems (`/proc`, `/dev`, ...) to make sure - scripts and tools executed inside the chroot work properly. It also - propagates `/etc/resolv.conf` from the host into the chroot if - requested so that DNS resolution works inside the chroot. After the - mkosi-chroot command exits, various mount points are cleaned up. + `$OUTPUTDIR`, `$CHROOT_SCRIPT`) into the image and modify the + corresponding environment variables to point to the locations inside + the image. It will also mount APIVFS filesystems (`/proc`, `/dev`, + ...) to make sure scripts and tools executed inside the chroot work + properly. It also propagates `/etc/resolv.conf` from the host into the + chroot if requested so that DNS resolution works inside the chroot. + After the mkosi-chroot command exits, various mount points are cleaned + up. To execute the entire script inside the image, put the following snippet at the start of the script: ```sh if [ "$container" != "mkosi" ]; then - exec mkosi-chroot "$SCRIPT" "$@" + exec mkosi-chroot "$CHROOT_SCRIPT" "$@" fi ``` @@ -1644,7 +1645,7 @@ $ cat >mkosi.build <