version #85
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: Build Custom Raspberry Pi OS | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
if: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup QEMU | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-system-arm expect | |
- name: Download Raspberry Pi OS Lite (32-bit) | |
run: | | |
wget -q https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf-lite.img.xz | |
unxz 2023-05-03-raspios-bullseye-armhf-lite.img.xz | |
qemu-img resize ./2023-05-03-raspios-bullseye-armhf-lite.img 2G | |
- name: Download QEMU-compatible Raspberry Pi Kernel and dtb | |
run: | | |
mkdir qemu_rpi_kernel | |
wget -O qemu_rpi_kernel/kernel-qemu-5.10.63-bullseye https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-5.10.63-bullseye | |
wget -O qemu_rpi_kernel/versatile-pb.dtb https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/versatile-pb-bullseye-5.10.63.dtb | |
- name: Configure user and password for Raspberry Pi OS | |
run: | | |
mkdir boot_mount | |
PASS=$(echo 'raspberry' | openssl passwd -6 -stdin) | |
sudo mount -o loop,offset=$((512*8192)) ./2023-05-03-raspios-bullseye-armhf-lite.img boot_mount/ | |
echo "pi:$PASS" | sudo tee boot_mount/userconf.txt | |
sudo umount boot_mount | |
- name: Start QEMU and Customize Image | |
run: | | |
echo '#!/usr/bin/expect -f | |
set timeout 3600 | |
spawn qemu-system-arm -kernel qemu_rpi_kernel/kernel-qemu-5.10.63-bullseye -dtb qemu_rpi_kernel/versatile-pb.dtb -cpu arm1176 -m 256 -M versatilepb -drive file=./2023-05-03-raspios-bullseye-armhf-lite.img,format=raw -net user,hostfwd=tcp::5022-:22 -net nic -append "root=/dev/sda2 rootfstype=ext4 rw" -no-reboot -nographic | |
expect "User configuration dialog" | |
expect "raspberrypi login:" | |
expect "Multi-User System" | |
send "pi\r" | |
expect "Password:" | |
send "raspberry\r" | |
expect "permitted by applicable law." | |
send "bind 'set enable-bracketed-paste off'\r" | |
send "\r" | |
send "\r" | |
send "sudo apt update -y && sudo apt-get install -y openssh-server libopenjp2-7 && sudo systemctl enable ssh && sudo systemctl start ssh && sudo shutdown -h now\r" | |
expect eof' > modify_image.exp | |
chmod +x modify_image.exp | |
./modify_image.exp | |
ssh-keygen -f ~/.ssh/id_rsa -N "" | |
cat ~/.ssh/id_rsa.pub | ssh -p 5022 pi@localhost "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys" | |
scp -P 5022 ./frame/run.py pi@localhost:/srv/frameos/run.py | |
scp -P 5022 -r ./frame/frame pi@localhost:/srv/frameos/frame | |
scp -P 5022 ./frame/requirements.txt pi@localhost:/srv/frameos/requirements.txt | |
xz 2023-05-03-raspios-bullseye-armhf-lite.img | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./2023-05-03-raspios-bullseye-armhf-lite.img.xz | |
asset_name: frameos-raspberry-pi-os-32bit.img.xz | |
asset_content_type: application/octet-stream |