Skip to content

Commit

Permalink
image creation cleanup (commaai#317)
Browse files Browse the repository at this point in the history
* cleaning

* remove resize2fs shrinking

* [upload]

* updated ROOTFS_IMAGE_SIZE comment about resize2fs -M
  • Loading branch information
andiradulescu authored Aug 19, 2024
1 parent bdb9394 commit 37a76e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ RUN apt-get update && \
ccache \
libcap2-bin \
android-sdk-libsparse-utils \
e2fsprogs \
&& rm -rf /var/lib/apt/lists/*

RUN if [ ${UID:-0} -ne 0 ] && [ ${GID:-0} -ne 0 ]; then \
Expand Down
20 changes: 8 additions & 12 deletions build_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ OUTPUT_DIR="$DIR/output"

ROOTFS_DIR="$BUILD_DIR/agnos-rootfs"
ROOTFS_IMAGE="$BUILD_DIR/system.img"
SKIP_CHUNKS_IMAGE="$OUTPUT_DIR/system-skip-chunks.img"
OUT_IMAGE="$OUTPUT_DIR/system.img"
OUT_SKIP_CHUNKS_IMAGE="$OUTPUT_DIR/system-skip-chunks.img"

# the partition is 10G, but openpilot's updater didn't always handle the full size
# - the size will also get shrunk with "resize2fs -M"
# - openpilot fix, shipped in 0.9.8 (8/18/24): https://github.com/commaai/openpilot/pull/33320
# openpilot fix, shipped in 0.9.8 (8/18/24): https://github.com/commaai/openpilot/pull/33320
ROOTFS_IMAGE_SIZE=5G

# Create temp dir if non-existent
Expand Down Expand Up @@ -132,20 +132,16 @@ exec_as_root bash -c "set -e; export ROOTFS_DIR=$ROOTFS_DIR GIT_HASH=$GIT_HASH;
echo "Unmount filesystem"
exec_as_root umount -l $ROOTFS_DIR

# Make image with skipped chunks
echo "Sparsify image $(basename $SKIP_CHUNKS_IMAGE)"
# Make system image with skipped chunks
echo "Sparsifying image $(basename $OUT_SKIP_CHUNKS_IMAGE)"
exec_as_user bash -c "\
TMP_SPARSE=\$(mktemp); \
img2simg $ROOTFS_IMAGE \$TMP_SPARSE; \
TMP_SKIP=\$(mktemp); \
$DIR/tools/simg2dontcare.py $TMP_SPARSE \$TMP_SKIP; \
mv \$TMP_SKIP $SKIP_CHUNKS_IMAGE"

# Reduce system image to the minimum size
exec_as_user e2fsck -fy $ROOTFS_IMAGE
exec_as_user resize2fs -M $ROOTFS_IMAGE
$DIR/tools/simg2dontcare.py \$TMP_SPARSE \$TMP_SKIP; \
mv \$TMP_SKIP $OUT_SKIP_CHUNKS_IMAGE"

# Copy system image to output
cp $ROOTFS_IMAGE $OUTPUT_DIR
cp $ROOTFS_IMAGE $OUT_IMAGE

echo "Done!"

0 comments on commit 37a76e0

Please sign in to comment.