Skip to content

Commit

Permalink
refactor: remove debian packaging for tools
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Jan 15, 2025
1 parent 0e77c3b commit b24987f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 82 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@ jobs:
- name: Export makefile variables
run: make env >> $GITHUB_ENV

- name: Create debian package control file
run: make control

- 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

- name: Build [${{ env.TOOLS_DEB }}]
- name: Build [${{ env.TOOLS_TARGZ }}]
id: docker_build
uses: docker/build-push-action@v5
with:
Expand All @@ -65,7 +59,7 @@ jobs:
push: false
load: true
build-args: |
TOOLS_DEB=${{ env.TOOLS_DEB }}
TOOLS_TARGZ=${{ env.TOOLS_TARGZ }}
IMAGE_KERNEL_VERSION=${{ env.IMAGE_KERNEL_VERSION }}
LINUX_VERSION=${{ env.LINUX_VERSION }}
LINUX_HEADERS_URLPATH=${{ env.LINUX_HEADERS_URLPATH }}
Expand Down Expand Up @@ -96,13 +90,13 @@ jobs:
with:
if-no-files-found: error
path: |
${{ env.TOOLS_DEB }}
${{ env.TOOLS_TARGZ }}
${{ env.TOOLS_ROOTFS }}
- name: Checksum artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: |
sha512sum ${{ env.TOOLS_DEB }} > ${{ env.TOOLS_DEB }}.sha512
sha512sum ${{ env.TOOLS_TARGZ }} > ${{ env.TOOLS_TARGZ }}.sha512
sha512sum ${{ env.TOOLS_ROOTFS }} > ${{ env.TOOLS_ROOTFS }}.sha512
- uses: softprops/action-gh-release@v1
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
*.ext2
control
machine-emulator-tools-*.tar.gz
machine-emulator-tools-*.deb
rootfs.*
package.json
*.bin
Expand Down
20 changes: 6 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,15 @@ RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \
# pack tools (deb)
# ------------------------------------------------------------------------------
FROM tools-env AS packer
ARG TOOLS_DEB=machine-emulator-tools.deb
ARG TOOLS_TARGZ=machine-emulator-tools.tar.gz
ARG STAGING_BASE=${BUILD_BASE}/_install
ARG STAGING_DEBIAN=${STAGING_BASE}/DEBIAN
ARG STAGING_BIN=${STAGING_BASE}/usr/bin
ARG STAGING_SHARE=${STAGING_BASE}/usr/share/machine-emulator-tools

RUN mkdir -p ${STAGING_DEBIAN} ${STAGING_SBIN} ${STAGING_BIN} ${STAGING_BASE}/etc && \
RUN mkdir -p ${STAGING_BASE}/usr/bin ${STAGING_BASE}/usr/bin ${STAGING_BASE}/etc && \
echo "cartesi-machine" > ${staging_base}/etc/hostname

COPY control ${STAGING_DEBIAN}/control
COPY package.json ${STAGING_SHARE}/package.json
COPY postinst ${STAGING_DEBIAN}/postinst
COPY copyright ${STAGING_BASE}/usr/share/doc/machine-emulator-tools/copyright

COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils_staging ${STAGING_BASE}
COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_BIN}
COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN}
COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN}
COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_BASE}/usr/bin
COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BASE}/usr/bin
COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BASE}/usr/bin

RUN dpkg-deb -Zxz --root-owner-group --build ${STAGING_BASE} ${BUILD_BASE}/${TOOLS_DEB}
RUN cd ${STAGING_BASE} && tar -czf ${BUILD_BASE}/${TOOLS_TARGZ} *
29 changes: 12 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PATCH := 2
LABEL := -test2
VERSION := $(MAJOR).$(MINOR).$(PATCH)$(LABEL)

TOOLS_DEB := machine-emulator-tools-v$(VERSION).deb
TOOLS_TARGZ := machine-emulator-tools-v$(VERSION).tar.gz
TOOLS_IMAGE := cartesi/machine-emulator-tools:$(VERSION)
TOOLS_ROOTFS := rootfs-tools-v$(VERSION).ext2
TOOLS_ROOTFS_IMAGE := cartesi/rootfs-tools:$(VERSION)
Expand All @@ -31,9 +31,9 @@ LINUX_HEADERS_URLPATH := https://github.com/cartesi/image-kernel/releases/downlo

all: fs

build: control package.json
build:
@docker buildx build --load \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
--build-arg TOOLS_TARGZ=$(TOOLS_TARGZ) \
--build-arg IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION) \
--build-arg LINUX_VERSION=$(LINUX_VERSION) \
--build-arg LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH) \
Expand All @@ -44,21 +44,16 @@ build: control package.json

