Skip to content

Commit

Permalink
Compress on-the-fly
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Feb 8, 2024
1 parent 1f3c33f commit d448789
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ rm -rf ${FILES_TO_DELETE}
mkdir /home
mkdir /var
mkdir /frzr_root
mkdir /nix
EOF

# copy files into chroot again
Expand All @@ -264,8 +263,15 @@ fi
echo "Free space"
df -h

IMG_FILENAME="${SYSTEM_NAME}-${VERSION}.img.xz"

btrfs subvolume snapshot -r ${BUILD_PATH} ${SNAP_PATH}
btrfs send -f ${SYSTEM_NAME}-${VERSION}.img ${SNAP_PATH}

if [ -z "${NO_COMPRESS}" ]; then
btrfs send ${SNAP_PATH} | xz -9 -T0 > ${IMG_FILENAME}
else
btrfs send -f ${SYSTEM_NAME}-${VERSION}.img ${SNAP_PATH}
fi

cp ${BUILD_PATH}/build_info build_info.txt

Expand All @@ -275,13 +281,8 @@ umount -l ${MOUNT_PATH}
rm -rf ${MOUNT_PATH}
rm -rf ${BUILD_IMG}

IMG_FILENAME="${SYSTEM_NAME}-${VERSION}.img.tar.xz"
if [ -z "${NO_COMPRESS}" ]; then
proc=$(cat /proc/cpuinfo | grep processor | wc -l)
tar -c -I"xz -9 -T${proc}" -f ${IMG_FILENAME} ${SYSTEM_NAME}-${VERSION}.img
rm ${SYSTEM_NAME}-${VERSION}.img

sha256sum ${SYSTEM_NAME}-${VERSION}.img.tar.xz > sha256sum.txt
sha256sum ${IMG_FILENAME} > sha256sum.txt
cat sha256sum.txt

# Move the image to the output directory, if one was specified.
Expand Down

0 comments on commit d448789

Please sign in to comment.