Skip to content

Build Debian Rootfs #51

Build Debian Rootfs

Build Debian Rootfs #51

Workflow file for this run

name: Build Debian Rootfs
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
jobs:
Build:
runs-on: ${{ matrix.config.os }}
container:
image: lazymio/qemu-full
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',
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',
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',
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',
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',
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',
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',
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',
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',
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-rpi',
kernel: 'linux-image-rpi',
artifact: 'debian-bullseye-rpi',
hostname: 'debian-bullseye-rpi',
qcow2: 'debian-bullseye-rpi.qcow2',
rootfs: 'debian-bullseye-rpi.tar.xz',
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',
# iface: 'eth0' # Append "net.ifnames=0", ref: https://wiki.debian.org/NetworkInterfaceNames
# }
steps:
- uses: actions/checkout@v2
- name: '🚧 Dependency'
shell: bash
run: |
apt update && apt install libguestfs-tools linux-image-generic debian-ports-archive-keyring binfmt-support -y
- name: '🚧 Deboostrap 1st stage'
shell: bash
run: |
mkdir mnt
debootstrap --foreign --arch=${{ matrix.config.arch }} --include=locales ${{ matrix.config.suite }} mnt/ http://deb.debian.org/debian
# 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: '🚧 Deboostrap 1st stage (ports)'
if: ${{ contains(matrix.config.arch, 'loong64') || contains(matrix.config.arch, 'riscv64') }}
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/ http://ftp.ports.debian.org/debian-ports
- name: '🚧 Deboostrap 2nd stage'
shell: bash
run: |
update-binfmts --display
find /opt/binfmt -name "qemu-*" -exec bash -c 'update-binfmts --unimport {} && update-binfmts --importdir /opt/binfmt --import {}' ';'
find /opt/binfmt -name "qemu-*" -exec bash -c 'cat {} | sed -n -r -e 's/package (qemu-.*)/\1/p | xargs update-binfmts --enable' ';'
update-binfmts --display
cp $(which qemu-${{ matrix.config.qemu-arch }}-static) mnt/usr/bin/
chroot mnt/ debootstrap/debootstrap --second-stage
- name: '🚧 Install Kernel & fstab'
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'
shell: bash
run: |
chroot mnt/ apt install openssh-server -y
- name: '🚧 Configure Debian'
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: '📦 Remove QEMU'
shell: bash
run: |
rm /usr/bin/qemu-${{ matrix.config.qemu-arch }}-static
- 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'
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/*