Skip to content

make-disk-image: pre/post-format-files copies content of source path #1079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sedlund
Copy link
Contributor

@sedlund sedlund commented Jun 24, 2025

Problem

diskoImagesScripts --pre-format-files destination does not work when its only one level deep


when using diskoImagesScript --pre-format-files using a destination of one path deep

nix build .#checks.x86_64-linux.make-disk-image-luks-interactive-impure (diskoImagesScript)

./result --pre-format-files $PWD/pre /tmp
----------8<-------8<-------------
++ for src in /tmp/xchg/copy_before_disko/*
++ '[' -e /tmp/xchg/copy_before_disko/L3RtcAo= ']'
+++ basename /tmp/xchg/copy_before_disko/L3RtcAo=
+++ base64 -d
++ dst=/tmp
+++ dirname /tmp
++ mkdir -p /
++ cp -rv /tmp/xchg/copy_before_disko/L3RtcAo= /tmp
'/tmp/xchg/copy_before_disko/L3RtcAo=' -> '/tmp/L3RtcAo='
'/tmp/xchg/copy_before_disko/L3RtcAo=/secret.key' -> '/tmp/L3RtcAo=/secret.key'
----------8<-------8<-------------
+ passwordFile=/tmp/secret.key
----------8<-------8<-------------
+ cryptsetup -q luksFormat /dev/disk/by-partlabel/disk-main-luks --key-file /dev/fd/63
cat: /tmp/secret.key: No such file or directory
Nothing to read on input.
+ rm -rf /tmp/tmp.vQKPk8IlAw
[    9.533714] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
----------8<-------8<-------------

Two levels deep looks like this

./result --pre-format-files $PWD/pre /tmp/pre
----------8<-------8<-------------
++ for src in /tmp/xchg/copy_before_disko/*
++ '[' -e /tmp/xchg/copy_before_disko/L3RtcC9wcmUK ']'
+++ basename /tmp/xchg/copy_before_disko/L3RtcC9wcmUK
+++ base64 -d
++ dst=/tmp/pre
+++ dirname /tmp/pre
++ mkdir -p /tmp
++ cp -rv /tmp/xchg/copy_before_disko/L3RtcC9wcmUK /tmp/pre
'/tmp/xchg/copy_before_disko/L3RtcC9wcmUK' -> '/tmp/pre'
'/tmp/xchg/copy_before_disko/L3RtcC9wcmUK/secret.key' -> '/tmp/pre/secret.key'

Solution

cp content of src, remove dirname from mkdir to make the full destination path

./result --pre-format-files $PWD/pre /tmp
----------8<-------8<-------------
++ for src in /tmp/xchg/copy_before_disko/*
++ '[' -e /tmp/xchg/copy_before_disko/L3RtcAo= ']'
+++ basename /tmp/xchg/copy_before_disko/L3RtcAo=
+++ base64 -d
++ dst=/tmp
++ mkdir -p /tmp
++ cp -rv /tmp/xchg/copy_before_disko/L3RtcAo=/. /tmp
'/tmp/xchg/copy_before_disko/L3RtcAo=/./secret.key' -> '/tmp/./secret.key'
----------8<-------8<-------------
installation finished!
++ umount -Rv /mnt
umount: /mnt/boot unmounted
umount: /mnt unmounted
[   68.424421] reboot: Power down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant