From 6c9a9045881ef8078172738f1cf24a54619794a3 Mon Sep 17 00:00:00 2001 From: Carsten Munk Date: Thu, 25 Apr 2024 10:51:30 +0000 Subject: [PATCH] More 0.17 stuff Signed-off-by: Carsten Munk --- Dockerfile | 2 +- install-pkgs | 77 ++++++++++++++------------------------------------ install-pkgs-2 | 6 ++-- 3 files changed, 25 insertions(+), 60 deletions(-) diff --git a/Dockerfile b/Dockerfile index a8c37ec..bb1f34c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -130,7 +130,7 @@ RUN cartesi-machine --ram-image=./artifacts/linux.bin --skip-root-hash-check --a COPY --from=aptget-setup /tool-image2.img /tool-image2.img RUN truncate -s 800M /clean-image.ext2 && cartesi-machine --skip-root-hash-check --append-bootargs="loglevel=8 init=/sbin/install-from-mtdblock1" --flash-drive=label:root,filename:/image.ext2 --flash-drive=label:out,filename:/tool-image2.img --flash-drive=label:clean,filename:/clean-image.ext2,shared --ram-length=2Gi && rm -rf /tool-image.img && rm -rf /tool-image2.img && rm -rf /image.ext2 -RUN cartesi-machine --skip-root-hash-check --append-bootargs="no4lvl loglevel=8 init=/opt/cartesi/bin/preinit systemd.unified_cgroup_hierarchy=0 rootfstype=ext4 ro CARTESI_TMPFS_SIZE=1G systemd.journald.forward_to_console=1" \ +RUN cartesi-machine --skip-root-hash-check --append-bootargs="no4lvl loglevel=8 init=/usr/sbin/cartesi-preinit systemd.unified_cgroup_hierarchy=0 rootfstype=ext4 ro CARTESI_TMPFS_SIZE=1G systemd.journald.forward_to_console=1" \ --ram-image=./artifacts/linux.bin --flash-drive="label:root,filename:/clean-image.ext2" --flash-drive="label:app,length:10Mi" --ram-length=2Gi --store=/lambada-base-machine-presparse \ --max-mcycle=0 && \ cp -v --sparse=always -r /lambada-base-machine-presparse /lambada-base-machine && rm -rf /lambada-base-machine-presparse && \ diff --git a/install-pkgs b/install-pkgs index a78bbb5..7f22f9d 100644 --- a/install-pkgs +++ b/install-pkgs @@ -4,11 +4,8 @@ export PATH export DEBIAN_FRONTEND="noninteractive" dpkg -i /mnt/machine-emulator-tools-v0.15.0.deb date -s '2023-12-02 00:00:00' -/opt/cartesi/bin/rndaddentropy < /opt/cartesi/bin/rndaddentropy -mkdir -p /opt/cartesi/bin/ -cat > /opt/cartesi/bin/preinit << EOF +cat > /usr/sbin/lambada-preinit << EOF #!/bin/sh -/opt/cartesi/bin/rndaddentropy < /opt/cartesi/var/run/random-seed if [ x\$CARTESI_SCRATCH != x ]; then mkfs.ext4 -F -F -O ^has_journal \$CARTESI_SCRATCH /usr/bin/mount \$CARTESI_SCRATCH /ram @@ -34,61 +31,29 @@ exec /sbin/init EOF # /tmpfs for RWA demo backwards compatiblity mkdir -p /ram /opt /tmpfs -mkdir -p /opt/cartesi/dapp -chmod +x /opt/cartesi/bin/preinit -cat > /opt/cartesi/bin/run-app.sh << EOF -#!/bin/bash -export IPFS_PATH=/root/.ipfs -export HTTP_DATASTORE_URL=http://127.0.0.1:5004/ipfs -export IO_DEVICE=/dev/pmem1 -mkdir -p /opt/rollup-store -mkdir -p /opt/rollup-cache -/usr/bin/ipfs init /etc/ipfs-config -/usr/bin/ipfs daemon --offline & -echo "Waiting for IPFS" -IPFS_HOST="127.0.0.1" -IPFS_PORT="5001" +chmod +x /usr/sbin/lambada-preinit -while true; do - nc -z "\$IPFS_HOST" "\$IPFS_PORT" - RET=\$? - echo \$RET - if [ x\$RET = x0 ]; then - break - fi - sleep 1 -done -echo "IPFS up" -echo "Asking for app to guest tools which would set CID of /app" -curl http://127.0.0.1:5004/get_app > /dev/null -ipfs files read /app/boot-script > /tmp/boot-script -chmod +x /tmp/boot-script -cat /tmp/boot-script -/tmp/boot-script -EOF -chmod +x /opt/cartesi/bin/run-app.sh -cat > /opt/cartesi/bin/yield-and-install << EOF + +cat > /usr/bin/yield-and-install << EOF #!/bin/bash - if [ ! -e /dev/cmio ]; then - echo "No /dev/cmio" - mkdir -p /tmp/instructions - mount -t 9p -o trans=virtio instructions /tmp/instructions -oversion=9p2000.L - /tmp/instructions/boot-script - exit 0 - fi - mkdir -p /opt/rollup-cache - mkdir -p /opt/rollup-store - export IO_DEVICE=/dev/pmem1 - /opt/cartesi/bin/rollup-init /opt/cartesi/bin/run-app.sh + if [ ! -e /dev/cmio ]; then + echo "No /dev/cmio" + mkdir -p /tmp/instructions + mount -t 9p -o trans=virtio instructions /tmp/instructions -oversion=9p2000.L + /tmp/instructions/boot-script + exit 0 + fi + mkdir -p /opt/rollup-cache + mkdir -p /opt/rollup-store + export IO_DEVICE=/dev/pmem1 + /usr/bin/rollup-init /usr/bin/lambada-rollup-server /usr/bin/cartesi-run-app.sh - echo "entrypoint exited with \$? status" - dmesg - halt -f - exit 0 + echo "entrypoint exited with \$? status" + dmesg + halt -f + exit 0 EOF - -chmod +x /opt/cartesi/bin/yield-and-install - +chmod +x /usr/bin/yield-and-install cat > /etc/systemd/system/yield-and-install.service << EOF [Unit] Description=First yield @@ -96,7 +61,7 @@ After=network.target [Service] Type=oneshot -ExecStart=/opt/cartesi/bin/yield-and-install +ExecStart=/usr/bin/yield-and-install RemainAfterExit=yes [Install] WantedBy=multi-user.target diff --git a/install-pkgs-2 b/install-pkgs-2 index d936d4d..1506a09 100644 --- a/install-pkgs-2 +++ b/install-pkgs-2 @@ -33,8 +33,8 @@ systemctl enable systemd-networkd.service echo -n "Enabled.." -mkdir -p /opt/cartesi/bin/ -cat > /opt/cartesi/bin/run-app.sh << EOF +mkdir -p /usr/bin/ +cat > /usr/bin/cartesi-run-app.sh << EOF #!/bin/bash export IPFS_PATH=/root/.ipfs export HTTP_DATASTORE_URL=http://127.0.0.1:5004/ipfs @@ -64,7 +64,7 @@ chmod +x /tmp/boot-script cat /tmp/boot-script /tmp/boot-script EOF -chmod +x /opt/cartesi/bin/run-app.sh +chmod +x /usr/bin/cartesi-run-app.sh find /usr/share/doc -depth -type f ! -name copyright|xargs rm || true find /usr/share/doc -empty|xargs rmdir || true