serhepopovych / simple-cdd-meta

Debian and it's derivatives Simple-CDD preseed configuration with profiles
MIT License
6 stars 3 forks source link

Add support for local files that should be included to installed system #28

Closed serhepopovych closed 6 months ago

serhepopovych commented 3 years ago

Local packages supported with packages/ subdirectory and handled by simple-cdd natively.

Adding specific files (e.g. configuration) to installed system is tricky. There only two ways known to us: 1) Put required file(s) together with profile and add it's name to .extra to make simple-cdd to add this file to ISO. Later during install phase access this file in /simple-cdd/ somehow, but not from simple-cdd .postinst as it is executed in-target (i.e. chroot /target) system and ISO image most likely unmounted at that time. All above makes this way not reliable. Especially for cases where whole directory structures needs to be installed. 2) Inline file(s) or cpio(1)/tar(1) archive, either as is or base64(1) encoded, to .postinst with corresponding commands to unpack them:

        base64 -d -i <<'_EOF' | tar -zxf /dev/stdin -C '/etc/dir'
        <encoded data goes here>
        _EOF
This is most reliable way as simple-cdd already copies <profile>.postinst without any extra step to final ISO; this
script copied to /usr/local/simple-cdd on target during install and file(s) data embedded and available when executed
by in-target.

The only concern with (2) is that managing embedded archives isn't simple. For example to modify single file within archive you must put embedded block do dedicated file, decode it using base64(1), unpack with cpio(1), tar(1) or similar tool, modify, pack, decode and embed again. This is subject to human errors, especially when file permissions in archive isn't default (e.g. builder user or root).

Instead local files subdirectory should be introduced by analogy with one in OpenWRT ImageBuilder that has exactly same layout as we expect to see on installed system, but with additional metadata describing file system entries ownership and permissions.

Later .sh should handle contents of directory and prepare set of base64(1) archives in $simple_cdd_tmp directory and inline them to .postinst (e.g. with sed(1)) during templates/.postinst.sed to profiles/.postinst install phase.

This will simplify file modification and make process less error prone.

serhepopovych commented 6 months ago

This is implemented with e0076fdcdc453bdeb7b4099a9e0e28d6e8bd9e82.