copy:
@ID=`docker create $(TOOLS_IMAGE)` && \
docker cp $$ID:/opt/cartesi/$(TOOLS_DEB) . && \
docker cp $$ID:/opt/cartesi/$(TOOLS_TARGZ) . && \
docker rm $$ID

$(TOOLS_DEB) deb: build

control: Makefile control.in
@sed 's|ARG_VERSION|$(VERSION)|g' control.in > control
package.json: Makefile package.json.in
@sed 's|ARG_VERSION|$(VERSION)|g' package.json.in > package.json
$(TOOLS_TARGZ) targz: build

fs: $(TOOLS_ROOTFS)

$(TOOLS_ROOTFS): $(TOOLS_DEB)
$(TOOLS_ROOTFS): $(TOOLS_TARGZ)
@docker buildx build --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
--build-arg TOOLS_TARGZ=$(TOOLS_TARGZ) \
--output type=tar,dest=rootfs.tar \
--file fs/Dockerfile \
. && \
Expand All @@ -67,15 +62,15 @@ $(TOOLS_ROOTFS): $(TOOLS_DEB)

fs-license:
@docker buildx build --load --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
--build-arg TOOLS_TARGZ=$(TOOLS_TARGZ) \
-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

env:
@echo VERSION=$(VERSION)
@echo TOOLS_DEB=$(TOOLS_DEB)
@echo TOOLS_TARGZ=$(TOOLS_TARGZ)
@echo TOOLS_ROOTFS=$(TOOLS_ROOTFS)
@echo TOOLS_IMAGE=$(TOOLS_IMAGE)
@echo TOOLS_ROOTFS_IMAGE=$(TOOLS_ROOTFS_IMAGE)
Expand Down Expand Up @@ -125,7 +120,7 @@ clean-image:
@(docker rmi $(TOOLS_IMAGE) > /dev/null 2>&1 || true)

clean:
@rm -f $(TOOLS_DEB) control rootfs*
@rm -f $(TOOLS_TARGZ) rootfs*
@$(MAKE) -C sys-utils clean

distclean: clean clean-image
Expand All @@ -135,7 +130,7 @@ sys-utils:

help:
@echo 'available commands:'
@echo ' deb - build machine-emulator-tools .deb package'
@echo ' targz - build machine-emulator-tools .tar.gz'
@echo ' fs - build rootfs.ext2'
@echo ' fs-license - build rootfs.ext2.html with licence information'
@echo ' setup - setup riscv64 buildx'
Expand All @@ -144,4 +139,4 @@ help:
@echo ' env - print useful Makefile variables as a KEY=VALUE list'
@echo ' clean - remove the generated artifacts'

.PHONY: build fs fs-license deb env setup setup-required help distclean
.PHONY: build fs fs-license targz env setup setup-required help distclean
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $ make setup

### Building

Invoking make will build all tools and create the `machine-emulator-tools-$VERSION.deb` Debian package along with the `rootfs-tools-$VERSION.ext2` root filesystem artifacts.
Invoking make will build all tools and create the `machine-emulator-tools-$VERSION.tar.gz` archive along with the `rootfs-tools-$VERSION.ext2` root filesystem artifacts.

```bash
$ make
Expand All @@ -33,7 +33,7 @@ $ make
The following commands are available as `make` targets:

- **all**: Build Debian package and rootfs (Default)
- **deb**: Build machine-emulator-tools.deb package
- **targz**: Build machine-emulator-tools.tar.gz
- **fs**: Build rootfs.ext2
- **setup**: Setup riscv64 buildx
- **setup-required**: Check if riscv64 buildx setup is required
Expand Down
10 changes: 0 additions & 10 deletions control.in

This file was deleted.

23 changes: 0 additions & 23 deletions copyright

This file was deleted.

7 changes: 3 additions & 4 deletions fs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Final image
FROM --platform=linux/riscv64 ubuntu:24.04
ARG TOOLS_DEB=machine-emulator-tools-v0.16.2.deb
ADD ${TOOLS_DEB} /tmp/
ARG TOOLS_TARGZ=machine-emulator-tools.tar.gz
ADD ${TOOLS_TARGZ} /
RUN apt-get update && \
apt-get upgrade -y --no-install-recommends && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
Expand All @@ -19,6 +19,5 @@ RUN apt-get update && \
file \
stress-ng \
libatomic1 \
/tmp/${TOOLS_DEB} \
&& \
rm -rf /var/lib/apt/lists/* /tmp/${TOOLS_DEB}
rm -rf /var/lib/apt/lists/*

0 comments on commit b24987f

Please sign in to comment.