Skip to content

Commit

Permalink
More 0.17 stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Carsten Munk <[email protected]>
  • Loading branch information
stskeeps committed Apr 25, 2024
1 parent c8c2f33 commit 6c9a904
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
77 changes: 21 additions & 56 deletions install-pkgs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,69 +31,37 @@ 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
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
Expand Down
6 changes: 3 additions & 3 deletions install-pkgs-2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6c9a904

Please sign in to comment.