Update build.yaml #81
Workflow file for this run
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 Debian Rootfs | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
Build: | |
runs-on: ${{ matrix.config.os }} | |
container: | |
image: ${{ matrix.config.image }} | |
options: --privileged | |
name: ${{ matrix.config.name }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: amd64, | |
qemu-arch: "x86_64", | |
name: 'Debian-bullseye-amd64', | |
kernel: 'linux-image-amd64', | |
artifact: 'debian-bullseye-amd64', | |
hostname: 'debian-bullseye-amd64', | |
qcow2: 'debian-bullseye-amd64.qcow2', | |
rootfs: 'debian-bullseye-amd64.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.1.4', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: mipsel, | |
qemu-arch: "mipsel", | |
name: 'Debian-bullseye-mipsel-malta', | |
kernel: 'linux-image-4kc-malta', | |
artifact: 'debian-bullseye-mipsel-malta', | |
hostname: 'debian-bullseye-mipsel-malta', | |
qcow2: 'debian-bullseye-mipsel-malta.qcow2', | |
rootfs: 'debian-bullseye-mipsel-malta.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.1.4', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: mips64el, | |
qemu-arch: "mips64el", | |
name: 'Debian-bullseye-mips64el-malta', | |
kernel: 'linux-image-5kc-malta', | |
artifact: 'debian-bullseye-mips64el-malta', | |
hostname: 'debian-bullseye-mips64el-malta', | |
qcow2: 'debian-bullseye-mips64el-malta.qcow2', | |
rootfs: 'debian-bullseye-mips64el-malta.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.1.4', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: armhf, | |
qemu-arch: "arm", | |
name: 'Debian-bullseye-armhf-armmp', | |
kernel: 'linux-image-armmp', | |
artifact: 'debian-bullseye-armhf-armmp', | |
hostname: 'debian-bullseye-armhf-armmp', | |
qcow2: 'debian-bullseye-armhf-armmp.qcow2', | |
rootfs: 'debian-bullseye-armhf-armmp.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.1.4', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
# - { | |
# os: ubuntu-latest, | |
# suite: bullseye, | |
# arch: armel, | |
# qemu-arch: "arm", | |
# name: 'Debian-bullseye-armel-versatile', | |
# kernel: 'linux-image-versatile', # Has been removed: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=977126 | |
# artifact: 'debian-bullseye-armel-versatile', | |
# hostname: 'debian-bullseye-armel-versatile', | |
# qcow2: 'debian-bullseye-armel-versatile.qcow2', | |
# rootfs: 'debian-bullseye-armel-versatile.tar.xz', | |
# iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
# } | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: arm64, | |
qemu-arch: "aarch64", | |
name: 'Debian-bullseye-arm64', | |
kernel: 'linux-image-arm64', | |
artifact: 'debian-bullseye-arm64', | |
hostname: 'debian-bullseye-arm64', | |
qcow2: 'debian-bullseye-arm64.qcow2', | |
rootfs: 'debian-bullseye-arm64.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v7.2.8', # v8.x will segfault, no idea | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: i386, | |
qemu-arch: "i386", | |
name: 'Debian-bullseye-i386', | |
kernel: 'linux-image-686', | |
artifact: 'debian-bullseye-i386', | |
hostname: 'debian-bullseye-i386', | |
qcow2: 'debian-bullseye-i386.qcow2', | |
rootfs: 'debian-bullseye-i386.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.1.4', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: unstable, | |
arch: riscv64, | |
qemu-arch: "riscv64", | |
name: 'Debian-bullseye-riscv64', | |
kernel: 'linux-image-riscv64', | |
artifact: 'debian-bullseye-riscv64', | |
hostname: 'debian-bullseye-riscv64', | |
qcow2: 'debian-bullseye-riscv64.qcow2', | |
rootfs: 'debian-bullseye-riscv64.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.2.0', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: ppc64el, | |
qemu-arch: "ppc64le", | |
name: 'Debian-bullseye-ppc64el', | |
kernel: 'linux-image-powerpc64le', | |
artifact: 'debian-bullseye-ppc64el', | |
hostname: 'debian-bullseye-ppc64el', | |
qcow2: 'debian-bullseye-ppc64el.qcow2', | |
rootfs: 'debian-bullseye-ppc64el.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.1.4', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
- { | |
os: ubuntu-latest, | |
suite: bullseye, | |
arch: s390x, | |
qemu-arch: "s390x", | |
name: 'Debian-bullseye-s390x', | |
kernel: 'linux-image-s390x', | |
artifact: 'debian-bullseye-s390x', | |
hostname: 'debian-bullseye-s390x', | |
qcow2: 'debian-bullseye-s390x.qcow2', | |
rootfs: 'debian-bullseye-s390x.tar.xz', | |
pool: 'http://deb.debian.org/debian', | |
image: 'lazymio/qemu-full:v8.2.0', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
# - { # Known not working: https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1779934.html | |
# os: ubuntu-latest, | |
# suite: bullseye, | |
# arch: armel, | |
# qemu-arch: "arm", | |
# name: 'Debian-bullseye-rpi', | |
# kernel: 'linux-image-rpi', | |
# artifact: 'debian-bullseye-rpi', | |
# hostname: 'debian-bullseye-rpi', | |
# qcow2: 'debian-bullseye-rpi.qcow2', | |
# rootfs: 'debian-bullseye-rpi.tar.xz', | |
# pool: 'http://deb.debian.org/debian', | |
# image: 'lazymio/qemu-full:v8.2.0', | |
# iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
# } | |
- { # Disabled due to no kernel available | |
os: ubuntu-latest, | |
suite: unstable, | |
arch: loong64, | |
qemu-arch: "loongarch64", | |
name: 'Debian-bullseye-loong64', | |
kernel: 'linux-image-loong64', | |
artifact: 'debian-bullseye-loong64', | |
hostname: 'debian-bullseye-loong64', | |
qcow2: 'debian-bullseye-loong64.qcow2', | |
rootfs: 'debian-bullseye-loong64.tar.xz', | |
pool: 'http://ftp.ports.debian.org/debian-ports', | |
image: 'lazymio/qemu-full:v8.2.0', | |
iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames | |
} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: '🚧 Mount binfmt_misc' | |
shell: bash | |
run: | | |
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc | |
update-binfmts --display | |
ls /opt/binfmt_fixed/ | awk '{print $1}' | xargs -L 1 update-binfmts --importdir /opt/binfmt_fixed --unimport | |
ls /opt/binfmt_fixed/ | awk '{print $1}' | xargs -L 1 update-binfmts --importdir /opt/binfmt_fixed --import | |
ls /opt/binfmt_fixed/ | awk '{print $1}' | xargs -L 1 update-binfmts --enable | |
update-binfmts --display | |
- name: '🚧 Dependency' | |
shell: bash | |
run: | | |
apt update && apt install libguestfs-tools linux-image-generic debian-ports-archive-keyring aria2 -y | |
- name: '🚧 Deboostrap 1st stage' | |
if: ${{ !contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
mkdir mnt | |
debootstrap --foreign --arch=${{ matrix.config.arch }} --include=locales ${{ matrix.config.suite }} mnt/ ${{ matrix.config.pool }} | |
# https://wiki.debian.org/LoongArch/sbuildQEMU | |
# https://docs.loongnix.cn/loongnix/faq/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/%E6%A1%8C%E9%9D%A2%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F.html | |
- name: '🚧 Install Loong ArchLiunux firstly' | |
if: ${{ contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
mkdir arch | |
cd arch | |
echo "https://mirrors.nju.edu.cn/loongarch/archlinux/iso/latest/archlinux-bootstrap-loong64.tar.gz \ | |
https://mirrors.pku.edu.cn/loongarch/archlinux/iso/latest/archlinux-bootstrap-loong64.tar.gz \ | |
https://mirrors.wsyu.edu.cn/loongarch/archlinux/iso/latest/archlinux-bootstrap-loong64.tar.gz \ | |
https://mirror.iscas.ac.cn/loongarch/archlinux/iso/latest/archlinux-bootstrap-loong64.tar.gz" | aria2c --lowest-speed-limit=1M -s14 -x14 -k2M -j 4 --continue=true -i - | |
tar xf archlinux-bootstrap-loong64.tar.gz | |
mkdir -p root.loong64/target | |
# echo "Server = https://mirrors.nju.edu.cn/loongarch/archlinux/$repo/os/$arch" > root.loong64/etc/pacman.d/mirrorlist | |
echo "nameserver 8.8.8.8" >> root.loong64/etc/resolv.conf # Configure DNS manually | |
mount --bind /proc root.loong64/proc | |
mount --bind /dev root.loong64/dev | |
chroot root.loong64/ pacman-key --init | |
chroot root.loong64/ pacman-key --populate | |
# chroot root.loong64/ pacman-key --refresh-keys # Slow and seems not necessary | |
sed -i -e "s/CheckSpace/#CheckSpace/g" root.loong64/etc/pacman.conf | |
chroot root.loong64/ pacman -Syu --noconfirm archlinux-keyring | |
for i in 1 2 3 4 5; do bash -c "chroot root.loong64/ pacstrap /target base base-devel linux linux-firmware networkmanager grub efibootmgr" && break; done | |
umount --recursive --force root.loong64/dev || true # It's okay they failed | |
umount --recursive --force root.loong64/proc || true | |
- name: '🚧 Deboostrap 1st stage (loong64)' | |
if: ${{ contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
mkdir mnt/ | |
debootstrap --foreign --arch=${{ matrix.config.arch }} \ | |
--variant=buildd --include=locales \ | |
--include=debian-ports-archive-keyring \ | |
--components=main \ | |
--keyring=/etc/apt/trusted.gpg.d/debian-ports-archive-2023.gpg \ | |
--extra-suites=unreleased \ | |
${{ matrix.config.suite }} mnt/ ${{ matrix.config.pool }} | |
- name: '🚧 Deboostrap 2nd stage' | |
shell: bash | |
run: | | |
chroot mnt/ debootstrap/debootstrap --second-stage | |
- name: '🚧 Install Kernel & fstab' | |
if: ${{ !contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
bash -c "echo 'fake /usr ext4 fake 0 1' > mnt/etc/fstab" | |
chroot mnt/ apt update && chroot mnt/ apt install ${{ matrix.config.kernel }} -y | |
bash -c "echo '/dev/sda / ext4 errors=remount-ro 0 1' > mnt/etc/fstab" | |
- name: '🚧 Install SSH' | |
if: ${{ !contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
chroot mnt/ apt install openssh-server -y | |
- name: '🚧 Configure Loongarch ArchLinux' | |
if: ${{ contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
cd arch/root.loong64/ | |
mount --bind /proc target/proc | |
mount --bind /dev target/dev | |
echo "nameserver 8.8.8.8" >> target/etc/resolv.conf | |
echo ${{ matrix.config.hostname }} > target/etc/hostname | |
chroot target/ pacman-key --init | |
chroot target/ pacman-key --populate | |
sed -i -e "s/CheckSpace/#CheckSpace/g" target/etc/pacman.conf | |
chroot target/ pacman -Syu --noconfirm openssh | |
chroot target/ systemctl enable sshd | |
chroot target/ systemctl enable NetworkManager | |
chroot target/ useradd -m -G wheel -s /bin/bash debian | |
chroot target/ bash -c 'echo "debian:debian" | chpasswd' | |
chroot target/ bash -c 'echo "root:root" | chpasswd' | |
umount --recursive --force target/dev || true # It's okay they failed | |
umount --recursive --force target/proc || true | |
cd ../../ | |
mv mnt debian | |
mv arch/root.loong64/target mnt | |
mv debian mnt/ | |
echo "nameserver 8.8.8.8" >> mnt/debian/etc/resolv.conf | |
- name: '🚧 Configure Debian' | |
if: ${{ !contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
bash -c "ls -lha mnt/etc/network/" | |
bash -c "echo >> mnt/etc/network/interfaces" | |
bash -c "echo 'auto ${{ matrix.config.iface }}' >> mnt/etc/network/interfaces" | |
bash -c "echo 'iface ${{ matrix.config.iface }} inet dhcp' >> mnt/etc/network/interfaces" | |
bash -c "cat /dev/null > mnt/etc/machine-id" | |
bash -c "echo ${{ matrix.config.hostname }} > mnt/etc/hostname" | |
# sudo chroot mnt bash -c 'echo "debian:debian" | chpasswd' | |
chroot mnt bash -c "adduser --disabled-password --gecos '' debian" | |
chroot mnt bash -c 'echo "root:root" | chpasswd' | |
chroot mnt bash -c 'echo "debian:debian" | chpasswd' | |
- name: '📦 Pack qcow2' | |
shell: bash | |
run: | | |
mkdir artifact | |
virt-make-fs --type=ext4 --size=5G mnt raw.img | |
qemu-img convert -c -f raw -O qcow2 raw.img artifact/${{ matrix.config.qcow2 }} | |
- name: '📦 Pack Initrd & Kernel' | |
if: ${{ contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
find mnt/boot -name "vmlinu*" -exec mv {} ./artifact/vmlinuz-loong64 ';' | |
find mnt/boot -name "initram*" -exec mv {} ./artifact/initrd.img-loong64 ';' | |
cd artifact | |
echo "https://mirrors.nju.edu.cn/loongarch/archlinux/images/QEMU_EFI_8.1.fd \ | |
https://mirrors.pku.edu.cnloongarch/archlinux/images/QEMU_EFI_8.1.fd \ | |
https://mirrors.wsyu.edu.cn/loongarch/archlinux/images/QEMU_EFI_8.1.fd \ | |
https://mirror.iscas.ac.cn/loongarch/archlinux/images/QEMU_EFI_8.1.fd" | aria2c --lowest-speed-limit=200K -s14 -x14 -k1M -j 4 --continue=true -i - | |
mv QEMU_EFI_8.1.fd bios-loong64-8.1.bin | |
- name: '📦 Pack Initrd & Kernel' | |
if: ${{ !contains(matrix.config.arch, 'loong64') }} | |
shell: bash | |
run: | | |
cp mnt/boot/vmlinu* ./artifact/ | |
cp mnt/boot/initrd.img-* ./artifact/ | |
- name: '📦 Pack Rootfs' | |
shell: bash | |
run: | | |
ls -la . | |
ls -la artifact/ | |
tar caf artifact/${{ matrix.config.rootfs }} --one-file-system mnt | |
- name: '📤 Upload artifact' | |
uses: actions/upload-artifact@v2 | |
with: | |
path: ./artifact/ | |
name: artifact | |
publish: | |
needs: [Build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: artifact | |
path: artifact | |
- name: '📦 Check artifacts' | |
shell: bash | |
run: | | |
ls -la artifact/ | |
- name: '📦 Release' | |
if: startsWith(github.ref, 'refs/tags') | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ secrets.RELEASE_TOKEN }} | |
files: ./artifact/* |