summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf3
-rwxr-xr-xairootfs/root/bootstrap28
-rwxr-xr-xbuild3
-rw-r--r--packages.x86_649
-rw-r--r--profiledef.sh9
-rwxr-xr-xrun_archiso174
-rwxr-xr-xtest7
8 files changed, 230 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8926638
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+tmp/
+images/
+main
diff --git a/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf b/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf
new file mode 100644
index 0000000..d1d8474
--- /dev/null
+++ b/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf
@@ -0,0 +1,3 @@
+[Service]
+ExecStart=
+ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux
diff --git a/airootfs/root/bootstrap b/airootfs/root/bootstrap
new file mode 100755
index 0000000..456345c
--- /dev/null
+++ b/airootfs/root/bootstrap
@@ -0,0 +1,28 @@
+#!/bin/bash
+set -e
+
+if ! timeout 1 curl -Is tombarrett.xyz | grep "200 OK" > /dev/null; then
+ echo "Please first connect to the internet."
+ exit
+fi
+
+if ! test -b "$1"; then
+ echo "Please pass an existing drive as an argument. ie /dev/sda"
+ exit
+fi
+
+parted -s "$1" mklabel gpt
+
+if ! test -f "/sys/firmware/efi/efivars"; then
+ parted "$1" mkpart bios ext4 0% 513MiB
+ parted "$1" set 1 bios_grub on
+ parted "$1" mkpart home ext4 513MiB 100%
+else
+ parted "$1" mkpart efi fat32 0% 513MiB
+ parted "$1" set 1 esp on
+ parted "$1" mkpart home ext4 513MiB 100%
+fi
+
+mount "$1"2 /mnt
+
+timedatectl set-ntp true
diff --git a/build b/build
new file mode 100755
index 0000000..74fe18d
--- /dev/null
+++ b/build
@@ -0,0 +1,3 @@
+#!/bin/bash
+rm -rf tmp
+mkarchiso -v -w tmp -o images .
diff --git a/packages.x86_64 b/packages.x86_64
index 251e122..8e8f80c 100644
--- a/packages.x86_64
+++ b/packages.x86_64
@@ -1,9 +1,14 @@
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
base
+bash
cloud-init
linux
+linux-firmware
mkinitcpio
mkinitcpio-archiso
openssh
+parted
+ranger
+rsync
syslinux
+vim
+wget
diff --git a/profiledef.sh b/profiledef.sh
index 7c89c0f..a44ab1a 100644
--- a/profiledef.sh
+++ b/profiledef.sh
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034
-iso_name="archlinux-baseline"
-iso_label="ARCH_$(date +%Y%m)"
-iso_publisher="Arch Linux <https://archlinux.org>"
-iso_application="Arch Linux baseline"
+iso_name="toms_arch"
+iso_label="_$(date +%Y%m)"
+iso_publisher="Tom Barrett <https://tombarrett.xyz>"
+iso_application="toms archlinux installer"
iso_version="$(date +%Y.%m.%d)"
install_dir="arch"
bootmodes=('bios.syslinux.mbr' 'bios.syslinux.eltorito' 'uefi-x64.systemd-boot.esp' 'uefi-x64.systemd-boot.eltorito')
@@ -14,4 +14,5 @@ airootfs_image_type="squashfs"
airootfs_image_tool_options=('-comp' 'xz' '-Xbcj' 'x86' '-b' '1M' '-Xdict-size' '1M')
file_permissions=(
["/etc/shadow"]="0:0:400"
+ ["/root/bootstrap"]="0:0:700"
)
diff --git a/run_archiso b/run_archiso
new file mode 100755
index 0000000..983a003
--- /dev/null
+++ b/run_archiso
@@ -0,0 +1,174 @@
+#!/usr/bin/env bash
+#
+# Copyright (C) 2020 David Runge <dvzrv@archlinux.org>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# A simple script to run an archiso image using qemu. The image can be booted
+# using BIOS or UEFI.
+#
+# Requirements:
+# - qemu
+# - edk2-ovmf (when UEFI booting)
+
+
+set -eu
+
+print_help() {
+ local usagetext
+ IFS='' read -r -d '' usagetext <<EOF || true
+Usage:
+ run_archiso [options]
+
+Options:
+ -a set accessibility support using brltty
+ -b set boot type to 'BIOS' (default)
+ -d set image type to hard disk instead of optical disc
+ -h print help
+ -i [image] image to boot into
+ -s use Secure Boot (only relevant when using UEFI)
+ -u set boot type to 'UEFI'
+ -v use VNC display (instead of default SDL)
+ -c [image] attach an additional optical disc image (e.g. for cloud-init)
+
+Example:
+ Run an image using UEFI:
+ $ run_archiso -u -i archiso-2020.05.23-x86_64.iso
+EOF
+ printf '%s' "${usagetext}"
+}
+
+cleanup_working_dir() {
+ if [[ -d "${working_dir}" ]]; then
+ rm -rf -- "${working_dir}"
+ fi
+}
+
+copy_ovmf_vars() {
+ if [[ ! -f '/usr/share/edk2-ovmf/x64/OVMF_VARS.fd' ]]; then
+ printf 'ERROR: %s\n' "OVMF_VARS.fd not found. Install edk2-ovmf."
+ exit 1
+ fi
+ cp -av -- '/usr/share/edk2-ovmf/x64/OVMF_VARS.fd' "${working_dir}/"
+}
+
+check_image() {
+ if [[ -z "$image" ]]; then
+ printf 'ERROR: %s\n' "Image name can not be empty."
+ exit 1
+ fi
+ if [[ ! -f "$image" ]]; then
+ printf 'ERROR: %s\n' "Image file (${image}) does not exist."
+ exit 1
+ fi
+}
+
+run_image() {
+ if [[ "$boot_type" == 'uefi' ]]; then
+ copy_ovmf_vars
+ if [[ "${secure_boot}" == 'on' ]]; then
+ printf '%s\n' 'Using Secure Boot'
+ local ovmf_code='/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd'
+ else
+ local ovmf_code='/usr/share/edk2-ovmf/x64/OVMF_CODE.fd'
+ fi
+ qemu_options+=(
+ '-drive' "if=pflash,format=raw,unit=0,file=${ovmf_code},readonly"
+ '-drive' "if=pflash,format=raw,unit=1,file=${working_dir}/OVMF_VARS.fd"
+ '-global' "driver=cfi.pflash01,property=secure,value=${secure_boot}"
+ )
+ fi
+
+ if [[ "${accessibility}" == 'on' ]]; then
+ qemu_options+=(
+ '-chardev' 'braille,id=brltty'
+ '-device' 'usb-braille,id=usbbrl,chardev=brltty'
+ )
+ fi
+
+ if [[ -n "${oddimage}" ]]; then
+ qemu_options+=(
+ '-device' 'scsi-cd,bus=scsi0.0,drive=cdrom1'
+ '-drive' "id=cdrom1,if=none,format=raw,media=cdrom,readonly=on,file=${oddimage}"
+ )
+ fi
+
+ qemu-system-x86_64 \
+ -boot order=d,menu=on,reboot-timeout=5000 \
+ -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \
+ -k en-us \
+ -name archiso,process=archiso_0 \
+ -device virtio-scsi-pci,id=scsi0 \
+ -device "scsi-${mediatype%rom},bus=scsi0.0,drive=${mediatype}0" \
+ -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},readonly=on,file=${image}" \
+ -display "${display}" \
+ -vga virtio \
+ -audiodev pa,id=snd0 \
+ -device ich9-intel-hda \
+ -device hda-output,audiodev=snd0 \
+ -hda main \
+ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::60022-:22 \
+ -machine type=q35,smm=on,accel=kvm,usb=on,pcspk-audiodev=snd0 \
+ -global ICH9-LPC.disable_s3=1 \
+ -enable-kvm \
+ "${qemu_options[@]}" \
+ -serial stdio \
+ -no-reboot
+}
+
+image=''
+oddimage=''
+accessibility=''
+boot_type='bios'
+mediatype='cdrom'
+secure_boot='off'
+display='sdl'
+qemu_options=()
+working_dir="$(mktemp -dt run_archiso.XXXXXXXXXX)"
+trap cleanup_working_dir EXIT
+
+if (( ${#@} > 0 )); then
+ while getopts 'abc:dhi:suv' flag; do
+ case "$flag" in
+ a)
+ accessibility='on'
+ ;;
+ b)
+ boot_type='bios'
+ ;;
+ c)
+ oddimage="$OPTARG"
+ ;;
+ d)
+ mediatype='hd'
+ ;;
+ h)
+ print_help
+ exit 0
+ ;;
+ i)
+ image="$OPTARG"
+ ;;
+ u)
+ boot_type='uefi'
+ ;;
+ s)
+ secure_boot='on'
+ ;;
+ v)
+ display='none'
+ qemu_options+=(-vnc 'vnc=0.0.0.0:0,vnc=[::]:0')
+ ;;
+ *)
+ printf '%s\n' "Error: Wrong option. Try 'run_archiso -h'."
+ exit 1
+ ;;
+ esac
+ done
+else
+ print_help
+ exit 1
+fi
+
+check_image
+run_image
diff --git a/test b/test
new file mode 100755
index 0000000..7a6987b
--- /dev/null
+++ b/test
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+if ! test -f "main"; then
+ qemu-img create main 20G
+fi
+
+./run_archiso -u -i images/$(ls images | sort | tail -n 1)