From 3f924b22a682c8f7042c99ddc8db815ec6ae0ccd Mon Sep 17 00:00:00 2001 From: Sherif Nagy Date: Sat, 17 Dec 2022 23:23:41 +0000 Subject: [PATCH] Init R8 --- README.md | 4 ++- Rocky-8-aarch64-generic-Minimal.ks | 3 ++ createimage.sh | 20 +++++++++++++ includes/basecommon8.ksi | 10 +++++++ includes/gen-packages8.ksi | 16 +++++++++++ includes/gen-partitions8.ksi | 6 ++++ includes/gen-postcommon8.ksi | 45 ++++++++++++++++++++++++++++++ includes/gen-reposcommon8.ksi | 1 + includes/gen-rockycommon8.ksi | 9 ++++++ includes/packages8.ksi | 17 +++++++++++ includes/postcommon8.ksi | 10 +++++++ includes/precommon8.ksi | 4 +++ includes/rockyreadme8.ksi | 11 ++++++++ includes/rockyrepos8.ksi | 6 ++++ includes/rootfs-expand.ksi | 36 ++++++++++++++++++++++++ 15 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 Rocky-8-aarch64-generic-Minimal.ks create mode 100644 createimage.sh create mode 100644 includes/basecommon8.ksi create mode 100644 includes/gen-packages8.ksi create mode 100644 includes/gen-partitions8.ksi create mode 100644 includes/gen-postcommon8.ksi create mode 100644 includes/gen-reposcommon8.ksi create mode 100644 includes/gen-rockycommon8.ksi create mode 100644 includes/packages8.ksi create mode 100644 includes/postcommon8.ksi create mode 100644 includes/precommon8.ksi create mode 100644 includes/rockyreadme8.ksi create mode 100644 includes/rockyrepos8.ksi create mode 100644 includes/rootfs-expand.ksi diff --git a/README.md b/README.md index c07819c..5097e37 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -This repo to hold the KS to generate generic aarch64 rocky images for SoC such as RPI, Rockchip and others... +# Kickstarts + +KickStart repo based on https://github.com/psgreco/all-kickstarts/tree/wip-generic diff --git a/Rocky-8-aarch64-generic-Minimal.ks b/Rocky-8-aarch64-generic-Minimal.ks new file mode 100644 index 0000000..1cf6cf8 --- /dev/null +++ b/Rocky-8-aarch64-generic-Minimal.ks @@ -0,0 +1,3 @@ +%include includes/rockyrepos8.ksi +%include includes/gen-reposcommon8.ksi +%include includes/gen-rockycommon8.ksi diff --git a/createimage.sh b/createimage.sh new file mode 100644 index 0000000..b0be047 --- /dev/null +++ b/createimage.sh @@ -0,0 +1,20 @@ +#!/bin/bash +KSFILE=$1 +KSNAME=${KSFILE%.ks} + +if [ ! -f "${KSFILE}" ]; then + echo + echo "SYNOPSIS" + echo " $0 " + echo + echo "EXAMPLE" + echo " $0 Rocky-Userland-8-aarch64-Generic-Minimal-4.ks" + echo + exit 1 +fi + +set -x +appliance-creator -c ${KSFILE} \ + -d -v --logfile /var/tmp/${KSNAME}.log \ + --cache /root/cache --no-compress \ + -o /var/tmp/appoutput --format raw --name ${KSNAME} | tee /var/tmp/${KSNAME}.log.2 diff --git a/includes/basecommon8.ksi b/includes/basecommon8.ksi new file mode 100644 index 0000000..2788eb5 --- /dev/null +++ b/includes/basecommon8.ksi @@ -0,0 +1,10 @@ +install +keyboard us --xlayouts=us --vckeymap=us +timezone --isUtc --nontp UTC +selinux --enforcing +firewall --enabled --port=22:tcp +network --bootproto=dhcp --device=link --activate --onboot=on +services --enabled=sshd,NetworkManager,chronyd +shutdown +bootloader --location=mbr --driveorder=sda +lang en_US.UTF-8 diff --git a/includes/gen-packages8.ksi b/includes/gen-packages8.ksi new file mode 100644 index 0000000..544ee80 --- /dev/null +++ b/includes/gen-packages8.ksi @@ -0,0 +1,16 @@ +# Package setup +%packages +dracut-config-generic +kernel +kernel-core +grub2-common +grub2-efi-aa64 +grub2-efi-aa64-modules +grubby +efibootmgr +shim-aa64 +systemd-udev +uboot-tools +-dracut-config-rescue + +%end diff --git a/includes/gen-partitions8.ksi b/includes/gen-partitions8.ksi new file mode 100644 index 0000000..e7507fc --- /dev/null +++ b/includes/gen-partitions8.ksi @@ -0,0 +1,6 @@ +# Disk setup +clearpart --initlabel --all +part /boot/efi --asprimary --fstype=efi --size=512 +part /boot --asprimary --fstype=ext4 --size=1024 --label=boot +part swap --asprimary --fstype=swap --size=512 --label=swap +part / --asprimary --fstype=ext4 --size=3072 --label=rootfs diff --git a/includes/gen-postcommon8.ksi b/includes/gen-postcommon8.ksi new file mode 100644 index 0000000..e22fafd --- /dev/null +++ b/includes/gen-postcommon8.ksi @@ -0,0 +1,45 @@ +%post +# Setting correct yum variable to use raspberrypi kernel repo +#echo "generic" > /etc/dnf/vars/kvariant +# +# Generic efi filename for VMs +mkdir -p /boot/efi/EFI/BOOT +if [ -f /boot/efi/EFI/rocky/grubaa64.efi ];then + cp -f /boot/efi/EFI/rocky/grubaa64.efi /boot/efi/EFI/BOOT/BOOTAA64.EFI +fi + +cp -f /usr/share/uboot/rpi_3/u-boot.bin /boot/efi/rpi3-u-boot.bin +cp -f /usr/share/uboot/rpi_4/u-boot.bin /boot/efi/rpi4-u-boot.bin + +rpm -e dracut-config-generic + +#setup dtb link by running "creating 10-devicetree.install" +if [ -x /lib/kernel/install.d/10-devicetree.install ];then + /lib/kernel/install.d/10-devicetree.install remove +fi + +### Write /etc/sysconfig/kernel +cat << EOF > /etc/sysconfig/kernel +# Written by image installer +# UPDATEDEFAULT specifies if new-kernel-pkg should make new kernels the default +UPDATEDEFAULT=yes + +# DEFAULTKERNEL specifies the default kernel package type +DEFAULTKERNEL=kernel-core +EOF +chmod 644 /etc/sysconfig/kernel + +### Write grub defaults, turn off OS probing as it is always wrong for image creation +cat << EOF > /etc/default/grub +GRUB_TIMEOUT=5 +GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" +GRUB_DEFAULT=saved +GRUB_DISABLE_SUBMENU=true +GRUB_TERMINAL_OUTPUT="console" +GRUB_CMDLINE_LINUX="" +GRUB_DISABLE_RECOVERY="true" +GRUB_DISABLE_OS_PROBER="true" +GRUB_ENABLE_BLSCFG="false" +EOF +chmod 644 /etc/default/grub +%end diff --git a/includes/gen-reposcommon8.ksi b/includes/gen-reposcommon8.ksi new file mode 100644 index 0000000..0bab7f1 --- /dev/null +++ b/includes/gen-reposcommon8.ksi @@ -0,0 +1 @@ +repo --name="instKern" --baseurl=https://rockyrepos.gnulab.org/gen_aarch64_el8/ --cost=100 --install diff --git a/includes/gen-rockycommon8.ksi b/includes/gen-rockycommon8.ksi new file mode 100644 index 0000000..d791100 --- /dev/null +++ b/includes/gen-rockycommon8.ksi @@ -0,0 +1,9 @@ +rootpw --plaintext rocky +%include includes/basecommon8.ksi +%include includes/gen-partitions8.ksi +%include includes/packages8.ksi +%include includes/gen-packages8.ksi +%include includes/precommon8.ksi +%include includes/rockyreadme8.ksi +%include includes/gen-postcommon8.ksi +%include includes/postcommon8.ksi diff --git a/includes/packages8.ksi b/includes/packages8.ksi new file mode 100644 index 0000000..699a20d --- /dev/null +++ b/includes/packages8.ksi @@ -0,0 +1,17 @@ +# Package setup +%packages +@core +chrony +cloud-utils-growpart +net-tools +NetworkManager-wifi +nano +bash-completion +uboot-images-armv8 +bcm2711-firmware +bcm2835-firmware +bcm283x-firmware +bcm283x-overlays +-java-11-* + +%end diff --git a/includes/postcommon8.ksi b/includes/postcommon8.ksi new file mode 100644 index 0000000..a700e20 --- /dev/null +++ b/includes/postcommon8.ksi @@ -0,0 +1,10 @@ +%post +# Remove ifcfg-link on pre generated images +rm -f /etc/sysconfig/network-scripts/ifcfg-link + +# Remove machine-id on pre generated images +rm -f /etc/machine-id +touch /etc/machine-id + +%end +%include includes/rootfs-expand.ksi diff --git a/includes/precommon8.ksi b/includes/precommon8.ksi new file mode 100644 index 0000000..1dc6221 --- /dev/null +++ b/includes/precommon8.ksi @@ -0,0 +1,4 @@ +%pre + +#End of Pre script for partitions +%end diff --git a/includes/rockyreadme8.ksi b/includes/rockyreadme8.ksi new file mode 100644 index 0000000..10869a8 --- /dev/null +++ b/includes/rockyreadme8.ksi @@ -0,0 +1,11 @@ +%post +# Mandatory README file +cat >/root/README << EOF +== Rocky Linux 8 == + +If you want to automatically resize your / partition, just type the following (as root user): +rootfs-expand + +EOF + +%end diff --git a/includes/rockyrepos8.ksi b/includes/rockyrepos8.ksi new file mode 100644 index 0000000..c7fd33e --- /dev/null +++ b/includes/rockyrepos8.ksi @@ -0,0 +1,6 @@ +# Basic setup information +url --url="https://download.rockylinux.org/pub/rocky/8/BaseOS/aarch64/os/" +# Repositories to use +repo --name="rocky8-baseos" --baseurl=https://download.rockylinux.org/pub/rocky/8/BaseOS/aarch64/os/ +repo --name="rocky8-appstream" --baseurl=https://download.rockylinux.org/pub/rocky/8/AppStream/aarch64/os/ +repo --name="rocky8-powertools" --baseurl=https://download.rockylinux.org/pub/rocky/8/PowerTools/aarch64/os/ diff --git a/includes/rootfs-expand.ksi b/includes/rootfs-expand.ksi new file mode 100644 index 0000000..cf08239 --- /dev/null +++ b/includes/rootfs-expand.ksi @@ -0,0 +1,36 @@ +%post +cat >/usr/local/bin/rootfs-expand << EOF + +#!/bin/bash +clear +part=\$(mount |grep '^/dev.* / ' |awk '{print \$1}') +if [ -z "\$part" ];then + echo "Error detecting rootfs" + exit -1 +fi +dev=\$(echo \$part|sed 's/[0-9]*\$//g') +devlen=\${#dev} +num=\${part:\$devlen} +if [[ "\$dev" =~ ^/dev/mmcblk[0-9]*p\$ ]];then + dev=\${dev:0:-1} +fi +if [ ! -x /usr/bin/growpart ];then + echo "Please install cloud-utils-growpart (sudo yum install cloud-utils-growpart)" + exit -2 +fi +if [ ! -x /usr/sbin/resize2fs ];then + echo "Please install e2fsprogs (sudo yum install e2fsprogs)" + exit -3 +fi +echo \$part \$dev \$num + +echo "Extending partition \$num to max size ...." +growpart \$dev \$num +echo "Resizing ext4 filesystem ..." +resize2fs \$part +echo "Done." +df -h |grep \$part +EOF + +chmod +x /usr/local/bin/rootfs-expand +%end