2019-02-12 12:03:25 +01:00
|
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
|
# GNU GPL OS/K #
|
|
|
|
|
# #
|
|
|
|
|
# Desc: Grub installation script for the OS/K image #
|
|
|
|
|
# #
|
|
|
|
|
# #
|
|
|
|
|
# Copyright © 2018-2019 The OS/K Team #
|
|
|
|
|
# #
|
|
|
|
|
# This file is part of OS/K. #
|
|
|
|
|
# #
|
|
|
|
|
# OS/K is free software: you can redistribute it and/or modify #
|
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
|
|
|
# any later version. #
|
|
|
|
|
# #
|
|
|
|
|
# OS/K is distributed in the hope that it will be useful, #
|
|
|
|
|
# but WITHOUT ANY WARRANTY# without even the implied warranty of #
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
|
# #
|
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
|
# along with OS/K. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
|
|
2019-02-15 15:47:56 +01:00
|
|
|
|
#Color codes
|
|
|
|
|
CL='\033[0;32m'
|
|
|
|
|
CL2='\033[1;36m'
|
|
|
|
|
CL3='\033[0m'
|
|
|
|
|
NC='\033[1;37m'
|
|
|
|
|
|
|
|
|
|
set -e #exit if error
|
|
|
|
|
|
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Mouting image... \(losetup\)${CL3}
|
2019-02-12 12:03:25 +01:00
|
|
|
|
## Prepare Mount
|
2019-02-15 15:47:56 +01:00
|
|
|
|
sudo losetup -D > /dev/null
|
|
|
|
|
sudo losetup /dev/loop0 $1 > /dev/null # mounting the device block
|
|
|
|
|
sudo losetup /dev/loop1 $1 -o 1048576 > /dev/null #mounting the logical partition
|
2019-02-12 12:03:25 +01:00
|
|
|
|
|
2019-02-15 15:47:56 +01:00
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Mounting volume... \(mount\)${CL3}
|
2019-02-12 12:03:25 +01:00
|
|
|
|
## Mount
|
2019-03-11 19:22:37 +01:00
|
|
|
|
if [ -e $2/boot ]
|
|
|
|
|
then
|
|
|
|
|
sudo umount $2 > /dev/null
|
|
|
|
|
fi
|
2019-02-15 15:47:56 +01:00
|
|
|
|
sudo mount /dev/loop1 $2 > /dev/null
|
|
|
|
|
|
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3}
|
2019-02-12 12:03:25 +01:00
|
|
|
|
## Install grub
|
2019-02-15 15:47:56 +01:00
|
|
|
|
sudo grub-install -V
|
2019-04-01 11:40:58 +02:00
|
|
|
|
sudo grub-install --target=i386-pc --debug --root-directory=$2 --boot-directory=$2/boot --no-floppy --modules="part_msdos biosdisk fat multiboot configfile" /dev/loop0 2> build/grub.log
|
2019-02-15 15:47:56 +01:00
|
|
|
|
|
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Copying grub.cfg
|
|
|
|
|
sudo cp $3 $2/boot/grub/grub.cfg > /dev/null
|
|
|
|
|
|
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Sync image... \(sync\)${CL3}
|
2019-02-12 12:03:25 +01:00
|
|
|
|
sync
|
|
|
|
|
|
2019-02-15 15:47:56 +01:00
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Unmounting volume... \(umount\)${CL3}
|
|
|
|
|
sudo umount /dev/loop1 > /dev/null
|
|
|
|
|
|
|
|
|
|
echo ${CL2}[grub-install.sh]${NC} Unmounting image... \(losetup\)${CL3}
|
|
|
|
|
sudo losetup -D > /dev/null
|
2019-02-12 12:03:25 +01:00
|
|
|
|
|
2019-03-16 22:33:09 +01:00
|
|
|
|
echo ${CL2}[grub-install.sh]${CL} See grub.log for more informations.${CL3}
|