Skip to content

Commit

Permalink
chore: improve builtin recipes and layers
Browse files Browse the repository at this point in the history
  • Loading branch information
koehlma committed May 30, 2024
1 parent af783b2 commit f8dd75c
Show file tree
Hide file tree
Showing 47 changed files with 290 additions and 120 deletions.
8 changes: 8 additions & 0 deletions bakery/repositories/core/layers/alpine-3-20.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

recipes = [
"alpine-bootstrap",
]

[parameters."alpine-bootstrap"]
version = "3.20"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = "Raspberry Pi OS (Bookworm)"
url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-11/2023-12-11-raspios-bookworm-arm64-lite.img.xz"
url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = "Raspberry Pi OS (Bookworm)"
url = "https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2023-12-11/2023-12-11-raspios-bookworm-armhf-lite.img.xz"
url = "https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = "Raspberry Pi OS (Bullseye)"
url = "https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-12-06/2023-12-05-raspios-bullseye-arm64-lite.img.xz"
url = "https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2024-03-12/2024-03-12-raspios-bullseye-arm64-lite.img.xz"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = "Raspberry Pi OS (Bullseye)"
url = "https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-12-06/2023-12-05-raspios-bullseye-armhf-lite.img.xz"
url = "https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2024-03-12/2024-03-12-raspios-bullseye-armhf-lite.img.xz"
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ case ${RUGPI_ARCH} in
"arm64")
ALPINE_ARCH="aarch64"
;;
"armv7")
ALPINE_ARCH="armv7"
;;
"armhf")
ALPINE_ARCH="armhf"
;;
*)
echo "Unsupported architecture ${RUGPI_ARCH}."
echo "Unsupported architecture '${RUGPI_ARCH}'."
exit 1
esac

wget -O /tmp/alpine-rootfs.tar.gz \
"https://dl-cdn.alpinelinux.org/alpine/v${RECIPE_PARAM_VERSION}/releases/${ALPINE_ARCH}/alpine-minirootfs-${RECIPE_PARAM_VERSION}.0-${ALPINE_ARCH}.tar.gz"


mkdir -p "${RUGPI_ROOT_DIR}"
tar -xvf /tmp/alpine-rootfs.tar.gz -C "${RUGPI_ROOT_DIR}"

wget -O- "https://dl-cdn.alpinelinux.org/alpine/v${RECIPE_PARAM_VERSION}/releases/${ALPINE_ARCH}/alpine-minirootfs-${RECIPE_PARAM_VERSION}.0-${ALPINE_ARCH}.tar.gz" \
| tar -xzvf - -C "${RUGPI_ROOT_DIR}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linux /vmlinuz ro modules=sd-mod,usb-storage,ext4,vfat init=/usr/bin/rugpi-ctrl root=/dev/sda${rugpi_syspart}
initrd /initrd.img
boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description = "setup Alpine for `generic-grub-*` targets"
dependencies = []

[parameters]
with_firmware = { default = "true" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -eu

apk update

BOOT_DIR="${RUGPI_LAYER_DIR}/boot"

mkdir -p "${BOOT_DIR}"

echo "Installing kernel..."
apk add linux-lts

if [ "${RECIPE_PARAM_WITH_FIRMWARE}" = "true" ]; then
echo "Installing firmware..."
apk add linux-firmware
fi

echo "Copying kernel and initrd..."
cp -L /boot/vmlinuz-lts "${BOOT_DIR}/vmlinuz"
cp -L /boot/initramfs-lts "${BOOT_DIR}/initrd.img"

echo "Installing second stage boot script..."
cp "${RECIPE_DIR}/files/second.grub.cfg" "${BOOT_DIR}"
12 changes: 0 additions & 12 deletions bakery/repositories/core/recipes/apt-cleanup/steps/00-install.sh

This file was deleted.

3 changes: 0 additions & 3 deletions bakery/repositories/core/recipes/apt-update/recipe.toml

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions bakery/repositories/core/recipes/apt-upgrade/recipe.toml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@

set -euo pipefail

case "${RUGPI_ARCH}" in
"amd64")
DEBIAN_ARCH="amd64"
;;
"arm64")
DEBIAN_ARCH="arm64"
;;
"armv7")
DEBIAN_ARCH="armhf"
;;
"arm")
DEBIAN_ARCH="armel"
;;
*)
echo "Unsupported architecture '${RUGPI_ARCH}'."
exit 1
esac

mmdebstrap \
--architectures="${RUGPI_ARCH}" \
--architectures="${DEBIAN_ARCH}" \
"${RECIPE_PARAM_SUITE}" \
"${RUGPI_ROOT_DIR}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linux /vmlinuz ro init=/usr/bin/rugpi-ctrl root=/dev/sda${rugpi_syspart}
initrd /initrd.img
boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description = "setup Debian for `generic-grub-*` targets"
dependencies = []

