2008-06-15 03:46:25 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2011-01-11 12:56:42 -01:00
|
|
|
## Copyright (C) 2006-2011 Daniel Baumann <daniel@debian.org>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
|
|
|
## live-build comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2008-06-15 03:46:25 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Including common functions
|
2010-09-07 13:11:20 +00:00
|
|
|
. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
|
2008-06-15 03:46:25 +00:00
|
|
|
|
|
|
|
# Setting static variables
|
2009-01-15 01:37:42 -01:00
|
|
|
DESCRIPTION="$(Echo 'installs silo into binary')"
|
2008-06-15 03:46:25 +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
|
2008-06-15 03:46:25 +00:00
|
|
|
Set_defaults
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_BOOTLOADER}" != "silo" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2008-06-20 00:35:07 +00:00
|
|
|
# Check image type
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_BINARY_IMAGES}" in
|
2010-02-18 15:34:29 -01:00
|
|
|
iso*|usb*|tar)
|
2008-06-20 00:35:07 +00:00
|
|
|
;;
|
|
|
|
|
2008-06-20 00:37:47 +00:00
|
|
|
net)
|
2008-06-20 00:38:21 +00:00
|
|
|
# silo not required for sparc netbooting
|
|
|
|
exit 0
|
2008-06-20 00:35:07 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-06-15 03:46:25 +00:00
|
|
|
Echo_message "Begin installing silo..."
|
|
|
|
|
|
|
|
# Requiring stage file
|
2008-10-14 19:32:50 +00:00
|
|
|
Require_stagefile .stage/config .stage/bootstrap
|
2008-06-15 03:46:25 +00:00
|
|
|
|
|
|
|
# Checking stage file
|
|
|
|
Check_stagefile .stage/binary_silo
|
|
|
|
|
|
|
|
# Checking silo templates
|
2008-06-17 05:08:24 +00:00
|
|
|
Check_templates silo
|
2008-06-15 03:46:25 +00:00
|
|
|
|
|
|
|
# Checking lock file
|
|
|
|
Check_lockfile .lock
|
|
|
|
|
|
|
|
# Creating lock file
|
|
|
|
Create_lockfile .lock
|
|
|
|
|
|
|
|
# Check architecture
|
|
|
|
Check_architecture sparc
|
|
|
|
|
|
|
|
# Checking depends
|
|
|
|
Check_package chroot/usr/sbin/silo silo
|
|
|
|
|
|
|
|
# Restoring cache
|
|
|
|
Restore_cache cache/packages_binary
|
|
|
|
|
|
|
|
# Installing depends
|
|
|
|
Install_package
|
|
|
|
|
|
|
|
# Local functions
|
|
|
|
Silo_live_entry ()
|
|
|
|
{
|
|
|
|
LABEL="${1}"
|
|
|
|
KERNEL="${2}"
|
|
|
|
INITRD="${3}"
|
|
|
|
APPEND="${4}"
|
|
|
|
|
|
|
|
DIRECTORY="/$(basename ${DESTDIR_LIVE})"
|
|
|
|
|
|
|
|
LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
|
|
|
|
LINUX_LIVE="${LINUX_LIVE}\t label=${LABEL}\n"
|
|
|
|
LINUX_LIVE="${LINUX_LIVE}\t initrd=${DIRECTORY}/${INITRD}\n"
|
2010-09-16 20:38:13 +00:00
|
|
|
LINUX_LIVE="${LINUX_LIVE}\t append=\"boot=${INITFS} config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
|
2008-06-15 03:46:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Silo_install_entry ()
|
|
|
|
{
|
|
|
|
LABEL="${1}"
|
|
|
|
KERNEL="${2}"
|
|
|
|
INITRD="${3}"
|
|
|
|
APPEND="${4}"
|
|
|
|
|
|
|
|
DIRECTORY="/$(basename ${DESTDIR_INSTALL})"
|
|
|
|
|
2009-11-16 10:40:43 -01:00
|
|
|
if [ "${LABEL}" != "rescue" ] && [ "${LABEL}" != "rescuegui" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
|
|
|
APPEND="${APPEND} quiet"
|
|
|
|
fi
|
|
|
|
|
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\nimage=${DIRECTORY}/${KERNEL}\n"
|
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\t label=${LABEL}\n"
|
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\t initrd=${DIRECTORY}/${INITRD}\n"
|
2010-09-07 13:11:20 +00:00
|
|
|
LINUX_INSTALL="${LINUX_INSTALL}\t append=\"LB_BOOTAPPEND_LIVE ${APPEND} LB_BOOTAPPEND_INSTALL\"\n"
|
2008-06-15 03:46:25 +00:00
|
|
|
}
|
|
|
|
|
2008-06-20 00:35:07 +00:00
|
|
|
# Setting destination directories
|
|
|
|
DESTDIR_INSTALL="binary/install"
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_INITRAMFS}" in
|
2008-06-15 03:46:25 +00:00
|
|
|
casper)
|
|
|
|
INITFS="casper"
|
2008-06-20 00:35:07 +00:00
|
|
|
DESTDIR_LIVE="binary/casper"
|
2008-06-15 03:46:25 +00:00
|
|
|
;;
|
|
|
|
|
2010-09-04 10:52:01 +00:00
|
|
|
live-initramfs|live-boot)
|
2008-06-15 03:46:25 +00:00
|
|
|
INITFS="live"
|
2008-06-20 00:35:07 +00:00
|
|
|
DESTDIR_LIVE="binary/live"
|
2008-06-15 03:46:25 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Creating directory
|
|
|
|
mkdir -p "${DESTDIR_LIVE}"
|
|
|
|
|
|
|
|
# Setting boot parameters
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_ENCRYPTION}" in
|
2009-12-13 19:17:45 -01:00
|
|
|
""|false)
|
2008-06-15 03:46:25 +00:00
|
|
|
;;
|
|
|
|
*)
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} encryption=${LB_ENCRYPTION}"
|
2008-06-15 03:46:25 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_USERNAME}" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_INITRAMFS}" in
|
2008-06-15 03:46:25 +00:00
|
|
|
casper)
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} username=${LB_USERNAME}"
|
2008-06-15 03:46:25 +00:00
|
|
|
;;
|
|
|
|
|
2010-09-04 10:52:01 +00:00
|
|
|
live-initramfs|live-boot)
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_USERNAME}" != "user" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} username=${LB_USERNAME}"
|
2008-06-15 03:46:25 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_HOSTNAME}" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_INITRAMFS}" in
|
2008-06-15 03:46:25 +00:00
|
|
|
casper)
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} hostname=${LB_HOSTNAME}"
|
2008-06-15 03:46:25 +00:00
|
|
|
;;
|
|
|
|
|
2010-09-04 10:52:01 +00:00
|
|
|
live-initramfs|live-boot)
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_HOSTNAME}" != "debian" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} hostname=${LB_HOSTNAME}"
|
2008-06-15 03:46:25 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_UNION_FILESYSTEM}" != "aufs" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}"
|
2008-06-15 03:46:25 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_NET_COW_PATH}" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
|
|
|
Echo_error "Net cow not supported on silo"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_EXPOSED_ROOT}" != "false" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} exposedroot"
|
2008-06-15 03:46:25 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's| ||')"
|
2008-06-15 03:46:25 +00:00
|
|
|
|
|
|
|
# Parameters are listed at: linux/Documentation/kernel-parameters.txt
|
2010-06-22 20:38:45 +00:00
|
|
|
FAILSAFE="noapic noapm nodma nomce nolapic nomodeset nosmp vga=ofonly"
|
2008-06-15 03:46:25 +00:00
|
|
|
|
|
|
|
# Assembling kernel configuration
|
|
|
|
|
|
|
|
# Default entries
|
2010-09-07 13:11:20 +00:00
|
|
|
DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
|
2008-06-15 03:46:25 +00:00
|
|
|
DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
|
|
|
|
DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
|
|
|
|
|
|
|
|
Silo_live_entry "live" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}"
|
|
|
|
Silo_live_entry "live-failsafe" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}" "${FAILSAFE}"
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "$(echo ${LB_LINUX_FLAVOURS} | wc -w)" -gt "1" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
|
|
|
for KERNEL in chroot/boot/vmlinuz-*
|
|
|
|
do
|
|
|
|
KERNEL_IMAGE="$(basename ${KERNEL})"
|
|
|
|
KERNEL_VERSION="$(echo ${KERNEL_IMAGE} | sed -e 's|vmlinuz-||')"
|
|
|
|
INITRD="initrd.img-${KERNEL_VERSION}"
|
|
|
|
|
|
|
|
Silo_live_entry "live-${KERNEL_VERSION}" "${KERNEL_IMAGE}" "${INITRD}"
|
|
|
|
Silo_live_entry "live-${KERNEL_VERSION}-failsafe" "${KERNEL_IMAGE}" "${INITRD}" "${FAILSAFE}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
|
|
|
|
|
|
|
|
# Assembling debian-installer configuration
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_DEBIAN_INSTALLER}" != "false" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
|
|
|
VMLINUZ_DI="vmlinuz"
|
|
|
|
INITRD_DI="initrd.gz"
|
|
|
|
APPEND_DI="vga=normal"
|
|
|
|
|
|
|
|
Silo_install_entry "linux" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
|
|
|
|
Silo_install_entry "install" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
|
|
|
|
Silo_install_entry "expert" "${VMLINUZ_DI}" "${INITRD_DI}" "priority=low ${APPEND_DI}"
|
|
|
|
Silo_install_entry "rescue" "${VMLINUZ_DI}" "${INITRD_DI}" "rescue/enable=true ${APPEND_DI}"
|
|
|
|
Silo_install_entry "auto" "${VMLINUZ_DI}" "${INITRD_DI}" "auto=true priority=critical ${APPEND_DI}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_BINARY_IMAGES}" in
|
2010-02-18 15:34:29 -01:00
|
|
|
iso*|usb*)
|
2008-06-15 03:46:25 +00:00
|
|
|
# Copying silo
|
|
|
|
mkdir -p binary/boot
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_BUILD_WITH_CHROOT}" in
|
2009-12-13 19:17:45 -01:00
|
|
|
true)
|
2008-06-15 03:46:25 +00:00
|
|
|
cp chroot/boot/second.b binary/boot
|
|
|
|
;;
|
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
false)
|
2008-06-15 03:46:25 +00:00
|
|
|
cp /boot/second.b binary/boot
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
cp -r "${TEMPLATES}"/* binary/boot
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_DEBIAN_INSTALLER}" = "false" ]
|
2008-06-15 03:46:25 +00:00
|
|
|
then
|
|
|
|
rm -f binary/boot/debian.txt.install
|
|
|
|
else
|
|
|
|
mv binary/boot/debian.txt.install binary/boot/debian.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Configure silo templates
|
|
|
|
sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" \
|
|
|
|
-e "s|LINUX_INSTALL|${LINUX_INSTALL}|" \
|
|
|
|
binary/boot/silo.conf
|
2010-09-07 13:11:20 +00:00
|
|
|
sed -i -e "s|LB_BOOTAPPEND_INSTALL|${LB_BOOTAPPEND_INSTALL}|" \
|
|
|
|
-e "s|LB_BOOTAPPEND_LIVE|${LB_BOOTAPPEND_LIVE}|" \
|
2008-06-15 03:46:25 +00:00
|
|
|
binary/boot/silo.conf
|
2010-09-07 13:11:20 +00:00
|
|
|
sed -i -e "s|LB_DATE|$(date +%Y%m%d)|" \
|
|
|
|
-e "s|LB_VERSION|${VERSION}|" \
|
|
|
|
-e "s|LB_DISTRIBUTION|${LB_DISTRIBUTION}|" \
|
2008-06-15 03:46:25 +00:00
|
|
|
binary/boot/debian.txt
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Saving cache
|
|
|
|
Save_cache cache/packages_binary
|
|
|
|
|
|
|
|
# Removing depends
|
|
|
|
Remove_package
|
|
|
|
|
|
|
|
# Creating stage file
|
|
|
|
Create_stagefile .stage/binary_silo
|