dermotbradley / create-alpine-disk-image

Create cloud-init enabled Alpine disk images for physical machines (PCs & RPIs), VMs, and Cloud servers
GNU General Public License v2.0
94 stars 11 forks source link

Order / presence of command-line options matters #54

Open skoenig opened 3 months ago

skoenig commented 3 months ago

Hi - it appears that, contrary to the documentation, certain command line options besides --script-filename are also mandatory. When I run the script as shown in the first example, it throws an error:

./create-alpine-disk-image --script-filename create.sh

create-alpine-disk-image version 0.3-DEV
./create-alpine-disk-image: 18: readonly: CADI_DEFAULT_ESP_PART_SIZE: is read only

The error occurs due to the missing --arch option, which leads to double-sourcing of ./definitions/virtual//defines and attempts to reassign read-only variables (see error.log).

Also, the order of options matters. Here is a working example with a couple of more options that leads to the same issue:

./create-alpine-disk-image --script-filename create.sh \
     --virtual generic \
     --cloud-configuration-type none 

create-alpine-disk-image version 0.3-DEV
./create-alpine-disk-image: 18: readonly: CADI_DEFAULT_ESP_PART_SIZE: is read only

When reversing the order of the two additional command-line options, the script runs successfully:

/create-alpine-disk-image --script-filename create.sh \
    --cloud-configuration-type none \
    --virtual generic

create-alpine-disk-image version 0.3-DEV

Using the following settings:

  Image arch: x86_64
  Image class: virtual, VM type: generic
  Config software type: none

  Alpine release: edge

  OS device type: generic       OS device media: disk
  OS device sector size: 512 bytes

  Boot type: bios           Bootloader: grub
  Root filesystem type: ext4

  Console device type: generic  Console output type: generic
  Keyboard type: generic
  Enable graphics: false

  Cron daemon: busybox      DHCP client: generic
  Login package: util-linux NTP daemon: chrony
  SSH daemon: openssh       Syslog server: rsyslog
  User management: shadow

Created tailored script 'create.sh'.
This script must be run as user 'root'.

So there is some weird option parsing going on here.

dermotbradley commented 3 months ago

Hello.

Unfortunately, as of a few months ago, I stopped my official involvement in Alpine and dropped maintainership of the Alpine packages I used to look after.

I still am using and developing/expanding this script locally (as I'm also still using Alpine, though in a modified form) but I'm no longer posting updates to it here on Github, partly because the current version of the script now makes use of quite a few modified (including changes that Alpine devs wouldn't accept) locally-hosted Alpine packages.

I guess I should add a note regarding that to the README.