live-build/helpers/make-live

395 lines
11 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
2007-09-23 08:04:48 +00:00
# make-live(1) - utility to build Debian Live systems
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# On Debian systems, the complete text of the GNU General Public License
# can be found in /usr/share/common-licenses/GPL file.
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:48 +00:00
set -e
2007-09-23 08:04:46 +00:00
# Source common functions
for FUNCTION in /usr/share/live-helper/functions/*.sh
do
. ${FUNCTION}
done
2007-09-23 08:04:48 +00:00
# Set static variables
PROGRAM="`basename ${0}`"
DESCRIPTION="utility to build Debian Live systems"
2007-09-23 08:04:51 +00:00
USAGE="${PROGRAM} [config] [--mode MODE] [--config CONFIG] [--apt apt|aptitude] [--apt-ftpproxy URL] [--apt-httpproxy URL] [--apt-generic enabled|disabled] [--apt-pdiffs enabled|disabled] [--apt-recommends enabled|disabled] [--apt-secure enabled|disabled] [--bootstrap cdebootstrap|deboostrap] [--cache enabled|disabled] [--debconf-frontend dialog|readline|noninteractive] [--debconf-priority low|medium|high|critical] [--debconf-nowarnings yes|no] [--genisoimage genisoimage|mkisofs] [--losetup losetup|losetup.org] [--tasksel aptitude|tasksel] [-r|--root DIRECTORY] [-a|--architecture ARCHITECTURE] [-d|--distribution stable|testing|unstable|etch|lenny|sid] [--distribution-config DIRECTORY] [-f|--bootstrap-flavour minimal|standard] [-m|--mirror-build URL] [--mirror-build-security URL] [--mirror-image URL] [--mirror-image-security URL] [--sections SECTION|\"SECTIONS\"] [--interactive shell|x11|xnest] [-k|--kernel-flavour FLAVOUR] [--kernel-packages PACKAGE|\"PACKAGES\"] [--keyring-packages PACKAGE|\"PACKAGES\"] [--hooks \"COMMAND\"|\"COMMANDS\"] [-l|--language LANGUAGE] [--packages PACKAGE|\"PACKAGES\"] [-p|--packages-lists LIST|\"LISTS\"] [--tasks TASK|\"TASKS\"] [--security enabled|disabled] [--symlinks enabled|disabled] [--sysvinit enabled|disabled] [--bootappend KERNEL_PARAMETER|\"KERNEL_PARAMETERS\"] [-e|--encryption ALGORITHM] [--username NAME] [--hostname NAME] [--filesystem ext2|plain|squashfs] [--memtest memtest86|memtest86+] [--iso-volume STRING] [--server-address HOSTNAME|IP] [--server-path DIRECTORY] [--source enabled|disabled] [--bootloader grub|syslinux] [--grub-splash FILE] [--syslinux-splash FILE] [-b|--binary-image hdd|iso|usb|net] [-s|--source-image generic|hdd|iso|usb|net] [--includes PATH] [--templates PATH] [--breakpoints] [--debug] [--force] [--quiet] [--verbose] [--root-command sudo]"
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:47 +00:00
HELP="Lists: gnome, gnome-core, gnome-desktop, gnome-full, gnome-junior, gnustep, kde, kde-core, kde-desktop, kde-extra, kde-full, kde-junior, mini, minimal, minimal-net, rescue, standard, standard-x11, xfce, xfce-desktop, xfce-junior"
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:48 +00:00
Local_arguments ()
2007-09-23 08:04:46 +00:00
{
2007-09-23 08:04:51 +00:00
ARGUMENTS="`getopt --longoptions mode:,config:,apt:,apt-ftpproxy:,apt-httpproxy:,apt-generic:,apt-pdiffs:,apt-recommends:,apt-secure:,bootstrap:,cache:,debconf-frontend:,debconf-priority:,debconf-nowarnings:,genisoimage:,losetup:,tasksel:,root:,architecture:,distribution:,distribution-config:,flavour:,mirror-build:,mirror-build-security:,mirror-image:,mirror-image-security:,sections:,interactive:,kernel:,kernel-packages:,keyring-packages:,hooks:,language:,packages:,packages-lists:,tasks:,security:,symlinks:,sysvinit:,bootappend:,encryption:,username:,hostname:,filesystem:,memtest:,iso-volume:,server-address:,server-path:,source:,bootloader:,grub-splash:,syslinux-splash:,binary-image:,binary-source:,includes:,templates:,help,usage,version,force,breakpoints,debug,quiet,verbose,root-command: --name=${PROGRAM} --options r:a:d:f:m:k:l:p:e:b:s:huv --shell sh -- "${@}"`"
2007-09-23 08:04:46 +00:00
if [ "${?}" != "0" ]
then
echo "Terminating." >&2
exit 1
fi
2007-09-23 08:04:47 +00:00
if [ "${1}" = "config" ]
then
CONFIG="true"
fi
2007-09-23 08:04:46 +00:00
eval set -- "${ARGUMENTS}"
while true
do
case "${1}" in
# common
2007-09-23 08:04:49 +00:00
--mode)
LH_MODE="${2}"; shift 2
;;
2007-09-23 08:04:50 +00:00
--config)
LH_CONFIG="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
--apt)
LH_APT="${2}"; shift 2
;;
--apt-ftpproxy)
LH_APT_FTPPROXY="${2}"; shift 2
;;
--apt-httpproxy)
LH_APT_HTTPPROXY="${2}"; shift 2
;;
--apt-generic)
LH_APT_GENERIC="${2}"; shift 2
;;
--apt-pdiffs)
LH_APT_PDIFFS="${2}"; shift 2
;;
--apt-recommends)
LH_APT_RECOMMENDS="${2}"; shift 2
;;
2007-09-23 08:04:48 +00:00
--apt-secure)
LH_APT_SECURE="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
--bootstrap)
LH_BOOTSTRAP="${2}"; shift 2
;;
--cache)
LH_CACHE="${2}"; shift 2
;;
--debconf-frontend)
LH_DEBCONF_FRONTEND="${2}"; shift 2
;;
--debconf-priority)
LH_DEBCONF_PRIORITY="${2}"; shift 2
;;
2007-09-23 08:04:50 +00:00
--debconf-nowarnings)
LH_DEBCONF_NOWARNINGS="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
--genisoimage)
LH_GENISOIMAGE="${2}"; shift 2
;;
2007-09-23 08:04:47 +00:00
--losetup)
LH_LOSETUP="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:51 +00:00
--tasksel)
LH_TASKSEL="${2}"; shift 2
;;
2007-09-23 08:04:48 +00:00
-r|--root)
2007-09-23 08:04:47 +00:00
LIVE_ROOT="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:51 +00:00
--root-command)
LIVE_ROOT_COMMAND="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
# bootstrap
-a|--architecture)
LIVE_ARCHITECTURE="${2}"; shift 2
;;
-d|--distribution)
LIVE_DISTRIBUTION="${2}"; shift 2
export LIVE_DISTRIBUTION
;;
--distribution-config)
LIVE_DISTRIBUTION_CONFIG="${2}"; shift 2
;;
2007-09-23 08:04:48 +00:00
-f|--bootstrap-flavour)
LIVE_BOOTSTRAP_FLAVOUR="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:48 +00:00
-m|--mirror-build)
LIVE_MIRROR_BUILD="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:48 +00:00
--mirror-build-security)
LIVE_MIRROR_BUILD_SECURITY="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:48 +00:00
--mirror-image)
LIVE_MIRROR_IMAGE="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:48 +00:00
--mirror-image-security)
LIVE_MIRROR_IMAGE_SECURITY="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
--sections)
LIVE_SECTIONS="${2}"; shift 2
;;
# chroot
2007-09-23 08:04:48 +00:00
--interactive)
LIVE_INTERACTIVE="${2}"; shift 2
;;
-k|--kernel-flavour)
LIVE_KERNEL_FLAVOUR="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
--kernel-packages)
LIVE_KERNEL_PACKAGES="${2}"; shift 2
;;
2007-09-23 08:04:49 +00:00
--keyring-packages)
LIVE_KEYRING_PACKAGS="${2}"; shift 2
;;
2007-09-23 08:04:50 +00:00
--hooks)
LIVE_HOOKS="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
-l|--language)
LIVE_LANGUAGE="${2}"; shift 2
;;
--packages)
LIVE_PACKAGES="${2}"; shift 2
;;
2007-09-23 08:04:48 +00:00
-p|--packages-lists)
LIVE_PACKAGES_LISTS="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
--tasks)
LIVE_TASKS="${2}"; shift 2
;;
--security)
LIVE_SECURITY="${2}"; shift 2
;;
--symlinks)
LIVE_SYMLINKS="${2}"; shift 2
;;
--sysvinit)
LIVE_SYSVINIT="${2}"; shift 2
;;
# image
--bootappend)
LIVE_BOOTAPPEND="${2}"; shift 2
;;
-e|--encryption)
LIVE_ENCRYPTION="${2}"; shift 2
;;
2007-09-23 08:04:48 +00:00
--username)
LIVE_USERNAME="${2}"; shift 2
;;
--hostname)
LIVE_HOSTNAME="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
--filesystem)
LIVE_FILESYSTEM="${2}"; shift 2
;;
2007-09-23 08:04:50 +00:00
--memtest)
LIVE_MEMTEST="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
--iso-volume)
LIVE_ISO_VOLUME="${2}"; shift 2
;;
--server-address)
LIVE_SERVER_ADDRESS="${2}"; shift 2
;;
--server-path)
LIVE_SERVER_PATH="${2}"; shift 2
;;
--source)
LIVE_SOURCE="${2}"; shift 2
;;
2007-09-23 08:04:49 +00:00
--bootloader)
LIVE_BOOTLOADER="${2}"; shift 2
;;
--grub-splash)
2007-09-23 08:04:51 +00:00
LIVE_GRUB_SPLASH="${2}"; shift 2
2007-09-23 08:04:46 +00:00
;;
--syslinux-splash)
LIVE_SYSLINUX_SPLASH="${2}"; shift 2
;;
-b|--binary-image)
LIVE_BINARY_IMAGE="${2}"; shift 2
;;
-s|--source-image)
LIVE_SOURCE_IMAGE="${2}"; shift 2
;;
2007-09-23 08:04:48 +00:00
--includes)
LIVE_INCLUDES="${2}"; shift 2
;;
2007-09-23 08:04:46 +00:00
--templates)
LIVE_TEMPLATES="${2}"; shift 2
;;
# other
-h|--help)
Help; shift
;;
-u|--usage)
2007-09-23 08:04:48 +00:00
Usage; shift
2007-09-23 08:04:46 +00:00
;;
-v|--version)
Version; shift
;;
2007-09-23 08:04:49 +00:00
--breakpoints)
LH_BREAKPOINTS="enabled"; shift
;;
2007-09-23 08:04:49 +00:00
--debug)
2007-09-23 08:04:49 +00:00
LH_DEBUG="enabled"; shift
2007-09-23 08:04:49 +00:00
;;
2007-09-23 08:04:48 +00:00
--force)
2007-09-23 08:04:49 +00:00
LH_FORCE="enabled"; shift
2007-09-23 08:04:48 +00:00
;;
2007-09-23 08:04:49 +00:00
--quiet)
2007-09-23 08:04:49 +00:00
LH_QUIET="enabled"; shift
2007-09-23 08:04:49 +00:00
;;
--verbose)
2007-09-23 08:04:49 +00:00
LH_VERBOSE="enabled"; shift
2007-09-23 08:04:49 +00:00
;;
2007-09-23 08:04:46 +00:00
--)
shift; break
;;
*)
echo "Internal error."
exit 1
;;
esac
done
2007-09-23 08:04:48 +00:00
}
Main ()
{
Local_arguments "${@}"
Set_defaults
if [ -z "${ROOT}" ]
then
ROOT="${LIVE_ROOT}"
fi
# Source existing configuration
Read_conffile "${ROOT}"/config/common
Read_conffile "${ROOT}"/config/bootstrap
Read_conffile "${ROOT}"/config/chroot
Read_conffile "${ROOT}"/config/image
Local_arguments "${@}"
2007-09-23 08:04:46 +00:00
# Configuring (this is really shit!)
2007-09-23 08:04:51 +00:00
LH_MODE="${LH_MODE}" LH_CONFIG="${LH_CONFIG}" LH_APT="${LH_APT}" LH_APT_FTPPROXY="${LH_APT_FTPPROXY}" LH_APT_HTTPPROXY="${LH_APT_HTTPPROXY}" LH_APT_GENERIC="${LH_APT_GENERIC}" LH_APT_PDIFFS="${LH_APT_PDIFFS}" LH_APT_RECOMMENDS="${LH_APT_RECOMMENDS}" LH_APT_SECURE="${LH_APT_SECURE}" LH_BOOTSTRAP="${LH_BOOTSTRAP}" LH_CACHE="${LH_CACHE}" LH_DEBCONF_FRONTEND="${LH_DEBCONF_FRONTEND}" LH_DEBCONF_PRIORITY="${LH_DEBCONF_PRIORITY}" LH_DEBCONF_NOWARNINGS="${LH_DEBCONF_NOWARNINGS}" LH_GENISOIMAGE="${LH_GENISOIMAGE}" LH_LOSETUP="${LH_LOSETUP}" LH_TASKSEL="${LH_TASKSEL}" LIVE_ROOT="${LIVE_ROOT}" LIVE_ARCHITECTURE="${LIVE_ARCHITECTURE}" LIVE_DISTRIBUTION="${LIVE_DISTRIBUTION}" LIVE_DISTRIBUTION_CONFIG="${LIVE_DISTRIBUTION_CONFIG}" LIVE_BOOTSTRAP_FLAVOUR="${LIVE_BOOTSTRAP_FLAVOUR}" LIVE_MIRROR_BUILD="${LIVE_MIRROR_BUILD}" LIVE_MIRROR_BUILD_SECURITY="${LIVE_MIRROR_BUILD_SECURITY}" LIVE_MIRROR_IMAGE="${LIVE_MIRROR_IMAGE}" LIVE_MIRROR_IMAGE_SECURITY="${LIVE_MIRROR_IMAGE_SECURITY}" LIVE_SECTIONS="${LIVE_SECTIONS}" LIVE_INTERACTIVE="${LIVE_INTERACTIVE}" LIVE_KERNEL_FLAVOUR="${LIVE_KERNEL_FLAVOUR}" LIVE_KERNEL_PACKAGES="${LIVE_KERNEL_PACKAGES}" LIVE_KEYRING_PACKAGES="${LIVE_KEYRING_PACKAGES}" LIVE_HOOKS="${LIVE_HOOKS}" LIVE_LANGUAGE="${LIVE_LANGUAGE}" LIVE_PACKAGES="${LIVE_PACKAGES}" LIVE_PACKAGES_LISTS="${LIVE_PACKAGES_LISTS}" LIVE_TASKS="${LIVE_TASKS}" LIVE_SECURITY="${LIVE_SECURITY}" LIVE_SYMLINKS="${LIVE_SYMLINKS}" LIVE_SYSVINIT="${LIVE_SYSVINIT}" LIVE_BOOTAPPEND="${LIVE_BOOTAPPEND}" LIVE_ENCRYPTION="${LIVE_ENCRYPTION}" LIVE_USERNAME="${LIVE_USERNAME}" LIVE_HOSTNAME="${LIVE_HOSTNAME}" LIVE_FILESYSTEM="${LIVE_FILESYSTEM}" LIVE_MEMTEST="${LIVE_MEMTEST}" LIVE_ISO_VOLUME="${LIVE_ISO_VOLUME}" LIVE_SERVER_ADDRESS="${LIVE_SERVER_ADDRESS}" LIVE_SERVER_PATH="${LIVE_SERVER_PATH}" LIVE_SOURCE="${LIVE_SOURCE}" LIVE_BOOTLOADER="${LIVE_BOOTLOADER}" LIVE_GRUB_SPLASH="${LIVE_GRUB_SPLASH}" LIVE_SYSLINUX_SPLASH="${LIVE_SYSLINUX_SPLASH}" LIVE_BINARY_IMAGE="${LIVE_BINARY_IMAGE}" LIVE_SOURCE_IMAGE="${LIVE_SOURCE_IMAGE}" LIVE_INCLUDES="${LIVE_INCLUDES}" LIVE_TEMPLATES="${LIVE_TEMPLATES}" LH_ROOT_COMMAND="${LH_ROOT_COMMAND}" lh_config newconfig
2007-09-23 08:04:49 +00:00
if [ "${LH_BREAKPOINTS}" = "enabled" ]
then
OPTIONS="${OPTIONS} --breakpoints"
fi
2007-09-23 08:04:49 +00:00
2007-09-23 08:04:49 +00:00
if [ "${LH_DEBUG}" = "enabled" ]
2007-09-23 08:04:49 +00:00
then
OPTIONS="${OPTIONS} --debug"
fi
2007-09-23 08:04:48 +00:00
2007-09-23 08:04:49 +00:00
if [ "${LH_FORCE}" = "enabled" ]
2007-09-23 08:04:48 +00:00
then
OPTIONS="${OPTIONS} --force"
fi
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:49 +00:00
if [ "${LH_QUIET}" = "enabled" ]
2007-09-23 08:04:49 +00:00
then
OPTIONS="${OPTIONS} --quiet"
fi
2007-09-23 08:04:49 +00:00
if [ "${LH_VERBOSE}" = "enabled" ]
2007-09-23 08:04:49 +00:00
then
OPTIONS="${OPTIONS} --verbose"
fi
2007-09-23 08:04:46 +00:00
# Building
2007-09-23 08:04:47 +00:00
if [ -z "${CONFIG}" ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:48 +00:00
cd "${LIVE_ROOT}" && lh_build "${OPTIONS}"
2007-09-23 08:04:46 +00:00
fi
}
2007-09-23 08:04:51 +00:00
trap "if [ -f ${ROOT}/chroot/proc/version ]; then umount ${ROOT}/chroot/proc; fi; \
if [ -f ${ROOT}/chroot/sys/kernel ]; then umount ${ROOT}/chroot/sys; fi; exit" \
0 1 2 3 9 15
2007-09-23 08:04:46 +00:00
Main "${@}"