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 Oct 2, 2024
1 parent 613f7cf commit 36907f5
Show file tree
Hide file tree
Showing 12 changed files with 542 additions and 369 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
21 changes: 19 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Build
on: [push]
jobs:
build:
needs: [test]
# needs: [test]
runs-on: ubuntu-latest-8-cores
steps:
- name: Install libarchive-tools
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential autoconf automake libarchive-dev libarchive-tools
sudo apt-get install -y --no-install-recommends build-essential autoconf automake libarchive-dev libarchive-tools pandoc
# Building from source cause the provided debian package is for Debian Bookworm
- name: Download, build and install xgenext2fs
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 All @@ -76,6 +79,19 @@ jobs:
- name: Build rootfs
run: make fs

- name: Auto-generate rootfs license information
if: startsWith(github.ref, 'refs/tags/v')
run: make fs-license

- name: Upload rootfs license information
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: license
if-no-files-found: error
path: |
${{ env.TOOLS_ROOTFS }}.html
- name: Build libcmt
id: docker_build_libcmt
uses: docker/build-push-action@v5
Expand Down Expand Up @@ -118,6 +134,7 @@ jobs:
${{ env.TOOLS_DEB }}
${{ env.TOOLS_DEB }}.sha512
${{ env.TOOLS_ROOTFS }}
${{ env.TOOLS_ROOTFS }}.html
${{ 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
- Generate rootfs.ext2.html with licenses of all installed packages

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

MAJOR := 0
MINOR := 16
PATCH := 1
LABEL :=
PATCH := 2
LABEL := -test2
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 @@ -53,15 +54,25 @@ control: Makefile control.in
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 \
fs: $(TOOLS_ROOTFS)

$(TOOLS_ROOTFS): $(TOOLS_DEB)
@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

fs-license:
@docker buildx build --load --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
-t $(TOOLS_ROOTFS_IMAGE) \
--file fs/Dockerfile \
.
TMPFILE=$(mktemp) && (cd fs/third-party/repo-info/; ./scan-local.sh $(TOOLS_ROOTFS_IMAGE) linux/riscv64) | tee $$TMPFILE && pandoc -s -f markdown -t html5 -o $(TOOLS_ROOTFS).html $$TMPFILE && rm -f $$TMPFILE

libcmt:
@mkdir $@

Expand All @@ -84,6 +95,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 Expand Up @@ -142,10 +154,11 @@ help:
@echo 'available commands:'
@echo ' deb - build machine-emulator-tools .deb package'
@echo ' fs - build rootfs.ext2'
@echo ' fs-and-license - build rootfs.ext2 and rootfs.ext2.md'
@echo ' setup - setup riscv64 buildx'
@echo ' setup-required - check if riscv64 buildx setup is required'
@echo ' help - list makefile commands'
@echo ' env - print useful Makefile variables as a KEY=VALUE list'
@echo ' clean - remove the generated artifacts'

.PHONY: build fs deb build-libcmt env setup setup-required help distclean
.PHONY: build fs fs-license deb build-libcmt env setup setup-required help distclean
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=linux/riscv64 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.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 \
/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.19 \
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 36907f5

Please sign in to comment.