libdevuansdk/zlibs/grub

55 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <parazyd@dyne.org>
#
# This file is part of libdevuansdk
#
# This source code 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
# (at your option) any later version.
#
# This software 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 this source code. If not, see <http://www.gnu.org/licenses/>.
grub_install_target_dev() {
fn grub_install_target_dev $@
root=$1
install_dev=$2
req=(root install_dev)
freq=($root/.done)
ckreq || return 1
# TODO: should we use qemu-chroot here for $arch = arm (parazyd?)
sudo chroot ${root} apt-get install --assume-yes --no-install-recommends grub-common
if [[ ! -d ${root}/boot/grub ]]; then
sudo mkdir ${root}/boot/grub
fi
ztmp
devicemap=$ztmpfile
cat > ${devicemap} <<EOF
(hd0) /dev/loop0
EOF
sudo cp ${devicemap} ${root}/boot/grub/device.map
sudo chroot ${root} grub-mkconfig -o /boot/grub/grub.cfg
## we now tamper with grub.cfg, to remove all references to
## loopback devices...
## FIXME!!! This is a hack...
sudo -- sed -r -i -e 's/.*loop.*//g' ${root}/boot/grub/grub.cfg
sudo grub-install --root-directory=${root} --no-floppy \
--modules="ext2 part_msdos" ${install_dev}
}