~bitfehler/anemos-demo-payload

e0cf094050e28c6131aa29f5ea6e8bd2a0463ed2 — Conrad Hoffmann 1 year, 2 months ago master
Initial commit
A  => .makeimg.modes +6 -0
@@ 1,6 @@
644 files/etc/hosts
644 files/etc/systemd/network/wired.network
644 files/etc/locale.conf
644 files/etc/hostname
644 files/etc/pacman.d/mirrorlist
644 templates/etc/motd

A  => IMGBUILD +91 -0
@@ 1,91 @@
# The name of this image. Mostly cosmetic, e.g. for output file naming.
imgname=arch-deploy

# The image format to generate. See also the man page for options.
# Generate raw image with msdos partition table and a single partition
#format="raw 6G msdos ext4"
# Generate xz-compressed tarball
#format="tar xz"
# Generate a directory
#format="dir"
# Custom: the IMGBUILD has to implement setup() and cleanup()
#format="custom"
format="custom"

# Specify config items to be copied from the host building the image.
#
# Add 'keyring' to install the host's pacman keyring on the image.
# Otherwise the keyring must be installed manually via files or by running
# `pacman-key` in the provision script.
# Add 'mirrorlist' to install the host's mirrorlist. Otherwise the mirrorlist
# must be installed manually by supplying a file or a patch to the default mirrorlist
# or some custom solution in the provision script.
#
# Default is to not use anything from the host.
# hostconf=""
hostconf=""

# The packages to install
packages="
	base
	curl
	grub
	kexec-tools
	linux
	lsb-release
	openssh
	sudo
	util-linux
	vim
"

setup() {
	# Could repartition disk
	#parted -s -- /dev/vda mklabel msdos mkpart primary 2048s -1s
	UUID=$(uuidgen)
	mkfs.ext4 -q -v -F -U "$UUID" /dev/vda1 
	mount /dev/vda1 "${imgroot}"
	mkdir "${imgroot}"/etc
	OPTS=$(findmnt -no OPTIONS /dev/vda1)
	printf "UUID=%s\t/\t%s\t%s\t0 1\n" "${UUID}" "ext4" "${OPTS}" > "${imgroot}/etc/fstab"
}

cleanup() {
	umount "${imgroot}"
}

# The provisioning function. It is executed in the context of the new image.
# Files have been copied, patches have been applied, templates have been
# rendered (see the folders in this directory and the makeimg man page).
provision() {
	#cat /etc/fstab.makeimg >> /etc/fstab
	#rm -f /etc/fstab.makeimg

	# Init pacman keyring
	pacman-key --init
	pacman-key --populate archlinux
	# Kill the gpg-agent that was started for this
	killall gpg-agent

	ln -sf "/usr/share/zoneinfo/Europe/Berlin" /etc/localtime
	locale-gen

	# echo secret | openssl passwd -6 -stdin
	echo 'root:$6$mpWkRUWMForQFL69$zceQFLgGasM6DxC9JyYAO6XrjPDEjfp7tOyVmkiag2C2TOyR/3aeD/V0OVVvJIfU2pjEqhN9ZlXD4EVsqNsrL1' | chpasswd -e

	# Set up bootloader.
	# Default to the fallback image, so it will work on most hardware.
	#sed -e 's/^GRUB_DEFAULT=0/GRUB_DEFAULT="1>1"/' -i /etc/default/grub
	sed -e 's/^GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200"/' -i /etc/default/grub
	# $BLKDEV is set by makeimg
	grub-install --target=i386-pc "${BLKDEV}"
	grub-mkconfig > /boot/grub/grub.cfg
}

# Performed last as services may have been installed via custom files/commands
services="
	sshd
	systemd-timesyncd
	systemd-networkd
	systemd-resolved
"

A  => LICENSE +20 -0
@@ 1,20 @@
Copyright (c) Conrad Hoffmann

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A  => Makefile +5 -0
@@ 1,5 @@

payload:
	tar -cvzf payload.tar.gz files/ patches/ templates/ IMGBUILD

.PHONY: payload

A  => README.md +9 -0
@@ 1,9 @@
# Example Anemos payload

This directory contains a simple example of an [IMGBUILD][1] building an [Arch
Linux][2] image. Run `make` to generate the file `payload.tar.gz`, which can
then be used as a payload for [Anemos][3].

[1]: https://sr.ht/~bitfehler/makeimg "makeimg project page on sr.ht"
[2]: https://archlinux.org "Arch Linux homepage"
[3]: https://sr.ht/~bitfehler/anemos "Anemos project page on sr.ht"

A  => files/etc/hostname +1 -0
@@ 1,1 @@
anemos-demo

A  => files/etc/hosts +6 -0
@@ 1,6 @@
# Static table lookup for hostnames.
# See hosts(5) for details.

127.0.0.1	localhost
::1		localhost
127.0.1.1	deployed.localdomain	deployed

A  => files/etc/locale.conf +1 -0
@@ 1,1 @@
LANG=en_US.UTF-8

A  => files/etc/pacman.d/mirrorlist +15 -0
@@ 1,15 @@
################################################################################
################## Arch Linux mirrorlist generated by Reflector #################
#################################################################################
#
## With:       reflector -c de -l 10 -p https -f 5 --sort rate
## When:       2022-08-26 20:27:21 UTC
## From:       https://archlinux.org/mirrors/status/json/
## Retrieved:  2022-08-26 20:27:10 UTC
## Last Check: 2022-08-26 20:20:25 UTC

Server = https://de.arch.mirror.kescher.at/$repo/os/$arch
Server = https://mirror.chaoticum.net/arch/$repo/os/$arch
Server = https://mirror.moson.org/arch/$repo/os/$arch
Server = https://mirror.iusearchbtw.nl/$repo/os/$arch
Server = https://mirror.pseudoform.org/$repo/os/$arch

A  => files/etc/resolv.conf +1 -0
@@ 1,1 @@
/run/systemd/resolve/stub-resolv.conf
\ No newline at end of file

A  => files/etc/systemd/network/wired.network +5 -0
@@ 1,5 @@
[Match]
Name=e*

[Network]
DHCP=yes

A  => files/init +1 -0
@@ 1,1 @@
/lib/systemd/systemd
\ No newline at end of file

A  => patches/etc/locale.gen +11 -0
@@ 1,11 @@
--- /etc/locale.gen.pacnew	2020-10-14 19:00:17.000000000 +0200
+++ locale.gen	2021-01-26 15:18:45.859082898 +0100
@@ -174,7 +174,7 @@
 #en_SC.UTF-8 UTF-8  
 #en_SG.UTF-8 UTF-8  
 #en_SG ISO-8859-1  
-#en_US.UTF-8 UTF-8  
+en_US.UTF-8 UTF-8  
 #en_US ISO-8859-1  
 #en_ZA.UTF-8 UTF-8  
 #en_ZA ISO-8859-1  

A  => templates/etc/motd +1 -0
@@ 1,1 @@
This image was build on $(date)