Bug with makefile that can erase host MBR

This commit is contained in:
Adrien Bourmault 2020-02-05 22:03:23 +01:00
parent 02e7b7ea77
commit 0af726ba09
1 changed files with 21 additions and 3 deletions

View File

@ -30,15 +30,33 @@ NC='\033[1;37m'
set -e #exit if error set -e #exit if error
echo ${CL2}[install-os-k.sh]${NC} Mount image... \(udisksctl\)${CL3} ## Mount
udisksctl loop-setup --offset 1048576 --no-user-interaction --file $1 echo ${CL2}[install-os-k.sh]${NC} Mount image... \(losetup\)${CL3}
lpblock=$(/sbin/losetup -j $1 | cut -d ':' -f 1) lpblock=$(sudo losetup -f)
sudo losetup $lpblock $1 -o 1048576
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} echo ${CL2}[install-os-k.sh]${NC} Sync image... \(sync\)${CL3}
sync sync
# Get the mountpoint
mountpoint=$(udisksctl info -b $lpblock | grep MountPoint | cut -d ':' -f 2 | sed 's/ //g') 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 !
return 13
fi
echo ${CL2}[install-os-k.sh]${NC} Copying grub.cfg echo ${CL2}[install-os-k.sh]${NC} Copying grub.cfg
cp $2 $mountpoint/boot/grub/grub.cfg cp $2 $mountpoint/boot/grub/grub.cfg
echo ${CL2}[install-os-k.sh]${NC} Copying kernel echo ${CL2}[install-os-k.sh]${NC} Copying kernel