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
93 stars 11 forks source link

create.sh stopps with syntax error during configuring cloud-init #51

Closed gaissmai closed 11 months ago

gaissmai commented 11 months ago

Hi, I get the following error during builiding the image:

chroot:   Configure doas
chroot:     Adding doas configuration for root user
chroot:     Enabling doas configuration for wheel group
chroot: Configuring cloud-init
/bin/sh: syntax error: unexpected end of file (expecting "}")

AN ERROR OCCURRED, cleaning up before aborting!

I cloned the main branch with git SHA c15bd5b.

the hostsystem is:

PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy

the command was:


$ ./create-alpine-disk-image --cloud generic --script-filename create.sh --release 3.18
$ sudo bash ./create.sh

Thanks for any hint. Charly

gaissmai commented 11 months ago

ah, I see, it's still in development, just a hint, the script create-alpine-disk-image doesn't finish the create.sh script. Still some bugs lurking.

dermotbradley commented 11 months ago

ah, I see, it's still in development, just a hint, the script create-alpine-disk-image doesn't finish the create.sh script. Still some bugs lurking.

Whilst there is ongoing development of the script it is however intended to be functional - indeed I use it basically every day.

I am currently investigating the issue you have reported, I can reproduce it, and I hope to have a fix in a matter of hours.

dermotbradley commented 11 months ago

The problem you reported should now be fixed.

gaissmai commented 11 months ago

Hi, the create-alpine-disk-image now finishes creating the create.sh script, but there is still a syntax error in the generated script:

$ git rev-parse --short HEAD
bbfb686

$ ./create-alpine-disk-image --cloud generic --script-filename create.sh --release 3.18

create-alpine-disk-image version 0.3-DEV

Using the following settings:

  Image arch: x86_64
  Image class: cloud, Cloud type: generic
  Config software type: cloud-init

  Alpine release: v3.18

  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'.

but again, in the chroot section lurks still a syntax error:

$ sudo bash ./create.sh 
Creating sparse disk image of 318MiB
Partitioning disk image for BIOS
Setting up loop device for disk image
  Ensuring that loop driver is loaded (if necessary)
  Setting up loop device with 512-byte sector size for disk image
Formatting and mounting filesystems
  Formatting Ext4 root filesystem on partition
  Mounting root filesystem onto ./chroot
Downloading statically built APK tool for x86_64 arch
Copying system's /etc/resolv.conf into chroot filesystem
Creating /etc/apk/repositories file inside chroot
Bootloader packages to be installed are: grub grub-bios
Install base Alpine & bootloader packages for x86_64 arch inside chroot
deleting the temporary CA directory
Mounting tmp, /proc, /sys, and /dev special filesystems in chroot
chroot: Add /etc/fstab entries
chroot:   Add /tmp on tmpfs entry
chroot:   Add rootfs entry
chroot: Adding additional repos
chroot:   Adding community repo to /etc/apk/repositories
chroot: Updating packages info
chroot:   Updating packages list
chroot:   Upgrading base packages if necessary
chroot: Doing basic OS configuration
/bin/sh: syntax error: unexpected end of file (expecting "}")
Finished chroot section
Removing temporary /etc/resolv.conf from chroot filesystem
mv: cannot stat './chroot/final-packages.list': No such file or directory
Cleaning up
Normal cleanup
  Unmounting /tmp inside chroot
  Unmounting /dev inside chroot
  Unmounting /sys inside chroot
  Unmounting /proc inside chroot
  Unmounting root filesystem inside chroot
  Freeing up loop device '/dev/loop1'

the host system is:

PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
dermotbradley commented 11 months ago

Yeah I noticed that myself shortly after pushing the last update (that problem only showed up when the script was run without the "--debug" option).

I've just pushed another PR with that fixed (and some other issues).

I've verified that I'm able to create a disk image using the options you originally indicated.

Sorry for these teething problems, I need to work on a more automated testing mechanism for at least at selection of the script's options.

gaissmai commented 11 months ago

thanks for fixing it!