Skip to content

Commit

Permalink
feat: release libcmt as a debian package
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Apr 9, 2024
1 parent 2a24e72 commit 8ed1479
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ jobs:
- name: Build rootfs
run: make fs

- name: Upload [${{ env.LIBCMT_DEB }}]
uses: actions/upload-artifact@v3
with:
path: ${{ env.LIBCMT_DEB }}

- name: Upload [${{ env.TOOLS_DEB }}]
uses: actions/upload-artifact@v3
with:
Expand All @@ -88,6 +93,7 @@ jobs:
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
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -98,6 +104,8 @@ jobs:
${{ env.TOOLS_DEB }}.sha512
${{ env.TOOLS_ROOTFS }}
${{ env.TOOLS_ROOTFS }}.sha512
${{ env.TOOLS_LIBCMT }}
${{ env.TOOLS_LIBCMT }}.sha512
test:
runs-on: ubuntu-latest-8-cores
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) install TARGET_PREF
USER developer
RUN make -C ${BUILD_BASE}/tools/sys-utils/ -j$(nproc) all

# build libcmt debian package
# ------------------------------------------------------------------------------
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 \
TARGET_PREFIX=/usr/riscv64-linux-gnu \
LIBCMT_DEB_FILENAME=${BUILD_BASE}/${TOOLS_LIBCMT}

# build rust tools
# ------------------------------------------------------------------------------
FROM c-builder as rust-env
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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).deb

IMAGE_KERNEL_VERSION ?= v0.20.0-output-unification-test1
LINUX_VERSION ?= 6.5.13-ctsi-1-output-unification-test1
Expand Down Expand Up @@ -51,7 +52,6 @@ $(TOOLS_DEB) deb: build
control: Makefile control.template
@sed 's|ARG_VERSION|$(VERSION)|g' control.template > control


$(TOOLS_ROOTFS) fs: $(TOOLS_DEB)
@docker buildx build --platform=linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
Expand All @@ -62,10 +62,22 @@ $(TOOLS_ROOTFS) fs: $(TOOLS_DEB)
xgenext2fs -fzB 4096 -b 25600 -i 4096 -a rootfs.gnutar -L rootfs $(TOOLS_ROOTFS) && \
rm -f rootfs.gnutar rootfs.tar

$(TOOLS_LIBCMT) libcmt:
@docker buildx build --load \
--target libcmt-debian-packager \
--build-arg TOOLS_LIBCMT=$(TOOLS_LIBCMT) \
-t $(TOOLS_IMAGE)-libcmt \
-f Dockerfile \
.
@ID=`docker create $(TOOLS_IMAGE)-libcmt` && \
docker cp $$ID:/opt/cartesi/$(TOOLS_LIBCMT) . && \
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)
Expand Down
1 change: 1 addition & 0 deletions sys-utils/libcmt/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
compile_flags.txt
*/*.clang-tidy*
11 changes: 10 additions & 1 deletion sys-utils/libcmt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

LIBCMT_VERSION ?=0.0.0

INSTALL_FILE= install -m0644
INSTALL_EXEC= install -m0755

# paths
PREFIX = /usr
TARGET_PREFIX ?= $(PREFIX)
Expand Down Expand Up @@ -78,6 +83,11 @@ install: $(libcmt_LIB)
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
dpkg-deb -Zxz --root-owner-group --build $(TARGET_DESTDIR) $(LIBCMT_DEB_FILENAME)

#-------------------------------------------------------------------------------
mock_SRC := \
src/abi.c \
Expand All @@ -104,7 +114,6 @@ mock: $(mock_LIB)
install-mock: $(mock_LIB)
mkdir -p $(DESTDIR)$(PREFIX)/lib
cp -f $< $(DESTDIR)$(PREFIX)/lib
mkdir -p $(DESTDIR)$(PREFIX)/include/libcmt/mock
cp -f src/*.h $(DESTDIR)$(PREFIX)/include/libcmt/
mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
sed -e 's|@ARG_PREFIX@|$(PREFIX)|g' src/libcmt_mock.pc > $(DESTDIR)$(PREFIX)/lib/pkgconfig/libcmt.pc
Expand Down
8 changes: 8 additions & 0 deletions sys-utils/libcmt/tools/template/cross-control.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Package: libcmt-dev-riscv64-cross
Version: ARG_VERSION
Architecture: all
Priority: optional
Section: devel
Maintainer: Machine Reference Unit <https://discord.com/channels/600597137524391947/1107965671976992878>
Provides: libcmt-dev-riscv64-cross
Description: Libcmt Library and Headers

0 comments on commit 8ed1479

Please sign in to comment.