2007-09-23 08:04:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Including common functions
|
2012-08-27 13:52:29 +00:00
|
|
|
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Setting static variables
|
2015-05-04 18:36:20 +00:00
|
|
|
DESCRIPTION="$(Echo 'installs grub-legacy into binary')"
|
2007-09-23 08:04:49 +00:00
|
|
|
HELP=""
|
|
|
|
USAGE="${PROGRAM} [--force]"
|
|
|
|
|
|
|
|
Arguments "${@}"
|
|
|
|
|
|
|
|
# Reading configuration files
|
2008-10-28 14:26:17 -01:00
|
|
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
2007-09-23 08:04:49 +00:00
|
|
|
Set_defaults
|
|
|
|
|
2016-01-18 02:07:48 -01:00
|
|
|
Check_First_Bootloader_Role "grub-legacy"
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2015-05-04 18:36:20 +00:00
|
|
|
Echo_message "Begin installing grub-legacy..."
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Requiring stage file
|
2012-06-03 20:42:41 +00:00
|
|
|
Require_stagefile .build/config .build/bootstrap
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:50 +00:00
|
|
|
# Checking stage file
|
2015-05-04 18:36:20 +00:00
|
|
|
Check_stagefile .build/binary_grub-legacy
|
2007-09-23 08:04:50 +00:00
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Checking lock file
|
|
|
|
Check_lockfile .lock
|
|
|
|
|
|
|
|
# Creating lock file
|
|
|
|
Create_lockfile .lock
|
|
|
|
|
2007-09-23 08:05:13 +00:00
|
|
|
# Check architecture
|
2010-12-05 12:27:08 -01:00
|
|
|
Check_architectures amd64 i386
|
|
|
|
Check_crossarchitectures
|
2007-09-23 08:05:09 +00:00
|
|
|
|
2007-09-23 08:04:51 +00:00
|
|
|
# Checking depends
|
2015-01-04 16:08:09 -01:00
|
|
|
Check_package chroot /usr/sbin/grub grub-legacy
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:05:15 +00:00
|
|
|
# Restoring cache
|
2012-06-04 08:52:28 +00:00
|
|
|
Restore_cache cache/packages.binary
|
2007-09-23 08:05:15 +00:00
|
|
|
|
2007-09-23 08:04:51 +00:00
|
|
|
# Installing depends
|
|
|
|
Install_package
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:05:14 +00:00
|
|
|
# Local functions
|
|
|
|
Grub_live_entry ()
|
|
|
|
{
|
|
|
|
LABEL="${1}"
|
|
|
|
KERNEL="${2}"
|
|
|
|
INITRD="${3}"
|
|
|
|
APPEND="${4}"
|
|
|
|
|
|
|
|
LINUX_LIVE="${LINUX_LIVE}\ntitle\t\tDebian GNU/Linux - ${LABEL}"
|
2011-06-08 08:07:26 +00:00
|
|
|
LINUX_LIVE="${LINUX_LIVE}\nkernel\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}"
|
2007-09-23 08:05:14 +00:00
|
|
|
LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}"
|
|
|
|
}
|
|
|
|
|
|
|
|
Grub_install_entry ()
|
|
|
|
{
|
|
|
|
LABEL="${1}"
|
|
|
|
KERNEL="${2}"
|
|
|
|
INITRD="${3}"
|
|
|
|
APPEND="${4}"
|
|
|
|
|
2009-11-16 10:40:43 -01:00
|
|
|
QAPPEND="quiet"
|
2007-09-23 08:05:14 +00:00
|
|
|
|
2009-09-11 07:44:40 +00:00
|
|
|
for TYPE in Install Expert Rescue Auto
|
|
|
|
do
|
|
|
|
case "${TYPE}" in
|
|
|
|
Install)
|
|
|
|
TAPPEND="${APPEND} ${QAPPEND}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
Expert)
|
|
|
|
TAPPEND="priority=low ${APPEND}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
Rescue)
|
|
|
|
TAPPEND="rescue/enable=true ${APPEND} ${QAPPEND}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
Auto)
|
|
|
|
TAPPEND="auto=true priority=critical ${APPEND} ${QAPPEND}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "${LABEL}" in
|
|
|
|
Text)
|
|
|
|
TYPE_SUFFIX=""
|
|
|
|
;;
|
|
|
|
GUI)
|
|
|
|
TYPE_SUFFIX="gui"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\ntitle\t\t${LABEL} ${TYPE}"
|
2010-09-07 13:11:20 +00:00
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\nkernel\t\t/${KERNEL} ${TAPPEND} ${LB_BOOTAPPEND_INSTALL}"
|
2009-09-11 07:44:40 +00:00
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\ninitrd\t\t/${INITRD}"
|
|
|
|
done
|
2007-09-23 08:05:14 +00:00
|
|
|
}
|
|
|
|
|
2015-05-04 18:36:20 +00:00
|
|
|
if [ -e "config/bootloaders/grub-legacy" ]
|
2015-04-29 05:52:56 +00:00
|
|
|
then
|
|
|
|
# Internal local copy
|
2015-05-04 18:36:20 +00:00
|
|
|
_SOURCE="config/bootloaders/grub-legacy"
|
2015-04-29 05:52:56 +00:00
|
|
|
else
|
|
|
|
# Internal system copy
|
|
|
|
if [ -n "${LIVE_BUILD}" ]
|
|
|
|
then
|
2015-05-04 18:36:20 +00:00
|
|
|
_SOURCE="${LIVE_BUILD}/share/bootloaders/grub-legacy"
|
2015-04-29 05:52:56 +00:00
|
|
|
else
|
2015-05-04 18:36:20 +00:00
|
|
|
_SOURCE="/usr/share/live/build/bootloaders/grub-legacy"
|
2015-04-29 05:52:56 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_INITRAMFS}" in
|
2011-01-02 08:32:58 -01:00
|
|
|
live-boot)
|
2007-09-23 08:04:52 +00:00
|
|
|
INITFS="live"
|
|
|
|
;;
|
2011-06-08 08:07:26 +00:00
|
|
|
|
|
|
|
*)
|
|
|
|
INITFS=""
|
|
|
|
;;
|
2007-09-23 08:04:52 +00:00
|
|
|
esac
|
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Setting destination directory
|
2012-12-19 08:52:13 -01:00
|
|
|
case "${LIVE_IMAGE_TYPE}" in
|
2010-02-18 15:34:29 -01:00
|
|
|
iso*|tar)
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_INITRAMFS}" in
|
2011-01-02 08:32:58 -01:00
|
|
|
live-boot)
|
2007-09-23 08:05:13 +00:00
|
|
|
DESTDIR_LIVE="binary/live"
|
|
|
|
;;
|
2011-06-08 08:07:26 +00:00
|
|
|
|
|
|
|
*)
|
|
|
|
DESTDIR_LIVE="binary/boot"
|
|
|
|
;;
|
2007-09-23 08:05:13 +00:00
|
|
|
esac
|
|
|
|
|
2007-09-23 08:04:52 +00:00
|
|
|
DESTDIR_INSTALL="binary/install"
|
2007-09-23 08:04:49 +00:00
|
|
|
;;
|
|
|
|
|
2012-07-18 17:11:55 +00:00
|
|
|
hdd*|netboot)
|
2010-09-02 11:22:22 +00:00
|
|
|
Echo_warning "Bootloader in this image type not yet supported by live-build."
|
2008-10-30 07:30:47 -01:00
|
|
|
Echo_warning "This would produce a not bootable image, aborting (FIXME)."
|
2007-09-23 08:04:50 +00:00
|
|
|
exit 1
|
2020-02-10 14:48:49 -01:00
|
|
|
;;
|
2007-09-23 08:04:49 +00:00
|
|
|
esac
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2010-12-05 12:27:08 -01:00
|
|
|
Check_multiarchitectures
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Creating directory
|
2007-09-23 08:05:11 +00:00
|
|
|
mkdir -p "${DESTDIR_LIVE}"
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Setting boot parameters
|
2016-12-02 13:10:19 -01:00
|
|
|
if [ "${LB_UNION_FILESYSTEM}" != "overlay" ]
|
2007-09-23 08:05:13 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}"
|
2007-09-23 08:05:13 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_NET_COW_PATH}" ]
|
2007-10-30 17:17:16 -01:00
|
|
|
then
|
2015-05-04 18:36:20 +00:00
|
|
|
Echo_error "Net cow not yet supported on grub-legacy"
|
2007-10-31 09:10:05 -01:00
|
|
|
exit 1
|
2007-10-30 17:17:16 -01:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's| ||')"
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Assembling kernel configuration
|
2007-09-23 08:05:14 +00:00
|
|
|
|
|
|
|
# Default entries
|
2010-09-07 13:11:20 +00:00
|
|
|
DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
|
2007-09-24 06:47:42 +00:00
|
|
|
DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
|
2008-01-15 06:25:29 -01:00
|
|
|
DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
|
2007-09-23 08:04:52 +00:00
|
|
|
|
2007-09-24 06:47:42 +00:00
|
|
|
Grub_live_entry "live" "$(basename ${DESTDIR_LIVE})/${DEFAULT_KERNEL}" "$(basename ${DESTDIR_LIVE})/${DEFAULT_INITRD}"
|
2012-04-27 18:31:49 +00:00
|
|
|
|
|
|
|
if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ]
|
|
|
|
then
|
|
|
|
Grub_live_entry "live (fail-safe mode)" "$(basename ${DESTDIR_LIVE})/${DEFAULT_KERNEL}" "$(basename ${DESTDIR_LIVE})/${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
|
|
|
|
fi
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:05:14 +00:00
|
|
|
for KERNEL in chroot/boot/vmlinuz-*
|
|
|
|
do
|
2008-01-15 06:25:29 -01:00
|
|
|
VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')"
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-24 06:47:42 +00:00
|
|
|
Grub_live_entry "live, kernel ${VERSION}" "$(basename ${DESTDIR_LIVE})/$(basename ${KERNEL})" "$(basename ${DESTDIR_LIVE})/initrd.img-${VERSION}"
|
2012-04-27 18:31:49 +00:00
|
|
|
Grub_live_entry "live, kernel ${VERSION} (fail-safe mode)" "$(basename ${DESTDIR_LIVE})/$(basename ${KERNEL})" "$(basename ${DESTDIR_LIVE})/initrd.img-${VERSION}" "${LB_BOOTAPPEND_FAILSAFE}"
|
2007-09-23 08:05:14 +00:00
|
|
|
done
|
|
|
|
|
2008-01-15 06:25:29 -01:00
|
|
|
LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:52 +00:00
|
|
|
# Assembling debian-installer configuration
|
2015-01-05 15:53:53 -01:00
|
|
|
if [ "${LB_DEBIAN_INSTALLER}" != "none" ]
|
2007-09-23 08:04:52 +00:00
|
|
|
then
|
2007-09-23 08:05:14 +00:00
|
|
|
LINUX_LIVE="title\t\tLive:\nroot\n\n${LINUX_LIVE}"
|
|
|
|
LINUX_INSTALL="title\t\tInstaller:\nroot"
|
|
|
|
|
2008-07-10 23:37:51 +00:00
|
|
|
VMLINUZ_DI="install/vmlinuz"
|
|
|
|
INITRD_DI="install/initrd.gz"
|
2007-09-23 08:05:14 +00:00
|
|
|
APPEND_DI="vga=normal"
|
|
|
|
|
2008-07-10 23:37:51 +00:00
|
|
|
VMLINUZ_GI="install/gtk/vmlinuz"
|
|
|
|
INITRD_GI="install/gtk/initrd.gz"
|
2007-09-23 08:05:14 +00:00
|
|
|
APPEND_GI="video=vesa:ywrap,mtrr vga=788"
|
|
|
|
|
2020-01-23 14:47:04 -01:00
|
|
|
if [ -f "binary/${VMLINUZ_GI}" ] && [ -f "binary/${INITRD_GI}" ]
|
2009-09-11 07:45:39 +00:00
|
|
|
then
|
2020-01-23 14:47:04 -01:00
|
|
|
Grub_install_entry "GUI" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
|
2009-09-11 07:45:39 +00:00
|
|
|
fi
|
|
|
|
|
2020-01-23 14:47:04 -01:00
|
|
|
if [ -f "binary/${VMLINUZ_DI}" ] && [ -f "binary/${INITRD_DI}" ]
|
2009-09-11 07:45:39 +00:00
|
|
|
then
|
2020-01-23 14:47:04 -01:00
|
|
|
Grub_install_entry "Text" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
|
2009-09-11 07:45:39 +00:00
|
|
|
fi
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
|
2008-01-15 06:25:29 -01:00
|
|
|
LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
|
2007-09-23 08:05:14 +00:00
|
|
|
|
2007-09-23 08:04:49 +00:00
|
|
|
# Assembling memtest configuration
|
2007-09-23 08:04:52 +00:00
|
|
|
if [ -f "${DESTDIR_LIVE}"/memtest ]
|
2007-09-23 08:04:49 +00:00
|
|
|
then
|
2007-09-23 08:05:14 +00:00
|
|
|
MEMTEST="title\t\tOther:\nroot"
|
2010-09-07 13:11:20 +00:00
|
|
|
MEMTEST="${MEMTEST}\n\ntitle\t\t${LB_MEMTEST}\nkernel\t\t/$(basename ${DESTDIR_LIVE})/memtest"
|
2008-01-15 06:25:29 -01:00
|
|
|
MEMTEST="$(/bin/echo ${MEMTEST} | sed -e 's|//|/|g')"
|
2007-09-23 08:04:49 +00:00
|
|
|
fi
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:50 +00:00
|
|
|
# Copying templates
|
2007-09-23 08:04:49 +00:00
|
|
|
mkdir -p binary/boot/grub
|
2015-04-29 05:52:56 +00:00
|
|
|
cp -r "${_SOURCE}"/* binary/boot/grub
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2012-12-19 08:52:13 -01:00
|
|
|
case ${LIVE_IMAGE_TYPE} in
|
2010-02-18 15:34:29 -01:00
|
|
|
iso*)
|
2007-09-23 08:05:15 +00:00
|
|
|
FILES="chroot/usr/lib/grub/*/stage2_eltorito"
|
2007-09-23 08:04:49 +00:00
|
|
|
;;
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2011-09-13 07:10:28 +00:00
|
|
|
hdd*|tar)
|
2007-09-23 08:05:15 +00:00
|
|
|
FILES="chroot/usr/lib/grub/*/stage1 chroot/usr/lib/grub/*/e2fs_stage1_5 chroot/usr/lib/grub/*/stage2"
|
2007-09-23 08:04:49 +00:00
|
|
|
;;
|
|
|
|
esac
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_BUILD_WITH_CHROOT}" = "false" ]
|
2007-09-23 08:05:15 +00:00
|
|
|
then
|
2008-01-15 06:25:29 -01:00
|
|
|
FILES="$(echo ${FILES} | sed -e 's|chroot||g')"
|
2007-09-23 08:05:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Copying grub
|
|
|
|
cp ${FILES} binary/boot/grub
|
|
|
|
|
2008-01-15 06:25:29 -01:00
|
|
|
sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" -e "s|MEMTEST|${MEMTEST}|" binary/boot/grub/menu.lst
|
2012-11-30 13:06:57 -01:00
|
|
|
sed -i -e "s#LB_BOOTAPPEND_INSTALL#${LB_BOOTAPPEND_INSTALL}#" -e "s#LB_BOOTAPPEND_LIVE#${LB_BOOTAPPEND_LIVE}#" binary/boot/grub/menu.lst
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2008-01-15 06:25:29 -01:00
|
|
|
sed -i -e 's|\ $||g' binary/boot/grub/menu.lst
|
2007-09-23 08:05:14 +00:00
|
|
|
|
2007-09-23 08:05:15 +00:00
|
|
|
# Saving cache
|
2012-06-04 08:52:28 +00:00
|
|
|
Save_cache cache/packages.binary
|
2007-09-23 08:05:15 +00:00
|
|
|
|
2007-09-23 08:04:51 +00:00
|
|
|
# Removing depends
|
|
|
|
Remove_package
|
2007-09-23 08:04:49 +00:00
|
|
|
|
|
|
|
# Creating stage file
|
2012-06-03 20:42:41 +00:00
|
|
|
Create_stagefile .build/binary_grub
|