disko icon indicating copy to clipboard operation
disko copied to clipboard

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

Open sedlund opened this issue 6 months ago • 0 comments

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

sedlund avatar Jun 24 '25 05:06 sedlund