Void Linux for uConsole #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Void Linux for uConsole" | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
permissions: | |
contents: write | |
pull-requests: read | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Get current date | |
id: date | |
run: echo "stamp=$(date '+%s')" >> $GITHUB_ENV | |
- name: Install tools | |
run: | | |
sudo apt update | |
sudo apt -y install p7zip-full ccache gcc-aarch64-linux-gnu device-tree-compiler python-is-python3 python3-pip exfatprogs parted exfat-fuse binfmt-support qemu-user-static | |
- name: clone external repos | |
run: | | |
wget https://raw.githubusercontent.com/raspberrypi/rpi-update/master/rpi-update | |
git clone https://github.com/raspberrypi/userland | |
git clone https://github.com/syl20bnr/spacemacs emacs | |
- name: delete git directories | |
run: | | |
rm -rf userland/.git | |
rm -rf emacs/.git | |
- name: Setup CCache | |
uses: hendrikmuhs/[email protected] | |
- name: Cross-compile kernel | |
working-directory: linux | |
run: | | |
make KERNEL=kernel8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 bcm2711_defconfig | |
scripts/config -e CONFIG_BTRFS_FS | |
scripts/config -e CONFIG_BTRFS_FS_POSIX_ACL | |
scripts/config -d CONFIG_HZ_100 | |
scripts/config -d CONFIG_HZ_250 | |
scripts/config -d CONFIG_HZ_300 | |
scripts/config -e CONFIG_HZ_1000 | |
scripts/config -e CONFIG_NO_HZ_FULL | |
scripts/config -e CONFIG_CRASH_DUMP | |
scripts/config -e CONFIG_SECURITY_YAMA | |
scripts/config -e CONFIG_USERFAULTFD | |
make KERNEL=kernel8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 -j2 | |
make KERNEL=kernel8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 -j2 dtbs | |
make KERNEL=kernel8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 -j2 INSTALL_HDR_PATH=./headers_root headers_install | |
- name: Create installer.bin | |
run: truncate -s 4096M installer.bin | |
- name: Create loopback device | |
run: sudo mknod -m 0660 /dev/loop254 b 7 254 | |
- name: Mount installer.bin as loopback device | |
run: sudo losetup -P /dev/loop254 installer.bin | |
- name: Create GPT disk label | |
run: sudo parted /dev/loop254 mklabel msdos | |
- name: Create BOOT partition | |
run: sudo parted /dev/loop254 mkpart primary fat32 1 512 | |
- name: Create SYSTEM partition | |
run: sudo parted /dev/loop254 mkpart primary ext2 512 4096 | |
- name: Toogle boot flag on boot partition | |
run: sudo parted /dev/loop254 set 1 boot on | |
- name: Create BOOT filesystem | |
run: sudo mkfs.vfat -F32 /dev/loop254p1 | |
- name: Create SYSTEM filesystem | |
run: sudo mkfs.btrfs /dev/loop254p2 | |
- name: Mount SYSTEM filesystem | |
run: sudo mount -t btrfs -o compress=zstd:15 /dev/loop254p2 /mnt/ | |
- name: Mount BOOT filesystem | |
run: sudo mkdir -p /mnt/boot && sudo mount /dev/loop254p1 /mnt/boot | |
- name: Docker import Void ROOTFS tarball | |
run: curl https://repo-default.voidlinux.org/live/current/void-aarch64-musl-ROOTFS-20240314.tar.xz | xzcat | docker import - voidlinux/voidlinux:latest | |
- name: Docker builder | |
run: docker create --name void-builder voidlinux/voidlinux:latest /bin/bash | |
- name: Add QEMU BINFMT shim | |
run: docker cp /usr/bin/qemu-aarch64-static void-builder:/usr/bin/qemu-aarch64-static | |
- name: Commit builder | |
run: docker commit void-builder voidlinux/voidlinux:latest | |
- name: Docker build | |
run: docker build -t void:latest . | |
- name: Create docker image instance | |
run: docker create --name rpi-image void:latest | |
- name: Docker export | |
run: cd /mnt ; sudo docker export rpi-image | sudo tar --exclude=etc/machine-id --exclude=etc/ssh/*_key* --exclude=etc/ssh/moduli -xf - | |
- name: Free space | |
run: docker rm rpi-image ; docker rmi voidlinux/voidlinux:latest | |
- name: Delete QEMU BINFMT shim | |
run: sudo rm -rf /mnt/usr/bin/qemu-aarch64-static | |
- name: Copy hosts file | |
run: sudo cp config/etc/hosts /mnt/etc | |
- name: Copy hostname file | |
run: sudo cp config/etc/hostname /mnt/etc | |
- name: Unmount | |
run: sudo sync && sudo sync && sudo umount /mnt/boot && sudo umount /mnt | |
- name: Disconnect installer.bin | |
run: sudo losetup -D /dev/loop254 | |
- name: Move into directory | |
run: mkdir void_uconsole_os && mv installer.* void_uconsole_os/ | |
- name: Archive directory | |
run: sudo 7z -mx=9 a void_uconsole_os-${{ env.stamp }}.7z void_uconsole_os/ | |
- name: Create GH release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: true | |
prerelease: false | |
release_name: void_uconsole_os-${{ env.stamp }} | |
tag_name: ${{ env.stamp }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Upload zipped image to release artifacts | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: void_uconsole_os-${{ env.stamp }}.7z | |
asset_name: void_uconsole_os-${{ env.stamp }}.7z | |
asset_content_type: application/x-7z-compressed |