Bug with makefile that can erase host MBR

This commit is contained in:
Adrien Bourmault 2020-02-05 22:23:58 +01:00
parent 0af726ba09
commit 04fbcf9a02
3 changed files with 12 additions and 18 deletions

View File

@ -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}

View File

@ -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

View File

@ -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