Skip to content

Commit

Permalink
add kerenl build
Browse files Browse the repository at this point in the history
Signed-off-by: Bo YU <tsu.yubo@gmail.com>
  • Loading branch information
yuzibo committed Dec 14, 2023
1 parent a342c45 commit 6d467be
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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}

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

./create_image.sh /outport
KERNEL_VERSION="$1"

./create_image.sh /outport ${KERNEL_VERSION}
13 changes: 13 additions & 0 deletions create_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -48,13 +49,25 @@ 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
cp -a /builder/rv64-port/* "${ROOTFS_POINT}"

# 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"

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ services:
# build host dir with docker dir
volumes:
- './image:/outport'
# vf2 kernel passed here
environment:
- KERNEL_VERSION=${KERNEL_VERSION}
2 changes: 2 additions & 0 deletions rootfs/setup_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6d467be

Please sign in to comment.