Skip to content

Build rpi archlinuxarm #1235

Build rpi archlinuxarm

Build rpi archlinuxarm #1235

Workflow file for this run

name: Build rpi archlinuxarm
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
paths-ignore:
- "**/README.md"
jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_SH: 'sudo arch-chroot ./builder qemu-aarch64-static /usr/bin/bash -c'
IMG_NAME: 'ArchLinuxARM-rpi-aarch64-latest'
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: Set variables
run: |
echo V_SD=$(losetup -f) >> $GITHUB_ENV
echo RELEASE=$(date +%Y\/%m\/%d) >> $GITHUB_ENV
shell: bash
- name: generate builder
run: |
sudo apt update && sudo apt install qemu-user-static libarchive-tools arch-install-scripts
sudo curl -L -o ./ArchLinuxARM-aarch64-latest.tar.gz http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
sudo mkdir ./builder
sudo bsdtar -xpf ./ArchLinuxARM-aarch64-latest.tar.gz -C ./builder
sudo mount --bind ./builder ./builder
sudo cp /usr/bin/qemu-aarch64-static ./builder/usr/bin/qemu-aarch64-static
sudo cp -f ./pacman.conf ./builder/etc/pacman.conf
${{ env.BUILD_SH }} "pacman -R --ask=4 linux-aarch64"
${{ env.BUILD_SH }} "pacman -Syyu --ask=4 arch-install-scripts cloud-guest-utils"
shell: bash
- name: prepare img file
run: |
dd if=/dev/zero of=${{ env.IMG_NAME }}.img bs=4K count=512K
sudo losetup --partscan ${{ env.V_SD }} ${{ env.IMG_NAME }}.img
sudo parted -s ${{ env.V_SD }} mklabel msdos
sudo parted -s ${{ env.V_SD }} mkpart primary fat32 2048s 411647s
sudo parted -s ${{ env.V_SD }} mkpart primary ext4 411648s 100%
sudo mkfs.vfat -F 32 ${{ env.V_SD }}p1
sudo mkfs.ext4 ${{ env.V_SD }}p2
sudo tune2fs -O ^has_journal ${{ env.V_SD }}p2
sudo mount ${{ env.V_SD }}p2 ./builder/mnt
sudo mkdir -p ./builder/mnt/boot
sudo mount ${{ env.V_SD }}p1 ./builder/mnt/boot
shell: bash
- name: generate target
run: |
echo 0
${{ env.BUILD_SH }} "pacstrap -cGM /mnt $(cat packages.md)"
echo 1
${{ env.BUILD_SH }} "rm -f /mnt/etc/resolv.conf"
echo 2
${{ env.BUILD_SH }} "ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf"
echo 3
${{ env.BUILD_SH }} "echo -e '[Match]\nName=en*\n\n[Network]\nDHCP=yes\nDNSSEC=no'>/mnt/etc/systemd/network/en.network"
echo 4
${{ env.BUILD_SH }} "echo -e '[Match]\nName=eth*\n\n[Network]\nDHCP=yes\nDNSSEC=no'>/mnt/etc/systemd/network/eth.network"
echo 5
${{ env.BUILD_SH }} "echo '/dev/mmcblk0p1 /boot vfat defaults 0 0'>>/mnt/etc/fstab"
echo 6
${{ env.BUILD_SH }} "echo 'alarm'>/mnt/etc/hostname"
echo 7
${{ env.BUILD_SH }} "echo 'LANG=C'>/mnt/etc/locale.conf"
echo 8
${{ env.BUILD_SH }} "useradd -d /home/alarm -m -U alarm --root /mnt"
echo 9
${{ env.BUILD_SH }} "echo -e 'root:root\nalarm:alarm' | chpasswd --root /mnt"
echo 10
${{ env.BUILD_SH }} "usermod -a -G wheel alarm --root /mnt"
echo 11
${{ env.BUILD_SH }} "echo -n > /mnt/etc/machine-id"
echo 12
${{ env.BUILD_SH }} "systemctl --root=/mnt enable $(cat services.md)"
echo 13
shell: bash
- name: clean and create compressed file
run: |
LC_ALL=C
LANG=C
LANGUAGE=
sudo rm -rf ./builder/mnt/etc/*- ./builder/mnt/root/.bash_history ./builder/mnt/root/.gnupg ./builder/mnt/var/log/* ./builder/mnt/var/lib/systemd/*
${{ env.BUILD_SH }} "bsdtar --exclude 'lost+found' --exclude 'boot/System Volume Information' -czf /${{ env.IMG_NAME }}.tar.gz -C /mnt/ ."
sudo mv ./builder/${{ env.IMG_NAME }}.tar.gz ./${{ env.IMG_NAME }}.tar.gz
shell: bash
- name: create and enable resize2fs_once service
run: |
${{ env.BUILD_SH }} "cp -f /usr/bin/growpart /mnt/usr/local/bin/growpart"
${{ env.BUILD_SH }} "curl -L -o /mnt/etc/systemd/system/resize2fs_once.service https://github.com/BurningC4/ArchlinuxARM-rpi-aarch64/raw/main/resize2fs_once.service"
${{ env.BUILD_SH }} "chmod a+x /mnt/usr/local/bin/growpart"
${{ env.BUILD_SH }} "systemctl --root=/mnt enable resize2fs_once.service"
shell: bash
- name: clean and package img file
run: |
${{ env.BUILD_SH }} "rm -rf /mnt/etc/*- /mnt/root/.bash_history /mnt/root/.gnupg /mnt/var/log/* /mnt/var/lib/systemd/* "
sudo umount -R ./builder/mnt
sudo tune2fs -M / ${{ env.V_SD }}p2
sudo e2fsck -yf -E discard ${{ env.V_SD }}p2
sudo resize2fs -M ${{ env.V_SD }}p2
sudo e2fsck -yf ${{ env.V_SD }}p2
IMG_END=$(sudo fdisk -l -o end ${{ env.V_SD }} | sed -n '$p')
sudo losetup -d ${{ env.V_SD }}
sudo truncate --size=$[($IMG_END+1)*512] ${{ env.IMG_NAME }}.img
zip ${{ env.IMG_NAME }}.img.zip ${{ env.IMG_NAME }}.img
shell: bash
- name: prepare release files
run: |
sha256sum ${{ env.IMG_NAME }}.tar.gz > ./${{ env.IMG_NAME }}.tar.gz.sha256sum
sha256sum ${{ env.IMG_NAME }}.img.zip > ./${{ env.IMG_NAME }}.img.zip.sha256sum
shell: bash
- name: create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ env.RELEASE }}
tag_name: ${{ env.RELEASE }}
draft: false
prerelease: false
files: |
./${{ env.IMG_NAME }}.tar.gz
./${{ env.IMG_NAME }}.tar.gz.sha256sum
./${{ env.IMG_NAME }}.img.zip
./${{ env.IMG_NAME }}.img.zip.sha256sum
- name: delete old releases
uses: dev-drprasad/[email protected]
with:
keep_latest: 1
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}