Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDewes committed Oct 29, 2023
2 parents d3314ab + 0b74175 commit f2d8589
Show file tree
Hide file tree
Showing 44 changed files with 72 additions and 265 deletions.
12 changes: 12 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build-job:
tags:
- arm64
image: debian:bookworm
before_script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -y quilt debootstrap libarchive-tools qemu-utils gpg pigz parted zerofree zip dosfstools libcap2-bin rsync xz-utils curl xxd file git kmod bc kpartx
script:
- IMG_FILENAME=citadel-os-latest ARCHIVE_FILENAME=citadel-os-latest CITADEL_OS_VERSION=0.3.0 ./build.sh
artifacts:
paths:
- deploy
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export TARGET_HOSTNAME=${TARGET_HOSTNAME:-umbrel}

export FIRST_USER_NAME=${FIRST_USER_NAME:-umbrel}
export FIRST_USER_PASS=${FIRST_USER_PASS:-moneyprintergobrrr}
export RELEASE=${RELEASE:-bullseye} # Don't forget to update stage0/prerun.sh
export RELEASE=${RELEASE:-bookworm} # Don't forget to update stage0/prerun.sh
export WPA_ESSID
export WPA_PASSWORD
export WPA_COUNTRY
Expand Down
1 change: 0 additions & 1 deletion depends
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quilt
parted
realpath:coreutils
qemu-aarch64-static:qemu-user-static
debootstrap
zerofree
zip
Expand Down
9 changes: 0 additions & 9 deletions export-image/00-allow-rerun/00-run.sh

This file was deleted.

2 changes: 1 addition & 1 deletion export-image/02-set-sources/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache"
find "${ROOTFS_DIR}/var/lib/apt/lists/" -type f -delete
on_chroot << EOF
apt-get update
apt-get -y dist-upgrade
apt-get -y dist-upgrade --auto-remove --purge
apt-get clean
EOF
3 changes: 1 addition & 2 deletions export-image/04-set-partuuid/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then
sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab"
sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab"

sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/cmdline.txt"

sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/firmware/cmdline.txt"
fi

5 changes: 4 additions & 1 deletion export-image/05-finalise/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.info"

sed -i 's/^update_initramfs=.*/update_initramfs=all/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf"

on_chroot << EOF
update-initramfs -u
if [ -x /etc/init.d/fake-hwclock ]; then
/etc/init.d/fake-hwclock stop
fi
Expand Down Expand Up @@ -54,7 +57,7 @@ rm -f "${ROOTFS_DIR}/root/.vnc/private.key"
rm -f "${ROOTFS_DIR}/etc/vnc/updateid"

update_issue "$(basename "${EXPORT_DIR}")"
install -m 644 "${ROOTFS_DIR}/etc/schirm-issue" "${ROOTFS_DIR}/boot/issue.txt"
install -m 644 "${ROOTFS_DIR}/etc/schirm-issue" "${ROOTFS_DIR}/boot/firmware/issue.txt"

cp "$ROOTFS_DIR/etc/schirm-issue" "$INFO_FILE"

Expand Down
14 changes: 7 additions & 7 deletions export-image/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then
rm -rf "${ROOTFS_DIR}"
mkdir -p "${ROOTFS_DIR}"

BOOT_SIZE="$((256 * 1024 * 1024))"
ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot --block-size=1 | cut -f 1)
BOOT_SIZE="$((512 * 1024 * 1024))"
ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot/firmware --block-size=1 | cut -f 1)

# All partition sizes and starts will be aligned to this size
ALIGN="$((4 * 1024 * 1024))"
Expand All @@ -35,7 +35,7 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then

echo "Creating loop device..."
cnt=0
until LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do
until ensure_next_loopdev && LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do
if [ $cnt -lt 5 ]; then
cnt=$((cnt + 1))
echo "Error in losetup. Retrying..."
Expand All @@ -59,9 +59,9 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then
mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null

mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4
mkdir -p "${ROOTFS_DIR}/boot"
mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot" -t vfat
mkdir -p "${ROOTFS_DIR}/boot/firmware"
mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot/firmware" -t vfat

rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/"
rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/" "${ROOTFS_DIR}/boot/"
rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/firmware "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/"
rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/firmware/" "${ROOTFS_DIR}/boot/firmware/"
fi
8 changes: 8 additions & 0 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ update_issue() {
echo -e "Schirm OS built on ${IMG_DATE}\nGenerated using ${BUILD_SCRIPTS}, ${BUILD_SCRIPTS_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/schirm-issue"
}
export -f update_issue

ensure_next_loopdev() {
local loopdev
loopdev="$(losetup -f)"
loopmaj="$(echo "$loopdev" | sed -E 's/.*[^0-9]*?([0-9]+)$/\1/')"
[[ -b "$loopdev" ]] || mknod "$loopdev" b 7 "$loopmaj"
}
export -f ensure_next_loopdev
2 changes: 1 addition & 1 deletion stage0/00-configure-apt/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
cat files/raspberrypi.gpg.key | gpg --dearmor > "${STAGE_WORK_DIR}/raspberrypi-archive-stable.gpg"
install -m 644 "${STAGE_WORK_DIR}/raspberrypi-archive-stable.gpg" "${ROOTFS_DIR}/etc/apt/trusted.gpg.d/"
on_chroot << EOF
dpkg --add-architecture armhf
dpkg --add-architecture arm64
apt-get update
apt-get dist-upgrade -y
EOF
4 changes: 2 additions & 2 deletions stage0/00-configure-apt/files/raspi.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
deb http://archive.raspberrypi.org/debian/ RELEASE main
deb http://archive.raspberrypi.com/debian/ RELEASE main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ RELEASE main
#deb-src http://archive.raspberrypi.com/debian/ RELEASE main
8 changes: 6 additions & 2 deletions stage0/02-firmware/01-packages
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
raspberrypi-bootloader
raspberrypi-kernel
initramfs-tools
raspi-firmware
linux-image-rpi-v8
linux-image-rpi-2712
linux-headers-rpi-v8
linux-headers-rpi-2712
3 changes: 3 additions & 0 deletions stage0/02-firmware/02-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e

sed -i 's/^update_initramfs=.*/update_initramfs=no/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf"
Binary file modified stage0/files/debian.gpg
Binary file not shown.
2 changes: 1 addition & 1 deletion stage0/prerun.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

if [ "$RELEASE" != "bullseye" ]; then
if [ "$RELEASE" != "bookworm" ]; then
echo "WARNING: RELEASE does not match the intended option for this branch."
echo " Please check the relevant README.md section."
fi
Expand Down
17 changes: 15 additions & 2 deletions stage1/00-boot-files/00-run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#!/bin/bash -e

install -m 644 files/cmdline.txt "${ROOTFS_DIR}/boot/"
install -m 644 files/config.txt "${ROOTFS_DIR}/boot/"
mkdir -p "${ROOTFS_DIR}/boot/firmware"

if ! [ -L "${ROOTFS_DIR}/boot/overlays" ]; then
ln -s firmware/overlays "${ROOTFS_DIR}/boot/overlays"
fi

install -m 644 files/cmdline.txt "${ROOTFS_DIR}/boot/firmware/"
if ! [ -L "${ROOTFS_DIR}/boot/cmdline.txt" ]; then
ln -s firmware/cmdline.txt "${ROOTFS_DIR}/boot/cmdline.txt"
fi

