[neon/ubuntu-core/Neon/image_production] /: Add ISO image generation
Benjamin Port
null at kde.org
Sun Aug 11 08:56:58 BST 2024
Git commit af9ecf2988b9056518dd3fc6ad525803c126fd9b by Benjamin Port.
Committed on 02/08/2024 at 16:53.
Pushed by carlosdem into branch 'Neon/image_production'.
Add ISO image generation
M +6 -0 .gitignore
M +19 -1 Makefile
M +6 -0 README.md
A +125 -0 create_iso.sh
A +1 -0 image/99-custom-networking.cfg
A +12 -0 image/autoinstall.yaml
A +3 -0 image/casper-enable
A +43 -0 image/casper-stop
A +16 -0 image/casper.service
A +83 -0 image/core-desktop.yaml
A +83 -0 image/core-desktop.yaml.in
A +5 -0 image/gtk-3.0-settings.ini
A +12 -0 image/install-sources.yaml.in
A +8 -0 image/override.conf
https://invent.kde.org/neon/ubuntu-core/-/commit/af9ecf2988b9056518dd3fc6ad525803c126fd9b
diff --git a/.gitignore b/.gitignore
index de252d6..ced329e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,8 @@
local-snaps/*
+image/install-sources.yaml
+image/core-desktop.yaml
+image2/*
+output/*
*-signed-*.json
*-dangerous-*.json
*.snap-list
@@ -6,3 +10,5 @@ local-snaps/*
*.model.build
*.img
*.tar.gz
+*.xz
+*.iso
diff --git a/Makefile b/Makefile
index 723cde4..25ede40 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,12 @@ all: dangerous signed
dangerous: kde-neon-core-dangerous-amd64.tar.gz
+dangerous-iso: kde-neon-core-dangerous-amd64.iso
+
signed: kde-neon-core-signed-amd64.tar.gz
+signed-iso: kde-neon-core-signed-amd64.iso
+
kde-neon-core-signed-amd64.json: kde-neon-core-amd64.json
./finalize-json.sh signed $< $@
@@ -28,8 +32,22 @@ kde-neon-core-dangerous-amd64.snap-list: kde-neon-core-amd64.json
%.tar.gz: %.img
tar zcvf $@ $<
+%.img.xz: %.img
+ echo "generate xz file"
+ xz --force --threads=0 -vv $<
+
+%.installer.img: %.img.xz
+ -rm -rf output/
+ cat image/install-sources.yaml.in |sed "s/@SIZE@/$(shell stat -c%s $<)/g" > image/install-sources.yaml
+ cat image/core-desktop.yaml.in |sed "s/@PATH@/$</g" > image/core-desktop.yaml
+ sudo ubuntu-image classic --debug -O output/ image/core-desktop.yaml
+ mv output/plasma-core-desktop-22-amd64.img $@
+
+%.iso: %.installer.img
+ sudo ./create_iso.sh $<
+
clean:
- rm -rf *.model.build
+ rm -rf *.model.build image2
rm -f *.snap-list *.model *.img *.tar.gz *-signed-*.json *-dangerous-*.json
.PHONY: all clean dangerous signed
diff --git a/README.md b/README.md
index ae5a951..805be1c 100644
--- a/README.md
+++ b/README.md
@@ -53,3 +53,9 @@ For running images:
* qemu-system-x86_64
+## Generating ISO
+
+Ensure you are in a system providing apt tooling, with `xorriso` and `mtools` packages installed
+```
+make <grade>-iso
+```
diff --git a/create_iso.sh b/create_iso.sh
new file mode 100755
index 0000000..737d379
--- /dev/null
+++ b/create_iso.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+# Process obtained from https://itnext.io/how-to-create-a-custom-ubuntu-live-from-scratch-dd3b3f213f81
+
+DISK_IMAGE=$PWD/ubuntu-core-desktop-22-amd64.img
+if [ -e "$1" ]; then
+ DISK_IMAGE=$PWD/$1
+else
+ echo "Provide classic img file as first parameter"
+fi
+
+# where to mount the disk image
+CHROOT=$PWD/output/mnt
+
+mkdir -p $CHROOT
+# since we know that the partition with the data is the third one, we use awk to extract the start sector
+sudo mount -o loop,offset=$(expr 512 \* $(fdisk -l ${DISK_IMAGE} |grep img3 | awk '{print $2}')) ${DISK_IMAGE} $CHROOT
+
+# we prepare the chroot environment to ensure that everything works inside..
+sudo mount -o bind /dev ${CHROOT}/dev
+sudo mount -o bind /dev/pts ${CHROOT}/dev/pts
+sudo mount -o bind /proc ${CHROOT}/proc
+sudo mount -o bind /sys ${CHROOT}/sys
+sudo mount -o bind /run ${CHROOT}/run
+# install the required packages
+sudo chroot ${CHROOT} apt install -y casper
+# and, if needed, open a bash shell to do manual checks
+# chroot ${CHROOT} /bin/bash
+sudo umount ${CHROOT}/run
+sudo umount ${CHROOT}/sys
+sudo umount ${CHROOT}/proc
+sudo umount ${CHROOT}/dev/pts
+sudo umount ${CHROOT}/dev
+
+rm -rf $PWD/image2
+
+mkdir -p $PWD/image2/casper
+mkdir -p $PWD/image2/isolinux
+mkdir -p $PWD/image2/install
+
+sudo mv $CHROOT/cdrom/casper/* $PWD/image2/casper/
+
+sudo cp $CHROOT/boot/vmlinuz-**-**-generic image2/casper/vmlinuz
+sudo cp $CHROOT/boot/initrd.img-**-**-generic image2/casper/initrd
+
+touch image2/ubuntu
+
+cat <<EOF > image2/isolinux/grub.cfg
+
+search --set=root --file /ubuntu
+
+insmod all_video
+
+set default="0"
+set timeout=3
+
+menuentry "Install Ubuntu Core Desktop" {
+ linux /casper/vmlinuz boot=casper quiet splash ---
+ initrd /casper/initrd
+}
+EOF
+
+sudo mksquashfs $CHROOT image2/casper/filesystem.squashfs
+
+printf $(sudo du -sx --block-size=1 $CHROOT | cut -f1) > image2/casper/filesystem.size
+
+# we are done with the original disk image
+sudo umount ${CHROOT}
+rmdir ${CHROOT}
+
+cd $PWD/image2
+
+grub-mkstandalone \
+ --format=x86_64-efi \
+ --output=isolinux/bootx64.efi \
+ --locales="" \
+ --fonts="" \
+ "boot/grub/grub.cfg=isolinux/grub.cfg"
+
+(
+ cd isolinux && \
+ dd if=/dev/zero of=efiboot.img bs=1M count=10 && \
+ sudo mkfs.vfat efiboot.img && \
+ LC_CTYPE=C mmd -i efiboot.img efi efi/boot && \
+ LC_CTYPE=C mcopy -i efiboot.img ./bootx64.efi ::efi/boot/
+)
+
+grub-mkstandalone \
+ --format=i386-pc \
+ --output=isolinux/core.img \
+ --install-modules="linux16 linux normal iso9660 biosdisk memdisk search tar ls" \
+ --modules="linux16 linux normal iso9660 biosdisk search" \
+ --locales="" \
+ --fonts="" \
+ "boot/grub/grub.cfg=isolinux/grub.cfg"
+
+cat /usr/lib/grub/i386-pc/cdboot.img isolinux/core.img > isolinux/bios.img
+
+sudo /bin/bash -c "(find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt)"
+
+sudo xorriso \
+ -as mkisofs \
+ -iso-level 3 \
+ -full-iso9660-filenames \
+ -volid "Ubuntu Core Desktop" \
+ -output ${DISK_IMAGE%.*}.iso \
+ -eltorito-boot boot/grub/bios.img \
+ -no-emul-boot \
+ -boot-load-size 4 \
+ -boot-info-table \
+ --eltorito-catalog boot/grub/boot.cat \
+ --grub2-boot-info \
+ --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \
+ -eltorito-alt-boot \
+ -e EFI/efiboot.img \
+ -no-emul-boot \
+ -append_partition 2 0xef isolinux/efiboot.img \
+ -m "isolinux/efiboot.img" \
+ -m "isolinux/bios.img" \
+ -graft-points \
+ "/EFI/efiboot.img=isolinux/efiboot.img" \
+ "/boot/grub/bios.img=isolinux/bios.img" \
+ "."
+
+cd ..
diff --git a/image/99-custom-networking.cfg b/image/99-custom-networking.cfg
new file mode 100644
index 0000000..f144451
--- /dev/null
+++ b/image/99-custom-networking.cfg
@@ -0,0 +1 @@
+network: {config: disabled}
diff --git a/image/autoinstall.yaml b/image/autoinstall.yaml
new file mode 100644
index 0000000..6e6864d
--- /dev/null
+++ b/image/autoinstall.yaml
@@ -0,0 +1,12 @@
+version: 1
+source:
+ id: kde-neon-core-desktop
+ search_drivers: false
+interactive-sections:
+ - locale
+ - keyboard
+ - storage
+identity:
+ username: ubuntu
+ password: '$1$zB3Qu2ef$TKLhQpQlKRyCZGUdHFFMH/'
+ hostname: ubuntu
diff --git a/image/casper-enable b/image/casper-enable
new file mode 100755
index 0000000..7919184
--- /dev/null
+++ b/image/casper-enable
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/usr/bin/systemctl enable casper
diff --git a/image/casper-stop b/image/casper-stop
new file mode 100755
index 0000000..1de8fe1
--- /dev/null
+++ b/image/casper-stop
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Author: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre at canonical.com>
+# Tollef Fog Heen <tfheen at canonical.com>
+# Marco Amadori <marco.amadori at gmail.com>
+#
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+do_stop ()
+{
+ prompt=1
+ if grep -qs noprompt /proc/cmdline || [ -e /run/casper-no-prompt ]; then
+ prompt=
+ fi
+
+ # XXX - i18n
+ MSG="Please press ENTER then remove the installation medium: "
+ MSG_FALLBACK="Please remove the installation medium, then reboot."
+
+ if [ "$prompt" ]; then
+ if [ -x /bin/plymouth ] && plymouth --ping; then
+ chvt 63
+ plymouth message --text="$MSG"
+ clear > /dev/tty1
+ echo $MSG_FALLBACK > /dev/tty1
+ else
+ stty sane < /dev/console
+ echo $MSG > /dev/console
+ fi
+ fi
+
+ [ "$prompt" ] || return 0
+
+ if [ -x /bin/plymouth ] && plymouth --ping; then
+ plymouth watch-keystroke > /dev/null
+ else
+ read x < /dev/console
+ fi
+}
+
+do_stop
+
diff --git a/image/casper.service b/image/casper.service
new file mode 100644
index 0000000..01bac62
--- /dev/null
+++ b/image/casper.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Shuts down the "live" preinstalled system cleanly
+DefaultDependencies=no
+Before=final.target
+After=shutdown.target umount.target plymouth-halt.service plymouth-poweroff.service plymouth-reboot.service
+
+[Service]
+Type=oneshot
+ExecStart=/sbin/casper-stop
+StandardInput=tty-force
+StandardOutput=inherit
+StandardError=inherit
+TTYReset=yes
+
+[Install]
+WantedBy=final.target
diff --git a/image/core-desktop.yaml b/image/core-desktop.yaml
new file mode 100644
index 0000000..51f461c
--- /dev/null
+++ b/image/core-desktop.yaml
@@ -0,0 +1,83 @@
+name: plasma-core-desktop-amd64
+display-name: Plasma Core Desktop amd64
+revision: 1
+architecture: amd64
+series: mantic
+class: preinstalled
+kernel: linux-image-generic
+gadget:
+ url: "https://git.launchpad.net/~canonical-foundations/snap-pc/+git/github-mirror-amd64"
+ branch: classic
+ type: "git"
+rootfs:
+ components:
+ - main
+ - restricted
+ seed:
+ urls:
+ - "git://git.launchpad.net/~ubuntu-core-dev/ubuntu-seeds/+git/"
+ branch: mantic
+ names:
+ - minimal
+customization:
+ cloud-init:
+ user-data: |
+ #cloud-config
+ chpasswd:
+ expire: false
+ users:
+ - name: ubuntu
+ password: ubuntu
+ type: text
+ meta-data: |
+ #cloud-config
+ dsmode: local
+ instance_id: ubuntu-core-desktop
+ extra-packages:
+ - name: plymouth-theme-spinner
+ - name: squashfs-tools
+ - name: snapd
+ - name: cloud-init
+ - name: lshw
+ - name: yaru-theme-gtk
+ - name: gsettings-desktop-schemas
+ extra-snaps:
+ - name: ubuntu-core-desktop-installer
+ - name: core22
+ - name: snapd
+ manual:
+ make-dirs:
+ - path: /cdrom/casper
+ permissions: 0755
+ - path: /etc/systemd/system/snap.ubuntu-core-desktop-installer.miriway.service.d
+ permissions: 0755
+ - path: /etc/gtk-3.0
+ permissions: 0755
+ copy-file:
+ - source: 99-custom-networking.cfg
+ destination: /etc/cloud/cloud.cfg.d/99-custom-networking.cfg
+ - source: install-sources.yaml
+ destination: /cdrom/casper/install-sources.yaml
+ - source: autoinstall.yaml
+ destination: /autoinstall.yaml
+ - source: ../kde-neon-core-dangerous-amd64.img.xz
+ destination: /cdrom/casper/pc.img.xz
+ - source: casper.service
+ destination: /lib/systemd/system/casper.service
+ - source: casper-stop
+ destination: /sbin/casper-stop
+ - source: casper-enable
+ destination: /sbin/casper-enable
+ - source: override.conf
+ destination: /etc/systemd/system/snap.ubuntu-core-desktop-installer.miriway.service.d/override.conf
+ - source: gtk-3.0-settings.ini
+ destination: /etc/gtk-3.0/settings.ini
+ execute:
+ - path: /usr/bin/systemd-machine-id-setup
+ - path: /sbin/casper-enable
+artifacts:
+ img:
+ -
+ name: plasma-core-desktop-22-amd64.img
+ manifest:
+ name: plasma-core-desktop-pc-amd64.manifest
diff --git a/image/core-desktop.yaml.in b/image/core-desktop.yaml.in
new file mode 100644
index 0000000..a228775
--- /dev/null
+++ b/image/core-desktop.yaml.in
@@ -0,0 +1,83 @@
+name: plasma-core-desktop-amd64
+display-name: Plasma Core Desktop amd64
+revision: 1
+architecture: amd64
+series: mantic
+class: preinstalled
+kernel: linux-image-generic
+gadget:
+ url: "https://git.launchpad.net/~canonical-foundations/snap-pc/+git/github-mirror-amd64"
+ branch: classic
+ type: "git"
+rootfs:
+ components:
+ - main
+ - restricted
+ seed:
+ urls:
+ - "git://git.launchpad.net/~ubuntu-core-dev/ubuntu-seeds/+git/"
+ branch: mantic
+ names:
+ - minimal
+customization:
+ cloud-init:
+ user-data: |
+ #cloud-config
+ chpasswd:
+ expire: false
+ users:
+ - name: ubuntu
+ password: ubuntu
+ type: text
+ meta-data: |
+ #cloud-config
+ dsmode: local
+ instance_id: ubuntu-core-desktop
+ extra-packages:
+ - name: plymouth-theme-spinner
+ - name: squashfs-tools
+ - name: snapd
+ - name: cloud-init
+ - name: lshw
+ - name: yaru-theme-gtk
+ - name: gsettings-desktop-schemas
+ extra-snaps:
+ - name: ubuntu-core-desktop-installer
+ - name: core22
+ - name: snapd
+ manual:
+ make-dirs:
+ - path: /cdrom/casper
+ permissions: 0755
+ - path: /etc/systemd/system/snap.ubuntu-core-desktop-installer.miriway.service.d
+ permissions: 0755
+ - path: /etc/gtk-3.0
+ permissions: 0755
+ copy-file:
+ - source: 99-custom-networking.cfg
+ destination: /etc/cloud/cloud.cfg.d/99-custom-networking.cfg
+ - source: install-sources.yaml
+ destination: /cdrom/casper/install-sources.yaml
+ - source: autoinstall.yaml
+ destination: /autoinstall.yaml
+ - source: ../@PATH@
+ destination: /cdrom/casper/pc.img.xz
+ - source: casper.service
+ destination: /lib/systemd/system/casper.service
+ - source: casper-stop
+ destination: /sbin/casper-stop
+ - source: casper-enable
+ destination: /sbin/casper-enable
+ - source: override.conf
+ destination: /etc/systemd/system/snap.ubuntu-core-desktop-installer.miriway.service.d/override.conf
+ - source: gtk-3.0-settings.ini
+ destination: /etc/gtk-3.0/settings.ini
+ execute:
+ - path: /usr/bin/systemd-machine-id-setup
+ - path: /sbin/casper-enable
+artifacts:
+ img:
+ -
+ name: plasma-core-desktop-22-amd64.img
+ manifest:
+ name: plasma-core-desktop-pc-amd64.manifest
diff --git a/image/gtk-3.0-settings.ini b/image/gtk-3.0-settings.ini
new file mode 100644
index 0000000..5679943
--- /dev/null
+++ b/image/gtk-3.0-settings.ini
@@ -0,0 +1,5 @@
+[Settings]
+gtk-theme-name = Yaru
+gtk-icon-theme-name = Yaru
+gtk-sound-theme-name = Yaru
+gtk-icon-sizes = panel-menu-bar=24,24
diff --git a/image/install-sources.yaml.in b/image/install-sources.yaml.in
new file mode 100644
index 0000000..029189c
--- /dev/null
+++ b/image/install-sources.yaml.in
@@ -0,0 +1,12 @@
+- default: true
+ description:
+ en: KDE Neon Core Desktop.
+ id: kde-neon-core-desktop
+ locale_support: none
+ name:
+ en: KDE Neon Core Desktop
+ path: pc.img.xz
+ type: dd-xz:file
+ size: @SIZE@
+ variant: core
+
diff --git a/image/override.conf b/image/override.conf
new file mode 100644
index 0000000..e429d8d
--- /dev/null
+++ b/image/override.conf
@@ -0,0 +1,8 @@
+# /etc/systemd/system/snap.ubuntu-core-desktop-installer.miriway.service.d/override.conf
+[Unit]
+Conflicts=plymouth-quit.service getty at tty1.service
+
+[Service]
+ExecStartPre=-/usr/bin/plymouth deactivate
+ExecStartPost=/usr/bin/sleep 5
+ExecStartPost=-/usr/bin/plymouth quit --retain-splash
More information about the Neon-commits
mailing list