From 04fbcf9a02457e545dd544cc33b67f53b9c95be4 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 5 Feb 2020 22:23:58 +0100 Subject: [PATCH] Bug with makefile that can erase host MBR --- Makefile | 2 +- build/create_disk.sh | 2 +- build/install-os-k.sh | 26 ++++++++++---------------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 8d307c9..6a19b98 100644 --- a/Makefile +++ b/Makefile @@ -328,7 +328,7 @@ dddnokvm: all installonimage ## HD IMAGE RELATED ---------------------------------------------------------- # installonimage: $(installdisk) $(MBRDIR)/grub.cfg - @echo ${CL2}[$@] ${NC}Installing MBR on image...${CL3} + @echo ${CL2}[$@] ${NC}Installing boot configuration on image...${CL3} @$(BUILDDIR)/install-os-k.sh $(installdisk) $(MBRDIR)/grub.cfg $(BINDIR)/kaleid @echo ${CL2}[$@] ${CL}Success.${CL3} diff --git a/build/create_disk.sh b/build/create_disk.sh index 018b406..91f499c 100755 --- a/build/create_disk.sh +++ b/build/create_disk.sh @@ -76,7 +76,7 @@ fi if [ -z $lpblock ]; then - echo No loop device partition to target. Fatal error ! + Impossible to find an available loop device. Fatal error ! return 13 fi diff --git a/build/install-os-k.sh b/build/install-os-k.sh index 3c08f2a..e96a211 100755 --- a/build/install-os-k.sh +++ b/build/install-os-k.sh @@ -30,33 +30,27 @@ NC='\033[1;37m' set -e #exit if error -## Mount -echo ${CL2}[install-os-k.sh]${NC} Mount image... \(losetup\)${CL3} -lpblock=$(sudo losetup -f) -sudo losetup $lpblock $1 -o 1048576 +echo ${CL2}[install-os-k.sh]${NC} Mount image... \(udisksctl\)${CL3} +udisksctl loop-setup --offset 1048576 --no-user-interaction --file $1 +lpblock=$(/sbin/losetup -j $1 | cut -d ':' -f 1) -if [ -z $lpblock ]; -then - echo No loop device partition to target. Fatal error ! - return 13 -fi - -sudo udisksctl mount -b $lpblock --no-user-interaction - -## Sync echo ${CL2}[install-os-k.sh]${NC} Sync image... \(sync\)${CL3} sync -# Get the mountpoint +if [ -z $lpblock ]; +then + echo Impossible to find an available loop device. Fatal error ! + return 13 +fi + mountpoint=$(udisksctl info -b $lpblock | grep MountPoint | cut -d ':' -f 2 | sed 's/ //g') if [ -z $mountpoint ]; then - echo Impossible to mount the image $mountpoint. Fatal error ! + echo Impossible to mount the image at $lpblock. Fatal error ! return 13 fi - echo ${CL2}[install-os-k.sh]${NC} Copying grub.cfg cp $2 $mountpoint/boot/grub/grub.cfg echo ${CL2}[install-os-k.sh]${NC} Copying kernel