[parameters]
with_firmware = { default = "true" }
with_nonfree = { default = "true" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -euo pipefail

apt-get update -y

BOOT_DIR="${RUGPI_LAYER_DIR}/boot"

mkdir -p "${BOOT_DIR}"

echo "Installing kernel..."
case "${RUGPI_ARCH}" in
"amd64")
apt-get install -y \
linux-image-amd64 \
linux-headers-amd64
;;
"arm64")
apt-get install -y \
linux-image-arm64 \
linux-headers-arm64
;;
*)
echo "Unsupported architecture '${RUGPI_ARCH}'."
exit 1
esac

if [ "${RECIPE_PARAM_WITH_FIRMWARE}" == "true" ]; then
echo "Installing free firmware..."
apt-get install -y firmware-linux-free
fi

if [ "${RECIPE_PARAM_WITH_NONFREE}" == "true" ]; then
# Make sure that the non-free sources are available.
sed -i '/main/!b; /non-free/b; s/$/ non-free/' /etc/apt/sources.list
sed -i '/main/!b; /non-free-firmware/b; s/$/ non-free-firmware/' /etc/apt/sources.list

apt-get update -y

if [ "${RECIPE_PARAM_WITH_FIRMWARE}" == "true" ]; then
echo "Installing nonfree firmware..."
apt-get install -y firmware-linux
fi
fi

echo "Copying kernel and initrd..."
cp -L /vmlinuz "${BOOT_DIR}"
cp -L /initrd.img "${BOOT_DIR}"

echo "Installing second stage boot script..."
cp "${RECIPE_DIR}/files/second.grub.cfg" "${BOOT_DIR}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description = "apt: cleanup cache and delete package lists"
description = "cleanup cache and delete package lists"
priority = -900_000 # Execute after everything else.

[parameters]
Expand Down
18 changes: 18 additions & 0 deletions bakery/repositories/core/recipes/pkg-cleanup/steps/00-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -eu

if [ "${RECIPE_PARAM_AUTOREMOVE}" = "true" ]; then
if command -v apt-get; then
apt-get autoremove -y
fi
fi

if command -v apt-get; then
apt-get clean -y
rm -rf /var/lib/apt/lists/*
fi

if command -v apk; then
rm -rf /var/cache/apk/*
fi
3 changes: 3 additions & 0 deletions bakery/repositories/core/recipes/pkg-update/recipe.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description = "update package lists"
priority = 900_000 # Execute before everything else.
dependencies = ["pkg-cleanup"]
11 changes: 11 additions & 0 deletions bakery/repositories/core/recipes/pkg-update/steps/00-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -eu

if command -v apt-get; then
apt-get update -y
fi

if command -v apk; then
apk update
fi
3 changes: 3 additions & 0 deletions bakery/repositories/core/recipes/pkg-upgrade/recipe.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description = "upgrade all packages"
priority = 899_900 # Execute before everything else but after `pkg-update`.
dependencies = ["pkg-update"]
11 changes: 11 additions & 0 deletions bakery/repositories/core/recipes/pkg-upgrade/steps/00-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -eu

if command -v apt-get; then
apt-get upgrade -y
fi

if command -v apk; then
apk upgrade
fi
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
description = "Raspberry Pi meta recipe"
dependencies = ["pi-cleanup", "persist-fake-hwclock", "disable-swap", "rugpi-ctrl", "apt-upgrade"]
dependencies = ["rpi-raspios-cleanup", "persist-fake-hwclock"]
1 change: 1 addition & 0 deletions bakery/repositories/core/recipes/rugpi-ctrl/recipe.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
description = "install and configure Rugpi Ctrl"
priority = 700_000 # Execute very early.
dependencies = ["pkg-update"]

[parameters]
rugpi_admin = { default = false }
9 changes: 0 additions & 9 deletions bakery/templates/alpine-grub-efi/layers/alpine-base.toml

This file was deleted.

12 changes: 10 additions & 2 deletions bakery/templates/alpine-grub-efi/layers/customized.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
parent = "alpine-base"
# We use Alpine Linux 3.20 as a basis.
parent = "core/alpine-3-20"

recipes = ["setup"]
recipes = [
# Setup Alpine for booting via Grub.
"core/alpine-grub-setup",
# Install Rugpi Ctrl into the image.
"core/rugpi-ctrl",
# Install a static website.
"hello-world",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<title>Rugpi: Hello World!</title>

<style>
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap');

html, body {
background: #5dabf5;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'Fira Sans', sans-serif;
}

p {
text-align: center;
max-width: 80ch;
}
</style>
</head>
<body>
<h1>Hello World! 👋</h1>
<p>This is an example static web site served from a customized Rugpi system.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description = "example recipe for installing a static website"
dependencies = [
# Update the package lists such that we can install Nginx.
"core/pkg-update"
]
Loading

0 comments on commit f8dd75c

Please sign in to comment.