Skip to content

Commit

Permalink
feat: add auto-generated license info for rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
diegonehab committed Sep 19, 2024
1 parent 1fbaccc commit 7b559e2
Show file tree
Hide file tree
Showing 12 changed files with 467 additions and 365 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ libcmt*
.github
.git
*.md
fs
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build
on: [push]
jobs:
build:
needs: [test]
# needs: [test]
runs-on: ubuntu-latest-8-cores
steps:
- name: Install libarchive-tools
Expand Down Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Create version file
run: make package.json

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Buildx setup
uses: docker/setup-buildx-action@v3

Expand Down Expand Up @@ -101,6 +104,7 @@ jobs:
path: |
${{ env.TOOLS_DEB }}
${{ env.TOOLS_ROOTFS }}
${{ env.TOOLS_ROOTFS }}.md
libcmt/deb/*
- name: Checksum artifacts
Expand All @@ -118,6 +122,7 @@ jobs:
${{ env.TOOLS_DEB }}
${{ env.TOOLS_DEB }}.sha512
${{ env.TOOLS_ROOTFS }}
${{ env.TOOLS_ROOTFS }}.md
${{ env.TOOLS_ROOTFS }}.sha512
libcmt/deb/*
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Bump dependencies versions
- Added rootfs.ext2:/etc/LICENSES file listing licenses of all installed packages

## [0.16.1] - 2024-08-12
### Fixed
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

MAJOR := 0
MINOR := 16
PATCH := 1
PATCH := 2
LABEL :=
VERSION := $(MAJOR).$(MINOR).$(PATCH)$(LABEL)

TOOLS_DEB := machine-emulator-tools-v$(VERSION).deb
TOOLS_IMAGE := cartesi/machine-emulator-tools:$(VERSION)
TOOLS_ROOTFS := rootfs-tools-v$(VERSION).ext2
TOOLS_ROOTFS_IMAGE := cartesi/rootfs-tools:$(VERSION)

IMAGE_KERNEL_VERSION ?= v0.20.0
LINUX_VERSION ?= 6.5.13-ctsi-1
Expand Down Expand Up @@ -54,13 +55,19 @@ package.json: Makefile package.json.in
@sed 's|ARG_VERSION|$(VERSION)|g' package.json.in > package.json

$(TOOLS_ROOTFS) fs: $(TOOLS_DEB)
@docker buildx build --platform=linux/riscv64 \
@docker buildx build --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
--output type=tar,dest=rootfs.tar \
--file fs/Dockerfile \
. && \
xgenext2fs -fzB 4096 -b 25600 -i 4096 -a rootfs.tar -L rootfs $(TOOLS_ROOTFS) && \
rm -f rootfs.tar
@docker buildx build --load --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
-t $(TOOLS_ROOTFS_IMAGE) \
--file fs/Dockerfile \
.
(cd fs/third-party/repo-info/; ./scan-local.sh $(TOOLS_ROOTFS_IMAGE) linux/riscv64) | tee $(TOOLS_ROOTFS).md

libcmt:
@mkdir $@
Expand All @@ -84,6 +91,7 @@ env:
@echo TOOLS_DEB=$(TOOLS_DEB)
@echo TOOLS_ROOTFS=$(TOOLS_ROOTFS)
@echo TOOLS_IMAGE=$(TOOLS_IMAGE)
@echo TOOLS_ROOTFS_IMAGE=$(TOOLS_ROOTFS_IMAGE)
@echo IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION)
@echo LINUX_VERSION=$(LINUX_VERSION)
@echo LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH)
Expand Down
1 change: 1 addition & 0 deletions fs/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
third-party
66 changes: 17 additions & 49 deletions fs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,22 @@
FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS cross-builder
ENV BUILD_BASE=/tmp/build-extra

# Install dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
wget \
patch \
libdigest-sha-perl \
libc6-dev-riscv64-cross \
gcc-12-riscv64-linux-gnu \
&& \
adduser developer -u 499 --gecos ",,," --disabled-password && \
mkdir -p ${BUILD_BASE} && chown -R developer:developer ${BUILD_BASE} && \
rm -rf /var/lib/apt/lists/*

USER developer
WORKDIR ${BUILD_BASE}

# Build benchmark binaries
COPY fs/dhrystone.patch ${BUILD_BASE}/
COPY fs/shasumfile ${BUILD_BASE}/
RUN mkdir benchmarks && cd benchmarks && \
wget https://www.netlib.org/benchmark/whetstone.c https://www.netlib.org/benchmark/dhry-c && \
shasum -ca 256 ../shasumfile &&\
bash dhry-c && \
patch -p1 < ../dhrystone.patch && \
riscv64-linux-gnu-gcc-12 -O2 -o whetstone whetstone.c -lm && \
riscv64-linux-gnu-gcc-12 -O2 -o dhrystone dhry_1.c dhry_2.c -lm

# Final image
FROM --platform=linux/riscv64 riscv64/ubuntu:22.04
ARG TOOLS_DEB=machine-emulator-tools-v0.15.0.deb
FROM --platform=$TARGETPLATFORM ubuntu:22.04
ARG TOOLS_DEB=machine-emulator-tools-v0.16.2.deb
ADD ${TOOLS_DEB} /tmp/
RUN apt-get update && \
apt-get install -y --no-install-recommends \
busybox-static=1:1.30.1-7ubuntu3 \
coreutils=8.32-4.1ubuntu1.2 \
bash=5.1-6ubuntu1.1 \
psmisc=23.4-2build3 \
bc=1.07.1-3build1 \
curl=7.81.0-1ubuntu1.17 \
device-tree-compiler=1.6.1-1 \
jq=1.6-2.1ubuntu3 \
lua5.4=5.4.4-1 \
lua-socket=3.0~rc1+git+ac3201d-6 \
xxd=2:8.2.3995-1ubuntu2.16 \
file=1:5.41-3ubuntu0.1 \
/tmp/${TOOLS_DEB} \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
busybox-static=1:1.30.1-7ubuntu3 \
coreutils=8.32-4.1ubuntu1.2 \
bash=5.1-6ubuntu1.1 \
psmisc=23.4-2build3 \
bc=1.07.1-3build1 \
curl=7.81.0-1ubuntu1.18 \
device-tree-compiler=1.6.1-1 \
jq=1.6-2.1ubuntu3 \
lua5.4=5.4.4-1 \
lua-socket=3.0~rc1+git+ac3201d-6 \
xxd=2:8.2.3995-1ubuntu2.18 \
file=1:5.41-3ubuntu0.1 \
stress-ng=0.13.12-2ubuntu1 \
/tmp/${TOOLS_DEB} \
&& \
rm -rf /var/lib/apt/lists/* /tmp/${TOOLS_DEB}
COPY --chown=root:root --from=cross-builder /tmp/build-extra/benchmarks/whetstone /usr/bin/
COPY --chown=root:root --from=cross-builder /tmp/build-extra/benchmarks/dhrystone /usr/bin/
Loading

0 comments on commit 7b559e2

Please sign in to comment.