diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66deb66..71d9bc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,12 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Git + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Get tag name + run: echo "Tag name is ${{ github.ref_name }}" + - name: "Update APT sources" run: | sudo apt update @@ -29,7 +35,7 @@ jobs: - name: Create vf2 rootfs run: | export DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 vf2 - docker-compose up vf2 + ${{ github.ref_name }} docker-compose up vf2 ls -l image/* - name: Release uses: softprops/action-gh-release@v1 diff --git a/Dockerfile b/Dockerfile index 26ca791..2021eca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM debian:sid as builder MAINTAINER Bo YU "tsu.yubo@gmail.com" +ENV KERNEL_VERSION=${KERNEL_VERSION} + ARG DEBIAN_FRONTEND=noninteractive RUN --mount=type=cache,sharing=shared,target=/var/cache \ @@ -40,5 +42,5 @@ COPY --from=build_rootfs /build/rv64-sid/ ./rv64-port/ COPY create_image.sh build.sh ./ COPY rootfs/setup_rootfs.sh ./rv64-port/ -CMD eatmydata /builder/build.sh +CMD eatmydata /builder/build.sh ${KERNEL_VERSION} diff --git a/README.md b/README.md index 3f7579e..a7c1e20 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,10 @@ sudo apt install -y qemu-user-static qemu-system qemu-utils qemu-system-misc bin Need docker docker-compose installed, then type: ```bash sudo DOCKER_BUILDKIT=1 docker-compose build vf2 -sudo docker-compose up vf2 + +# need kernel tag from +# https://github.com/yuzibo/vf2-linux/tags +sudo docker-compose up vf2 KERNEL_TAG=vf2-v6.6.7-v1 ``` Or: ```bash diff --git a/build.sh b/build.sh index 0312934..c84582d 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,5 @@ #!/bin/sh -./create_image.sh /outport +KERNEL_VERSION="$1" + +./create_image.sh /outport ${KERNEL_VERSION} diff --git a/create_image.sh b/create_image.sh index cedcc1b..827be66 100755 --- a/create_image.sh +++ b/create_image.sh @@ -2,6 +2,7 @@ # It woule be good to test it outside of Docker OUT_DIR="$1" +KERNEL_VERSION="$2" ROOTFS_IMG="${OUT_DIR}/vf2-rootfs.img" SD_DD_OPTS="bs=4k iflag=fullblock oflag=direct conv=fsync status=progress" @@ -48,6 +49,16 @@ function make_image(){ kpartx -d ${ROOTFS_IMG} } +function get_kernel_deb(){ + vf2_image_repo="https://github.com/yuzibo/vf2-linux" + kernel_deb_url="${vf2_image_repo}/releases/download/${KERNEL_VERSION}/vf2-mainline-kernel-gcc-13.tar.gz" + + wget --no-check-certificate ${kernel_deb_url} + + tar -zxvf vf2-mainline-kernel-gcc-13.tar.gz -C /tmp + +} + function copy_rootfs(){ # from docker image has been defined @@ -55,6 +66,8 @@ function copy_rootfs(){ # Copy the rootfs cp /usr/bin/qemu-riscv64-static ${ROOTFS_POINT}/usr/bin/ + # should judge deb if exist + cp /tmp/vf2_kernel_deb/*.deb ${ROOTFS_POINT}/tmp chroot "${ROOTFS_POINT}" qemu-riscv64-static /bin/sh /setup_rootfs.sh rm "${ROOTFS_POINT}/setup_rootfs.sh" "${ROOTFS_POINT}/usr/bin/qemu-riscv64-static" diff --git a/docker-compose.yml b/docker-compose.yml index 5a286c2..760835b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,3 +10,6 @@ services: # build host dir with docker dir volumes: - './image:/outport' + # vf2 kernel passed here + environment: + - KERNEL_VERSION=${KERNEL_VERSION} diff --git a/rootfs/setup_rootfs.sh b/rootfs/setup_rootfs.sh index a7e6eaf..3134a27 100755 --- a/rootfs/setup_rootfs.sh +++ b/rootfs/setup_rootfs.sh @@ -37,6 +37,8 @@ usermod --password "$(echo debian | openssl passwd -1 -stdin)" debian #rm /boot/initrd* #update-initramfs -c -k all +apt install -f /tmp/*.deb + # create /boot/efi mkdir -p /boot/efi