From 948ae7fdf55cd1eb8007f0b0868240ff46257d40 Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 28 Mar 2019 20:09:20 +0300 Subject: [PATCH] builder: fix repo cloning to image --- builder/image-build.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/builder/image-build.sh b/builder/image-build.sh index f3c0f72e..f4af963b 100755 --- a/builder/image-build.sh +++ b/builder/image-build.sh @@ -73,13 +73,26 @@ img-resize ${IMAGE_PATH} max '5G' # Copy cloned repository to the image # Include dotfiles in globs (asterisks) shopt -s dotglob + +echo_stamp "Mount loop-image: ${IMAGE_PATH}" +DEV_IMAGE=$(losetup -Pf ${IMAGE_PATH} --show) +sleep 0.5 + +MOUNT_POINT=$(mktemp -d --suffix=.builder_image) +echo_stamp "Mount dirs ${MOUNT_POINT} & ${MOUNT_POINT}/boot" +mount "${DEV_IMAGE}p2" ${MOUNT_POINT} +mount "${DEV_IMAGE}p1" ${MOUNT_POINT}/boot + +mkdir -p ${MOUNT_POINT}'/home/pi/CleverSwarm/' for dir in ${REPO_DIR}/*; do - # Don't try to copy image into itself if [[ $dir != *"images" && $dir != *"imgcache" ]]; then - img-chroot ${IMAGE_PATH} copy $dir '/home/pi/CleverSwarm/' + cp -r $dir ${MOUNT_POINT}'/home/pi/CleverSwarm/'$(basename $dir) fi; done +umount -fR ${MOUNT_POINT} +losetup -d ${DEV_IMAGE} + # Install software img-chroot ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-software.sh'