install -m 644 files/config.txt "${ROOTFS_DIR}/boot/firmware/"
if ! [ -L "${ROOTFS_DIR}/boot/config.txt" ]; then
ln -s firmware/config.txt "${ROOTFS_DIR}/boot/config.txt"
fi
61 changes: 5 additions & 56 deletions stage1/00-boot-files/files/config.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
# For more options and information see
# http://rpf.io/configtxt
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
Expand All @@ -49,24 +13,11 @@

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
Expand All @@ -78,9 +29,7 @@ dtparam=i2c_arm=on
dtparam=i2c_vc=on

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
# Mostly disable GPU
gpu_mem=16
2 changes: 1 addition & 1 deletion stage1/01-sys-tweaks/files/fstab
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
proc /proc proc defaults 0 0
BOOTDEV /boot vfat defaults 0 2
BOOTDEV /boot/firmware vfat defaults 0 2
ROOTDEV / ext4 defaults,noatime 0 1
2 changes: 1 addition & 1 deletion stage1/02-net-tweaks/00-packages
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
netbase
dhcpcd5
dhcpcd
2 changes: 1 addition & 1 deletion stage2/00-sys-tweaks/00-packages
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ssh less fbset sudo psmisc
console-setup keyboard-configuration parted unzip
bash-completion
avahi-daemon
hardlink ca-certificates curl
ca-certificates curl
fake-hwclock usbutils
dosfstools
raspberrypi-sys-mods
Expand Down
4 changes: 2 additions & 2 deletions stage2/00-sys-tweaks/00-patches/04-resize-init.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- stage2.orig/rootfs/boot/cmdline.txt
+++ stage2/rootfs/boot/cmdline.txt
--- stage2.orig/rootfs/boot/firmware/cmdline.txt
+++ stage2/rootfs/boot/firmware/cmdline.txt
@@ -1 +1 @@
-usb-storage.quirks=152d:1561:u,152d:1576:u,152d:0578:u,125f:a76a:u,04e8:61b6:u console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait cgroup_enable=memory cgroup_memory=1
+usb-storage.quirks=152d:1561:u,152d:1576:u,152d:0578:u,125f:a76a:u,04e8:61b6:u console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait cgroup_enable=memory cgroup_memory=1 quiet init=/usr/lib/raspberrypi-sys-mods/firstboot
2 changes: 0 additions & 2 deletions stage2/00-sys-tweaks/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ fi

on_chroot << EOF
systemctl disable hwclock.sh
systemctl disable nfs-common
systemctl disable rpcbind
if [ "${ENABLE_SSH}" == "1" ]; then
systemctl enable ssh
else
Expand Down
1 change: 0 additions & 1 deletion stage2/01-net-tweaks/00-packages
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
wpasupplicant wireless-tools firmware-brcm80211
dhcpcd5
net-tools
network-manager
libzbar-dev
Expand Down
20 changes: 0 additions & 20 deletions stage2/01-net-tweaks/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,12 @@
install -v -d "${ROOTFS_DIR}/etc/wpa_supplicant"
install -v -m 600 files/wpa_supplicant.conf "${ROOTFS_DIR}/etc/wpa_supplicant/"

on_chroot << EOF
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 0
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_netconf 1
EOF

if [ -v WPA_COUNTRY ]; then
on_chroot <<- EOF
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_wifi_country "${WPA_COUNTRY}"
EOF
fi

if [ -v WPA_ESSID ] && [ -v WPA_PASSWORD ]; then
on_chroot <<EOF
set -o pipefail
wpa_passphrase "${WPA_ESSID}" "${WPA_PASSWORD}" | tee -a "/etc/wpa_supplicant/wpa_supplicant.conf"
EOF
elif [ -v WPA_ESSID ]; then
cat >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" << EOL
network={
ssid="${WPA_ESSID}"
key_mgmt=NONE
}
EOL
fi

# Disable wifi on 5GHz models if WPA_COUNTRY is not set
mkdir -p "${ROOTFS_DIR}/var/lib/systemd/rfkill/"
if [ -n "$WPA_COUNTRY" ]; then
Expand Down
2 changes: 0 additions & 2 deletions stage3/00-install-packages/00-debconf

This file was deleted.

17 changes: 0 additions & 17 deletions stage3/00-install-packages/00-packages

This file was deleted.

7 changes: 0 additions & 7 deletions stage3/00-install-packages/00-packages-nr

This file was deleted.

9 changes: 0 additions & 9 deletions stage3/00-install-packages/01-run.sh

This file was deleted.

5 changes: 0 additions & 5 deletions stage3/01-tweaks/00-run.sh

This file was deleted.

5 changes: 0 additions & 5 deletions stage3/prerun.sh

This file was deleted.

2 changes: 0 additions & 2 deletions stage4/00-install-packages/00-debconf

This file was deleted.

Loading

0 comments on commit f2d8589

Please sign in to comment.