diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98e2836..b0e3000 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,10 +18,14 @@ jobs: with: submodules: recursive token: ${{ secrets.CI_TOKEN }} + fetch-depth: 0 # fetch tags - name: Copy default Buildroot and Busybox config run: make init-config + - name: Resolve rootfs filename from Makefile + run: echo ROOTFS_FILENAME="$(make rootfs-filename)" >> $GITHUB_ENV + - name: Setup primary site run: sed -i -e 's#BR2_PRIMARY_SITE=""#BR2_PRIMARY_SITE="http://172.17.0.1:8080"#' cartesi-buildroot-config @@ -75,6 +79,7 @@ jobs: build-args: | TOOLCHAIN_REPOSITORY=${{ secrets.DOCKER_ORGANIZATION }}/toolchain TOOLCHAIN_VERSION=${{ env.TOOLCHAIN_VERSION }} + ROOTFS_FILENAME=${{ env.ROOTFS_FILENAME }} cache-from: type=gha,mode=max,scope=regular cache-to: type=gha,scope=regular @@ -88,7 +93,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') with: prerelease: true - files: rootfs.ext2 + files: rootfs-*.ext2 env: GITHUB_TOKEN: ${{ secrets.CI_TOKEN }} diff --git a/.gitignore b/.gitignore index 6afff05..2b8bfc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -rootfs.ext2 +rootfs-*.ext2 cartesi-buildroot-config cartesi-busybox-fragment skel/etc/os-release diff --git a/Dockerfile b/Dockerfile index 343b789..4763c13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ ARG RISCV_ARCH=rv64g ARG RISCV_ABI=lp64d ENV RISCV_ARCH $RISCV_ARCH ENV RISCV_ABI $RISCV_ABI +ARG ROOTFS_FILENAME=rootfs.ext2 ENV RISCV "$BASE/riscv64-cartesi-linux-gnu" ENV PATH "$RISCV/bin:${OLDPATH}" @@ -62,8 +63,8 @@ RUN \ cp local.mk work/local.mk && \ make BR2_EXTERNAL=$BUILD_BASE/buildroot/external O=work olddefconfig && \ make -C work && \ - cp work/images/rootfs.ext2 $BUILD_BASE/artifacts && \ - truncate -s %4096 $BUILD_BASE/artifacts/rootfs.ext2 + cp work/images/rootfs.ext2 $BUILD_BASE/artifacts/$ROOTFS_FILENAME && \ + truncate -s %4096 $BUILD_BASE/artifacts/$ROOTFS_FILENAME USER root diff --git a/Makefile b/Makefile index 246f06c..067d193 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,15 @@ BUSYBOX_CONFIG ?= configs/default-busybox-fragment RISCV_ARCH ?= rv64g RISCV_ABI ?= lp64d +ROOTFS_VERSION ?= $(shell git describe --dirty --tags) +ROOTFS_FILENAME ?= rootfs-$(ROOTFS_VERSION).ext2 + CONTAINER_BASE := /opt/cartesi/rootfs IMG_REPO ?= cartesi/rootfs IMG ?= $(IMG_REPO):$(TAG) BASE:=/opt/riscv -ART:=$(BASE)/rootfs/artifacts/rootfs.ext2 +ART:=$(BASE)/rootfs/artifacts/$(ROOTFS_FILENAME) ifneq ($(TOOLCHAIN_DOCKER_REPOSITORY),) BUILD_ARGS := --build-arg TOOLCHAIN_REPOSITORY=$(TOOLCHAIN_DOCKER_REPOSITORY) @@ -39,6 +42,7 @@ endif BUILD_ARGS += --build-arg RISCV_ARCH=$(RISCV_ARCH) BUILD_ARGS += --build-arg RISCV_ABI=$(RISCV_ABI) +BUILD_ARGS += --build-arg ROOTFS_FILENAME=$(ROOTFS_FILENAME) .NOTPARALLEL: all all: build copy @@ -83,7 +87,7 @@ clean-config: rm -f ./cartesi-buildroot-config ./cartesi-busybox-fragment clean: clean-config - rm -f rootfs.ext2 + rm -f $(ROOTFS_FILENAME) copy: ID=`docker create $(IMG)` && docker cp $$ID:$(ART) . && docker rm -v $$ID @@ -97,7 +101,7 @@ echo-os-release: HOME_URL="https://cartesi.io/" SUPPORT_URL="https://docs.cartesi.io/" BUG_REPORT_URL="https://docs.cartesi.io/#qa" - VERSION_ID="$(shell git describe --long --dirty --tags)" + VERSION_ID="$(ROOTFS_VERSION)" skel/etc/os-release: $(MAKE) --no-print-directory echo-os-release > $@ @@ -107,3 +111,6 @@ copy-br2-dl-cache: ID=`docker create $(IMG)` && \ docker cp $$ID:/opt/riscv/rootfs/buildroot/dl $(CACHE_DIR) && \ docker rm -v $$ID + +rootfs-filename: + @echo $(ROOTFS_FILENAME)