From 3b19b6c5c09bb09120bafdb2c0825b7213ed7791 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Wed, 29 May 2024 10:39:38 -0300 Subject: [PATCH] feat!: Add run and dev libcmt packages --- .github/workflows/main.yml | 16 +++---- Dockerfile | 43 ++++++++++++++++--- Makefile | 17 +++----- sys-utils/libcmt/Makefile | 27 +++++++++--- sys-utils/libcmt/src/libcmt.pc | 2 +- sys-utils/libcmt/src/libcmt_mock.pc | 10 ----- sys-utils/libcmt/tools/control.in | 8 ++++ .../tools/template/cross-control.template | 8 ---- 8 files changed, 80 insertions(+), 51 deletions(-) delete mode 100644 sys-utils/libcmt/src/libcmt_mock.pc create mode 100644 sys-utils/libcmt/tools/control.in delete mode 100644 sys-utils/libcmt/tools/template/cross-control.template diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1df86d33..f02c2bbe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,7 +76,7 @@ jobs: - name: Build rootfs run: make fs - - name: Build [${{ env.TOOLS_LIBCMT }}] + - name: Build libcmt id: docker_build_libcmt uses: docker/build-push-action@v5 with: @@ -86,13 +86,11 @@ jobs: push: false load: true target: libcmt-debian-packager - build-args: | - TOOLS_LIBCMT=${{ env.TOOLS_LIBCMT }} cache-from: type=gha,scope=regular,mode=max cache-to: type=gha,scope=regular - - name: Retrieve artifacts - run: make copy-libcmt + - name: Retrieve libcmt debian files + run: make copy-libcmt-deb DESTDIR=libcmt-deb - name: Upload artifacts uses: actions/upload-artifact@v4 @@ -101,14 +99,14 @@ jobs: path: | ${{ env.TOOLS_DEB }} ${{ env.TOOLS_ROOTFS }} - ${{ env.TOOLS_LIBCMT }} + libcmt-deb/* - name: Checksum artifacts if: startsWith(github.ref, 'refs/tags/v') run: | sha512sum ${{ env.TOOLS_DEB }} > ${{ env.TOOLS_DEB }}.sha512 sha512sum ${{ env.TOOLS_ROOTFS }} > ${{ env.TOOLS_ROOTFS }}.sha512 - sha512sum ${{ env.TOOLS_LIBCMT }} > ${{ env.TOOLS_LIBCMT }}.sha512 + sha512sum libcmt-deb/* > libcmt-deb.sha512 - uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') @@ -119,8 +117,8 @@ jobs: ${{ env.TOOLS_DEB }}.sha512 ${{ env.TOOLS_ROOTFS }} ${{ env.TOOLS_ROOTFS }}.sha512 - ${{ env.TOOLS_LIBCMT }} - ${{ env.TOOLS_LIBCMT }}.sha512 + libcmt-deb/* + libcmt-deb.sha512 test: runs-on: ubuntu-latest-8-cores diff --git a/Dockerfile b/Dockerfile index 0bf25de0..edc2e30a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,20 +76,51 @@ ARG BUILD_BASE=/opt/cartesi USER developer RUN make -C ${CMT_BASE} -j$(nproc) libcmt USER root -RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) install TARGET_PREFIX=/usr/riscv64-linux-gnu +RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) install-dev TARGET_PREFIX=/usr/riscv64-linux-gnu USER developer RUN make -C ${BUILD_BASE}/tools/sys-utils/ -j$(nproc) all -# build libcmt debian package +# build libcmt and libcmt-dev debian packages # ------------------------------------------------------------------------------ FROM c-builder as libcmt-debian-packager ARG CMT_BASE=${BUILD_BASE}/tools/sys-utils/libcmt -ARG TOOLS_LIBCMT=libcmt.deb USER root -RUN make -C ${CMT_BASE} debian-package \ - TARGET_DESTDIR=${BUILD_BASE}/_install \ + +# cross,dev +RUN make -C ${CMT_BASE} install-dev debian-package \ + TARGET_DESTDIR=${BUILD_BASE}/_install/cross.dev \ TARGET_PREFIX=/usr/riscv64-linux-gnu \ - LIBCMT_DEB_FILENAME=${BUILD_BASE}/${TOOLS_LIBCMT} + LIBCMT_DEB_FILENAME=${BUILD_BASE}/libcmt/deb/libcmt-dev-riscv64-cross.deb \ + ARG_PACKAGE=libcmt-dev-riscv64-cross \ + ARG_VERSION=0.1.0 \ + ARG_ARCHITECTURE=all \ + ARG_SECTION=devel \ + ARG_PROVIDES=libcmt-dev-riscv64-cross \ + ARG_DESCRIPTION="Libcmt cross development headers and libraries" + +# native,dev +RUN make -C ${CMT_BASE} install-dev debian-package \ + TARGET_DESTDIR=${BUILD_BASE}/_install/native.dev \ + TARGET_PREFIX=/usr \ + LIBCMT_DEB_FILENAME=${BUILD_BASE}/libcmt/deb/libcmt-dev.deb \ + ARG_PACKAGE=libcmt-dev \ + ARG_VERSION=0.1.0 \ + ARG_ARCHITECTURE=riscv64 \ + ARG_SECTION=devel \ + ARG_PROVIDES=libcmt-dev \ + ARG_DESCRIPTION="Libcmt development headers and libraries" + +# native,run +RUN make -C ${CMT_BASE} install-dev debian-package \ + TARGET_DESTDIR=${BUILD_BASE}/_install/native.run \ + TARGET_PREFIX=/usr \ + LIBCMT_DEB_FILENAME=${BUILD_BASE}/libcmt/deb/libcmt.deb \ + ARG_PACKAGE=libcmt \ + ARG_VERSION=0.1.0 \ + ARG_ARCHITECTURE=riscv64 \ + ARG_SECTION=libs \ + ARG_PROVIDES=libcmt \ + ARG_DESCRIPTION="Libcmt runtime libraries" # build rust tools # ------------------------------------------------------------------------------ diff --git a/Makefile b/Makefile index 50645b0d..0b481284 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,9 @@ PATCH := 0 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_LIBCMT := libcmt-v$(VERSION)-dev.deb +TOOLS_DEB := machine-emulator-tools-v$(VERSION).deb +TOOLS_IMAGE := cartesi/machine-emulator-tools:$(VERSION) +TOOLS_ROOTFS := rootfs-tools-v$(VERSION).ext2 IMAGE_KERNEL_VERSION ?= v0.20.0 LINUX_VERSION ?= 6.5.13-ctsi-1 @@ -63,25 +62,23 @@ $(TOOLS_ROOTFS) fs: $(TOOLS_DEB) xgenext2fs -fzB 4096 -b 25600 -i 4096 -a rootfs.tar -L rootfs $(TOOLS_ROOTFS) && \ rm -f rootfs.tar -$(TOOLS_LIBCMT) libcmt: +libcmt: @docker buildx build --load \ --target libcmt-debian-packager \ - --build-arg TOOLS_LIBCMT=$(TOOLS_LIBCMT) \ -t $(TOOLS_IMAGE)-libcmt \ -f Dockerfile \ . - $(MAKE) copy-libcmt + $(MAKE) copy-libcmt-deb -copy-libcmt: +copy-libcmt-deb: @ID=`docker create $(TOOLS_IMAGE)-libcmt` && \ - docker cp $$ID:/opt/cartesi/$(TOOLS_LIBCMT) . && \ + docker cp $$ID:/opt/cartesi/libcmt/deb $(DESTDIR) && \ docker rm $$ID env: @echo TOOLS_DEB=$(TOOLS_DEB) @echo TOOLS_ROOTFS=$(TOOLS_ROOTFS) @echo TOOLS_IMAGE=$(TOOLS_IMAGE) - @echo TOOLS_LIBCMT=$(TOOLS_LIBCMT) @echo IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION) @echo LINUX_VERSION=$(LINUX_VERSION) @echo LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH) diff --git a/sys-utils/libcmt/Makefile b/sys-utils/libcmt/Makefile index b45a9c95..028e705f 100644 --- a/sys-utils/libcmt/Makefile +++ b/sys-utils/libcmt/Makefile @@ -81,18 +81,31 @@ $(libcmt_SO): $(libcmt_OBJ) $(TARGET_CC) -shared -o $@ $^ libcmt: $(libcmt_LIB) $(libcmt_SO) -install: $(libcmt_LIB) $(libcmt_SO) build/ffi.h +install: $(libcmt_SO) mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib - cp -f $(libcmt_LIB) $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + cp -f $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + +install-dev: install $(libcmt_LIB) $(libcmt_SO) build/ffi.h + mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + cp -f $(libcmt_SO) $(libcmt_LIB) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ cp -f include/libcmt/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ cp -f build/ffi.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig - sed -e 's|@ARG_PREFIX@|$(TARGET_PREFIX)|g' src/libcmt.pc > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc - -debian-package: install - mkdir -p $(TARGET_DESTDIR)/DEBIAN - sed 's|ARG_VERSION|$(LIBCMT_VERSION)|g;' tools/template/cross-control.template > $(TARGET_DESTDIR)/DEBIAN/control + sed -e 's|@PREFIX@|$(TARGET_PREFIX)|g' \ + src/libcmt.pc > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc + +$(TARGET_DESTDIR)/DEBIAN/%: tools/control.in + mkdir -p $(@D) + sed -e 's|@PACKAGE@|$(ARG_PACKAGE)|' \ + -e 's|@VERSION@|$(ARG_VERSION)|' \ + -e 's|@ARCHITECTURE@|$(ARG_ARCHITECTURE)|' \ + -e 's|@PROVIDES@|$(ARG_PROVIDES)|' \ + -e 's|@DESCRIPTION@|$(ARG_DESCRIPTION)|' \ + $< > $@ + +debian-package: $(TARGET_DESTDIR)/DEBIAN/control + mkdir -p $(dir $(LIBCMT_DEB_FILENAME)) dpkg-deb -Zxz --root-owner-group --build $(TARGET_DESTDIR) $(LIBCMT_DEB_FILENAME) #------------------------------------------------------------------------------- diff --git a/sys-utils/libcmt/src/libcmt.pc b/sys-utils/libcmt/src/libcmt.pc index c1b4a7bc..a5fcbfb4 100644 --- a/sys-utils/libcmt/src/libcmt.pc +++ b/sys-utils/libcmt/src/libcmt.pc @@ -1,4 +1,4 @@ -prefix=@ARG_PREFIX@ +prefix=@PREFIX@ exec_prefix=${prefix} includedir=${prefix}/include libdir=${exec_prefix}/lib diff --git a/sys-utils/libcmt/src/libcmt_mock.pc b/sys-utils/libcmt/src/libcmt_mock.pc deleted file mode 100644 index c1b4a7bc..00000000 --- a/sys-utils/libcmt/src/libcmt_mock.pc +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@ARG_PREFIX@ -exec_prefix=${prefix} -includedir=${prefix}/include -libdir=${exec_prefix}/lib - -Name: libcmt -Description: The Cartesi Machine Tools library -Version: 0.0.1 -Cflags: -I${includedir} -Libs: -L${libdir} -lcmt diff --git a/sys-utils/libcmt/tools/control.in b/sys-utils/libcmt/tools/control.in new file mode 100644 index 00000000..9168b837 --- /dev/null +++ b/sys-utils/libcmt/tools/control.in @@ -0,0 +1,8 @@ +Package: @PACKAGE@ +Version: @VERSION@ +Architecture: @ARCHITECTURE@ +Priority: optional +Section: libs +Maintainer: Machine Reference Unit +Provides: @PROVIDES@ +Description: @DESCRIPTION@ diff --git a/sys-utils/libcmt/tools/template/cross-control.template b/sys-utils/libcmt/tools/template/cross-control.template deleted file mode 100644 index 25193a4f..00000000 --- a/sys-utils/libcmt/tools/template/cross-control.template +++ /dev/null @@ -1,8 +0,0 @@ -Package: libcmt-dev-riscv64-cross -Version: ARG_VERSION -Architecture: all -Priority: optional -Section: devel -Maintainer: Machine Reference Unit -Provides: libcmt-dev-riscv64-cross -Description: Libcmt Library and Headers