diff options
author | Linus Heckemann <git@sphalerite.org> | 2021-03-02 13:32:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 13:32:26 +0100 |
commit | 08fc5e317c10f7eb5255fd4394e09a4e18879efe (patch) | |
tree | 7a01d805888fd7b177070364f30c8830b3287d05 | |
parent | a676907ae34dde607f3b9e5e76d6223d8c7dcc53 (diff) | |
parent | aed7c9a22a8e9c28735a903359a948e50b0b7eb5 (diff) | |
download | nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.tar nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.tar.gz nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.tar.bz2 nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.tar.lz nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.tar.xz nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.tar.zst nixpkgs-08fc5e317c10f7eb5255fd4394e09a4e18879efe.zip |
Merge pull request #111802 from twhitehead/init-symlinks
nixos/stage1: chroot stage 2 init exists check so symlink resolve
-rw-r--r-- | nixos/modules/system/boot/stage-1-init.sh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh index 5b39f34200c..ddaf985878e 100644 --- a/nixos/modules/system/boot/stage-1-init.sh +++ b/nixos/modules/system/boot/stage-1-init.sh @@ -614,11 +614,16 @@ echo /sbin/modprobe > /proc/sys/kernel/modprobe # Start stage 2. `switch_root' deletes all files in the ramfs on the -# current root. Note that $stage2Init might be an absolute symlink, -# in which case "-e" won't work because we're not in the chroot yet. -if [ ! -e "$targetRoot/$stage2Init" ] && [ ! -L "$targetRoot/$stage2Init" ] ; then - echo "stage 2 init script ($targetRoot/$stage2Init) not found" - fail +# current root. The path has to be valid in the chroot not outside. +if [ ! -e "$targetRoot/$stage2Init" ]; then + stage2Check=${stage2Init} + while [ "$stage2Check" != "${stage2Check%/*}" ] && [ ! -L "$targetRoot/$stage2Check" ]; do + stage2Check=${stage2Check%/*} + done + if [ ! -L "$targetRoot/$stage2Check" ]; then + echo "stage 2 init script ($targetRoot/$stage2Init) not found" + fail + fi fi mkdir -m 0755 -p $targetRoot/proc $targetRoot/sys $targetRoot/dev $targetRoot/run |