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'