Skip to content

Commit

Permalink
Add CI tests and CD pipeline (nikhiljha#117)
Browse files Browse the repository at this point in the history
Add Github Actions workflow
Reduce interactivity in a CI environment
Change to systemd-nspawn from chroot
Clean up some magic strings as variables
Remove firefox (Cisco GPG repo problems)
Unmount everything and xz resulting image

Co-authored-by: Nikhil Jha <[email protected]>
  • Loading branch information
greg-hellings and nikhiljha authored Feb 7, 2022
1 parent 94b2ad6 commit 50fdc82
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ PP_IMAGE=${PP_IMAGE:-/dev/loop1}
PP_PARTA=${PP_PARTA:-${PP_IMAGE}p1}
PP_PARTB=${PP_PARTB:-${PP_IMAGE}p2}

FED_IMAGE=${FED_IMAGE:-/dev/loop0}
# Output file name.
OUT_NAME=${OUT_NAME:-fedora.img}

# Only needed if you want a custom file, otherwise do not change.
# FEDORA_RAW_FILE=Fedora-Minimal-Rawhide-20200302.n.1.aarch64.raw.xz
FEDORA_RAW_SOURCE=${EFDORA_RAW_SOURCE:-https://dl.fedoraproject.org/pub/fedora-secondary/development/rawhide/Spins/aarch64/images}
FEDORA_RAW_SOURCE=${FEDORA_RAW_SOURCE:-https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Spins/aarch64/images}
KERNEL_RAW_DIR=${KERNEL_RAW_DIR:-pp1-5.7}

export PP_IMAGE
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Run build

"on":
push:
paths-ignored:
- README.md
- COPYING
pull_request:
release:
types:
- published
- prereleased
workflow_dispatch: # Allows manually triggering

env:
PP_IMAGE: /dev/loop10
FED_IMAGE: /dev/loop11

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Makes extra disk space
uses: greg-hellings/make-space@v1
- name: Install necessary tools
run: |
sudo apt update
sudo apt install -yy systemd-container qemu-user-static u-boot-tools btrfs-progs dosfstools xz-utils sssd
sudo service sssd start
- name: Download files
run: |
set -ex -o pipefail
./download-files.sh
- name: Execute build
run: |
set -ex -o pipefail
sudo -E ./all.sh
# Compress image
sudo xz -T 0 fedora.img
- name: Store fedora.img.xz as an artifact
uses: actions/upload-artifact@v2
with:
name: image
path: fedora.img.xz
if-no-files-found: error

release:
needs:
- build # Can only run after the build has created the artifact
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Download fedora.img.xz
uses: actions/download-artifact@v2
with:
name: image
- name: Upload files to release
uses: ncipollo/release-action@v1
with:
artifacts: fedora.img.xz
allowUpdates: true
name: ${{ github.event.name }}
token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion 00-create-empty-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ echo "========================"

# Approximately 6GB image.
echo "Create image called $OUT_NAME? Make sure this doesn't exist, or it will be replaced."
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo

if [[ $REPLY =~ ^[Yy]$ ]]
then
if [[ -e "$OUT_NAME" ]]
Expand Down
2 changes: 2 additions & 0 deletions 00-selftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fi
command -v mkfs.btrfs >/dev/null 2>&1 || { echo >&2 "I require mkfs.btrfs but it's not installed. Aborting."; exit 1; }
command -v mkfs.vfat >/dev/null 2>&1 || { echo >&2 "I require mkfs.vfat but it's not installed. Aborting."; exit 1; }

command -v systemd-nspawn >/dev/null 2>&1 || { echo >&2 "I require systemd-nspawn but it's not installed. Aborting."; exit 1; }

if [[ $HOSTARCH != "aarch64" ]]; then
command -v qemu-aarch64-static >/dev/null 2>&1 || { echo >&2 "I require qemu-aarch64-static but it's not installed. Aborting."; exit 1; }
fi
Expand Down
8 changes: 6 additions & 2 deletions 01-partition-drive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ fi

# Warning
echo "=== WARNING WARNING WARNING ==="
infecho "This script will mount to /dev/loop1."
infecho "This script will mount to ${PP_IMAGE}."
infecho "Make sure nothing else is mounted there: lsblk"
echo "=== WARNING WARNING WARNING ==="
echo
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
Expand Down
24 changes: 16 additions & 8 deletions 02-install-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ fi

# Warning
echo "=== WARNING WARNING WARNING ==="
infecho "This script will try to mount to /dev/loop0."
infecho "This script will try to mount to ${FED_IMAGE}."
infecho "Make sure nothing else is there with: lsblk"
echo "=== WARNING WARNING WARNING ==="
echo
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
Expand All @@ -37,24 +41,28 @@ then
mkdir -p rootfs

infecho "Mounting Fedora image..."
losetup /dev/loop0 rawhide.raw
partprobe -s /dev/loop0
mount /dev/loop0p3 imgfs
losetup "${FED_IMAGE}" rawhide.raw
partprobe -s ${FED_IMAGE}
mount ${FED_IMAGE}p3 imgfs

infecho "Mounting SD Card rootfs..."
partprobe -s $PP_IMAGE
sleep 1 # Sometimes it lags.
mount $PP_PARTB rootfs

infecho "Copying files..."
rsync -a --progress imgfs/* rootfs/
if [ ! -z "$PS1" ]; then
rsync -a --progress imgfs/* rootfs/
else
rsync -a imgfs/* rootfs/
fi

infecho "Deleting contents of /boot..."
rm -rf rootfs/boot/*

infecho "Unmounting everything..."
umount /dev/loop0p3
losetup -d /dev/loop0
umount ${FED_IMAGE}p3
losetup -d ${FED_IMAGE}
umount $PP_PARTB

infecho "Deleting temp directories..."
Expand Down
6 changes: 5 additions & 1 deletion 03-install-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ infecho "Also, I didn't test this so it might also cause WWIII or something."
infecho "I'm not responsible for anything that happens, you should read the script first."
echo "=== WARNING WARNING WARNING ==="
echo
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
Expand Down
6 changes: 5 additions & 1 deletion 04-edit-fstab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ infecho "I didn't test this so it might also cause WWIII or something."
infecho "I'm not responsible for anything that happens, you should read the script first."
echo "=== WARNING WARNING WARNING ==="
echo
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
Expand Down
22 changes: 11 additions & 11 deletions 05-setup-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ infecho "I didn't test this so it might also cause WWIII or something."
infecho "I'm not responsible for anything that happens, you should read the script first."
echo "=== WARNING WARNING WARNING ==="
echo
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
Expand All @@ -50,30 +54,26 @@ then

cp phone-scripts/* rootfs/root

infecho "Mounting your /dev into the rootfs..."
infecho "This is neccesary for dnf to work, because reasons."
mount --bind /dev rootfs/dev

infecho "Copy resolv.conf /etc/tmp-resolv.conf"
cp /etc/resolv.conf rootfs/etc/tmp-resolv.conf

if [[ $HOSTARCH != "aarch64" ]]; then
infecho "Chrooting with qemu into rootfs..."
chroot rootfs qemu-aarch64-static /bin/bash /root/all.sh
systemd-nspawn -D rootfs qemu-aarch64-static /bin/bash /root/all.sh

infecho "KILLING ALL QEMU PROCESSES, MAKE SURE YOU HAVE NO MORE RUNNING!"
killall -9 /usr/bin/qemu-aarch64-static
killall -9 /usr/bin/qemu-aarch64-static || true

infecho "Removing qemu binary, so it doesn't stay in image"
rm -f rootfs/usr/bin/qemu-aarch64-static
else
infecho "Chrooting into rootfs..."
chroot rootfs /bin/bash /root/all.sh
fi

infecho "Unmounting your /dev from the rootfs..."
sleep 3
umount rootfs/dev

infecho "Unmounting rootfs..."
sleep 3
umount $PP_PARTA
umount $PP_PARTB
rmdir rootfs
fi
4 changes: 2 additions & 2 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source .env

umount /dev/loop0p3
umount ${FED_IMAGE}p3
umount $PP_PARTB
umount $PP_PARTA
sleep 3
rmdir imgfs
rmdir rootfs
rmdir $KERNEL_RAW_DIR/imgfs
rmdir $KERNEL_RAW_DIR/rootfs
losetup -d /dev/loop0
losetup -d ${FED_IMAGE}
6 changes: 5 additions & 1 deletion download-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ source .env
echo "This script will download a few GB of Fedora and a few MB of Kernel into the current directory."
echo "Look inside the script if you would rather download manually."
echo
read -p "Continue? [y/N] " -n 1 -r
if [ ! -z "$PS1" ]; then
read -p "Continue? [y/N] " -n 1 -r
else
REPLY=y
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
Expand Down
2 changes: 1 addition & 1 deletion phone-scripts/01-create-sudo-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ infecho () {
infecho "Adding user \"pine\"..."

adduser pine
passwd pine
printf 123456 | passwd --stdin pine
groupadd feedbackd
usermod -aG wheel,video,feedbackd pine
11 changes: 6 additions & 5 deletions phone-scripts/02-install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ infecho "Link temp-resolv.conf"
ln -sfv /etc/tmp-resolv.conf /etc/resolv.conf

infecho "Enabling COPR repository..."
dnf -y copr enable njha/mobile
dnf -q -y copr enable njha/mobile

infecho "Removing old kernel..."
infecho "THIS WILL FAIL, DON'T WORRY ITS PROBABLY OK"
dnf -y remove kernel || rpm -e --noscripts kernel-core
dnf -y install linux-firmware
dnf -q -y remove kernel || rpm -e --noscripts kernel-core
dnf -q -y install linux-firmware

# Firefox is currently causing problems with Cisco H.264 RPMs
infecho "Installing recommended packages..."
dnf -y install megi-kernel feedbackd phoc phosh squeekboard gnome-shell ModemManager rtl8723cs-firmware \
dnf -q -y install megi-kernel feedbackd phoc phosh squeekboard gnome-shell ModemManager rtl8723cs-firmware \
dbus-x11 chatty calls carbons purple-mm-sms pinephone-helpers evolution-data-server \
f35-backgrounds-gnome epiphany gnome-contacts NetworkManager-wwan \
firefox nautilus gvfs-goa megapixels gnome-power-manager gnome-usage xdg-user-dirs pipewire-alsa \
Expand All @@ -47,4 +48,4 @@ infecho "Making COPR higher priority for kernel updates..."
echo "priority=10" >> /etc/yum.repos.d/_copr\:copr.fedorainfracloud.org\:njha\:mobile.repo

infecho "Upgrading packages..."
dnf -y upgrade
dnf -q -y upgrade

0 comments on commit 50fdc82

Please sign in to comment.