diff options
author | Daniel Baumann <daniel@debian.org> | 2010-09-26 12:38:38 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2010-09-26 15:11:45 +0200 |
commit | 152d608f61fd22a1414c3a90ba061b790200350a (patch) | |
tree | 44a6d3a12cd11067aea2a4d43eb9133cc25bad2f /functions | |
download | vyos-live-build-152d608f61fd22a1414c3a90ba061b790200350a.tar.gz vyos-live-build-152d608f61fd22a1414c3a90ba061b790200350a.zip |
Adding debian version 3.0~a1-1.
Diffstat (limited to 'functions')
-rwxr-xr-x | functions/aliases.sh | 41 | ||||
-rwxr-xr-x | functions/architecture.sh | 88 | ||||
-rwxr-xr-x | functions/arguments.sh | 82 | ||||
-rwxr-xr-x | functions/breakpoints.sh | 20 | ||||
-rwxr-xr-x | functions/cache.sh | 61 | ||||
-rwxr-xr-x | functions/chroot.sh | 28 | ||||
-rwxr-xr-x | functions/color.sh | 38 | ||||
-rwxr-xr-x | functions/common.sh | 15 | ||||
-rwxr-xr-x | functions/conffile.sh | 55 | ||||
-rwxr-xr-x | functions/cursor.sh | 74 | ||||
-rwxr-xr-x | functions/defaults.sh | 1233 | ||||
-rwxr-xr-x | functions/echo.sh | 251 | ||||
-rwxr-xr-x | functions/exit.sh | 45 | ||||
-rwxr-xr-x | functions/help.sh | 36 | ||||
-rwxr-xr-x | functions/l10n.sh | 27 | ||||
-rwxr-xr-x | functions/lockfile.sh | 47 | ||||
-rwxr-xr-x | functions/losetup.sh | 53 | ||||
-rwxr-xr-x | functions/man.sh | 18 | ||||
-rwxr-xr-x | functions/packages.sh | 103 | ||||
-rwxr-xr-x | functions/packageslists.sh | 98 | ||||
-rwxr-xr-x | functions/releases.sh | 24 | ||||
-rwxr-xr-x | functions/stagefile.sh | 71 | ||||
-rwxr-xr-x | functions/templates.sh | 25 | ||||
-rwxr-xr-x | functions/usage.sh | 31 | ||||
-rwxr-xr-x | functions/version.sh | 37 | ||||
-rwxr-xr-x | functions/wrapper.sh | 22 |
26 files changed, 2623 insertions, 0 deletions
diff --git a/functions/aliases.sh b/functions/aliases.sh new file mode 100755 index 000000000..8e1dddad4 --- /dev/null +++ b/functions/aliases.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Find_files () +{ + (ls "${@}" | grep -qs .) > /dev/null 2>&1 +} + +In_list () +{ + NEEDLES="${1}" + shift + + for ITEM in ${@} + do + for NEEDLE in ${NEEDLES} + do + if [ "${NEEDLE}" = "${ITEM}" ] + then + return 0 + fi + done + done + + return 1 +} + +Truncate () +{ + for FILE in ${@} + do + : > ${FILE} + done +} diff --git a/functions/architecture.sh b/functions/architecture.sh new file mode 100755 index 000000000..b49729348 --- /dev/null +++ b/functions/architecture.sh @@ -0,0 +1,88 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Check_architecture () +{ + ARCHITECTURES="${@}" + VALID="false" + + for ARCHITECTURE in ${ARCHITECTURES} + do + if [ "$(echo ${LB_ARCHITECTURE} | grep ${ARCHITECTURE})" ] + then + VALID="true" + break + fi + done + + if [ "${VALID}" = "false" ] + then + Echo_warning "skipping %s, foreign architecture." "${0}" + exit 0 + fi +} + +Check_crossarchitecture () +{ + if [ -x /usr/bin/dpkg ] + then + HOST="$(dpkg --print-architecture)" + else + HOST="$(uname -m)" + fi + + case "${HOST}" in + amd64|i386|x86_64) + CROSS="amd64 i386" + ;; + + powerpc|ppc64) + CROSS="powerpc ppc64" + ;; + + *) + CROSS="${HOST}" + ;; + esac + + Check_architecture "${CROSS}" +} + +Check_multiarchitecture () +{ + if [ "$(echo ${LB_ARCHITECTURE} | wc -w)" -gt "1" ] + then + # First, only support multiarch on iso + case "${LB_BINARY_IMAGES}" in + iso*) + # Assemble multi-arch + case "${LB_CURRENT_ARCHITECTURE}" in + amd64) + DESTDIR="${DESTDIR}.amd" + DESTDIR_LIVE="${DESTDIR_LIVE}.amd" + DESTDIR_INSTALL="${DESTDIR_INSTALL}.amd" + ;; + + i386) + DESTDIR="${DESTDIR}.386" + DESTDIR_LIVE="${DESTDIR_LIVE}.386" + DESTDIR_INSTALL="${DESTDIR_INSTALL}.386" + ;; + + powerpc) + DESTDIR="${DESTDIR}.ppc" + DESTDIR_LIVE="${DESTDIR_LIVE}.ppc" + DESTDIR_INSTALL="${DESTDIR_INSTALL}.ppc" + ;; + esac + ;; + esac + fi +} diff --git a/functions/arguments.sh b/functions/arguments.sh new file mode 100755 index 000000000..0db3c13d0 --- /dev/null +++ b/functions/arguments.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Arguments () +{ + ARGUMENTS="$(getopt --longoptions breakpoints,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options c:huv --shell sh -- "${@}")" + + if [ "${?}" != "0" ] + then + Echo_error "terminating" >&2 + exit 1 + fi + + eval set -- "${ARGUMENTS}" + + while true + do + case "${1}" in + --breakpoints) + _BREAKPOINTS="true" + shift + ;; + + -c|--conffile) + _CONFFILE="${2}" + shift 2 + ;; + + --debug) + _DEBUG="true" + shift + ;; + + --force) + _FORCE="true" + shift + ;; + + -h|--help) + Man + shift + ;; + + --quiet) + _QUIET="true" + shift + ;; + + -u|--usage) + Usage + shift + ;; + + --verbose) + _VERBOSE="true" + shift + ;; + + -v|--version) + Version + shift + ;; + + --) + shift + break + ;; + + *) + Echo_error "internal error %s" "${0}" + exit 1 + ;; + esac + done +} diff --git a/functions/breakpoints.sh b/functions/breakpoints.sh new file mode 100755 index 000000000..29ab8610c --- /dev/null +++ b/functions/breakpoints.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Breakpoint () +{ + NAME="${1}" + + if [ "${_BREAKPOINTS}" = "true" ] + then + Echo_message "Waiting at %s" "${NAME}" + read WAIT + fi +} diff --git a/functions/cache.sh b/functions/cache.sh new file mode 100755 index 000000000..bae606dd2 --- /dev/null +++ b/functions/cache.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Restore_cache () +{ + DIRECTORY="${1}" + + if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ] + then + if [ -d "${DIRECTORY}" ] + then + # Restore old cache + if [ "$(stat --printf %d ${DIRECTORY})" = "$(stat --printf %d chroot/var/cache/apt/archives)" ] + then + # with hardlinks + cp -fl "${DIRECTORY}"/*.deb chroot/var/cache/apt/archives + else + # without hardlinks + cp "${DIRECTORY}"/*.deb chroot/var/cache/apt/archives + fi + fi + fi +} + +Save_cache () +{ + DIRECTORY="${1}" + + if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ] + then + # Cleaning current cache + Chroot chroot "apt-get autoclean" + + if ls chroot/var/cache/apt/archives/*.deb > /dev/null 2>&1 + then + # Creating cache directory + mkdir -p "${DIRECTORY}" + + # Saving new cache + for PACKAGE in chroot/var/cache/apt/archives/*.deb + do + if [ -e "${DIRECTORY}"/"$(basename ${PACKAGE})" ] + then + rm -f "${PACKAGE}" + else + mv "${PACKAGE}" "${DIRECTORY}" + fi + done + fi + else + # Purging current cache + rm -f chroot/var/cache/apt/archives/*.deb + fi +} diff --git a/functions/chroot.sh b/functions/chroot.sh new file mode 100755 index 000000000..589200add --- /dev/null +++ b/functions/chroot.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Chroot () +{ + CHROOT="${1}"; shift + COMMANDS="${@}" + + # Executing commands in chroot + Echo_debug "Executing: %s" "${COMMANDS}" + + if [ "${LB_USE_FAKEROOT}" != "true" ] + then + ${LB_ROOT_COMMAND} /usr/sbin/chroot "${CHROOT}" /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" ftp_proxy="${LB_APT_FTP_PROXY}" http_proxy="${LB_APT_HTTP_PROXY}" DEBIAN_FRONTEND="${LB_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LB_DEBCONF_PRIORITY}" DEBCONF_NOWARNINGS="${LB_DEBCONF_NOWARNINGS}" XORG_CONFIG="custom" ${COMMANDS} + else + # Building with fakeroot/fakechroot + ${LB_ROOT_COMMAND} /usr/sbin/chroot "${CHROOT}" ${COMMANDS} + fi + + return "${?}" +} diff --git a/functions/color.sh b/functions/color.sh new file mode 100755 index 000000000..9bdd8371d --- /dev/null +++ b/functions/color.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +NO_COLOR="\033[0m" + +UNDERSCORE="\033[4m" +BLINK="\033[5m" + +BLACK="\033[0;30m" +DARK_GRAY="\033[1;30m" + +RED="\033[0;31m" +LIGHT_RED="\033[1;31m" + +GREEN="\033[0;32m" +LIGHT_GREEN="\033[1;32m" + +BROWN="\033[0;33m" +YELLOW="\033[1;33m" + +BLUE="\033[0;34m" +LIGHT_BLUE="\033[1;34m" + +PURPLE="\033[0;35m" +LIGHT_PURPLE="\033[1;35m" + +CYAN="\033[0;36m" +LIGHT_CYAN="\033[1;36m" + +GRAY="\033[0;37m" +WHITE="\033[1;37m" diff --git a/functions/common.sh b/functions/common.sh new file mode 100755 index 000000000..98c8cfaee --- /dev/null +++ b/functions/common.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +PACKAGE="live-build" +VERSION="3.0~a1-1" +CONFIG_VERSION="$(echo ${VERSION} | awk -F- '{ print $1 }')" + +PATH="${PWD}/auto/scripts:${PATH}" diff --git a/functions/conffile.sh b/functions/conffile.sh new file mode 100755 index 000000000..02730dfd8 --- /dev/null +++ b/functions/conffile.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Get_conffiles () +{ + if [ -n "${LB_CONFIG}" ] + then + FILES="${LB_CONFIG}" + else + for FILE in ${@} + do + FILES="${FILES} ${FILE} ${FILE}.${LB_ARCHITECTURE} ${FILE}.${DISTRIBUTION}" + FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lh_||')" + FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lh_||').${ARCHITECTURE}" + FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lh_||').${DISTRIBUTION}" + done + fi + + echo ${FILES} +} + +Read_conffiles () +{ + for CONFFILE in Get_conffiles "${@}" + do + if [ -f "${CONFFILE}" ] + then + if [ -r "${CONFFILE}" ] + then + Echo_debug "Reading configuration file %s" "${CONFFILE}" + . "${CONFFILE}" + else + Echo_warning "Failed to read configuration file %s" "${CONFFILE}" + fi + fi + done +} + +Print_conffiles () +{ + for CONFFILE in Get_conffiles "${@}" + do + if [ -f "${CONFFILE}" ] + then + Echo_file "${CONFFILE}" + fi + done +} diff --git a/functions/cursor.sh b/functions/cursor.sh new file mode 100755 index 000000000..6ea1d9a9e --- /dev/null +++ b/functions/cursor.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Cursor_goto_position () +{ + __LINE="${1}" + __COLUMN="${2}" + + #echo -e "[${__LINE};${__COLUMN};H\c" + printf "[${__LINE};${__COLUMN};H" +} + +Cursor_save_position () +{ + #echo -e "[s\c" + printf "[s" +} + +Cursor_restore_position () +{ + #echo -e "[u\c" + printf "[u" +} + +Cursor_line_up () +{ + __LINES="${1}" + + #echo -e "[${__LINES}A\c" + printf "[${__LINES}A" +} + +Cursor_line_down () +{ + __LINES="${1}" + + #echo -e "[${__LINES}B\c" + printf "[${__LINES}B" +} + +Cursor_columns_forward () +{ + __COLUMNS="${1}" + + #echo -e "[${__COLUMNS}C\c" + printf "[${__COLUMNS}C" +} + +Cursor_columns_backward () +{ + __COLUMNS="${1}" + + #echo -e "[${__COLUMNS}D\c" + printf "[${__COLUMNS}D" +} + +Cursor_clear_screen () +{ + #echo -e "[2J\c" + printf "[2J" +} + +Cursor_erase_EOL () +{ + #echo -e "[K\c" + printf "[K" +} diff --git a/functions/defaults.sh b/functions/defaults.sh new file mode 100755 index 000000000..57cf37c20 --- /dev/null +++ b/functions/defaults.sh @@ -0,0 +1,1233 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Set_defaults () +{ + ## config/common + + LB_BASE="${LB_BASE:-/usr/share/live/build}" + + # Setting mode + if [ -z "${LB_MODE}" ] + then + LB_MODE="debian" + fi + + # Setting distribution name + if [ -z "${LB_DISTRIBUTION}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_DISTRIBUTION="squeeze" + ;; + + emdebian) + LB_DISTRIBUTION="sid" + ;; + + ubuntu) + LB_DISTRIBUTION="karmic" + ;; + esac + fi + + # Setting package manager + LB_APT="${LB_APT:-apt}" + + # Setting apt ftp proxy + if [ -z "${LB_APT_FTP_PROXY}" ] && [ -n "${ftp_proxy}" ] + then + LB_APT_FTP_PROXY="${ftp_proxy}" + else + if [ -n "${LB_APT_FTP_PROXY}" ] && [ "${LB_APT_FTP_PROXY}" != "${ftp_proxy}" ] + then + ftp_proxy="${LB_APT_FTP_PROXY}" + fi + fi + + # Setting apt http proxy + if [ -z "${LB_APT_HTTP_PROXY}" ] && [ -n "${http_proxy}" ] + then + LB_APT_HTTP_PROXY="${http_proxy}" + else + if [ -n "${LB_APT_HTTP_PROXY}" ] && [ "${LB_APT_HTT_PROXY}" != "${http_proxy}" ] + then + http_proxy="${LB_APT_HTTP_PROXY}" + fi + fi + + # Setting apt pdiffs + LB_APT_PDIFFS="${LB_APT_PDIFFS:-true}" + + # Setting apt pipeline + # LB_APT_PIPELINE + + APT_OPTIONS="${APT_OPTIONS:---yes}" + APTITUDE_OPTIONS="${APTITUDE_OPTIONS:---assume-yes}" + + GZIP_OPTIONS="${GZIP_OPTIONS:---best}" + + if gzip --help | grep -qs "\-\-rsyncable" + then + GZIP_OPTIONS="$(echo ${GZIP_OPTIONS} | sed -e 's|--rsyncable||') --rsyncable" + fi + + # Setting apt recommends + case "${LB_MODE}" in + debian|debian-release|ubuntu) + LB_APT_RECOMMENDS="${LB_APT_RECOMMENDS:-true}" + ;; + + emdebian) + LB_APT_RECOMMENDS="${LB_APT_RECOMMENDS:-false}" + ;; + esac + + # Setting apt secure + LB_APT_SECURE="${LB_APT_SECURE:-true}" + + # Setting bootstrap program + if [ -z "${LB_BOOTSTRAP}" ] || ( [ ! -x "$(which ${LB_BOOTSTRAP} 2>/dev/null)" ] && [ "${LB_BOOTSTRAP}" != "copy" ] ) + then + if [ -x "/usr/sbin/debootstrap" ] + then + LB_BOOTSTRAP="debootstrap" + elif [ -x "/usr/bin/cdebootstrap" ] + then + LB_BOOTSTRAP="cdebootstrap" + else + Echo_error "Cannot find /usr/sbin/debootstrap or /usr/bin/cdebootstrap. Please install debootstrap or cdebootstrap, or specify an alternative bootstrapping utility." + exit 1 + fi + fi + + # Setting cache option + LB_CACHE="${LB_CACHE:-true}" + LB_CACHE_INDICES="${LB_CACHE_INDICES:-false}" + LB_CACHE_PACKAGES="${LB_CACHE_PACKAGES:-true}" + LB_CACHE_STAGES="${LB_CACHE_STAGES:-bootstrap}" + + # Setting debconf frontend + LB_DEBCONF_FRONTEND="${LB_DEBCONF_FRONTEND:-noninteractive}" + LB_DEBCONF_NOWARNINGS="${LB_DEBCONF_NOWARNINGS:-yes}" + LB_DEBCONF_PRIORITY="${LB_DEBCONF_PRIORITY:-critical}" + + case "${LB_DEBCONF_NOWARNINGS}" in + true) + LB_DEBCONF_NOWARNINGS="yes" + ;; + + false) + LB_DEBCONF_NOWARNINGS="no" + ;; + esac + + # Setting initramfs hook + if [ -z "${LB_INITRAMFS}" ] + then + LB_INITRAMFS="auto" + else + if [ "${LB_INITRAMFS}" = "auto" ] + then + case "${LB_MODE}" in + ubuntu) + LB_INITRAMFS="casper" + ;; + + *) + case "${LB_DISTRIBUTION}" in + wheezy) + LB_INITRAMFS="live-boot" + ;; + + *) + LB_INITRAMFS="live-initramfs" + ;; + esac + ;; + esac + fi + fi + + # Setting fdisk + if [ -z "${LB_FDISK}" ] || [ ! -x "${LB_FDISK}" ] + then + # Workaround for gnu-fdisk divertion + # (gnu-fdisk is buggy, #445304). + if [ -x /sbin/fdisk.distrib ] + then + LB_FDISK="fdisk.distrib" + elif [ -x /sbin/fdisk ] + then + LB_FDISK="fdisk" + else + Echo_error "Can't process file /sbin/fdisk" + fi + fi + + # Setting losetup + if [ -z "${LB_LOSETUP}" ] || [ "${LB_LOSETUP}" != "/sbin/losetup.orig" ] + then + # Workaround for loop-aes-utils divertion + # (loop-aes-utils' losetup lacks features). + if [ -x /sbin/losetup.orig ] + then + LB_LOSETUP="losetup.orig" + elif [ -x /sbin/losetup ] + then + LB_LOSETUP="losetup" + else + Echo_error "Can't process file /sbin/losetup" + fi + fi + + if [ "$(id -u)" = "0" ] + then + # If we are root, disable root command + LB_ROOT_COMMAND="" + else + if [ -x /usr/bin/sudo ] + then + # FIXME: this is false until considered safe + #LB_ROOT_COMMAND="sudo" + LB_ROOT_COMMAND="" + fi + fi + + # Setting tasksel + LB_TASKSEL="${LB_TASKSEL:-tasksel}" + + # Setting root directory + if [ -z "${LB_ROOT}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_ROOT="debian-live" + ;; + + emdebian) + LB_ROOT="emdebian-live" + ;; + + ubuntu) + LB_ROOT="ubuntu-live" + ;; + esac + fi + + # Setting includes + if [ -z "${LB_INCLUDES}" ] + then + LB_INCLUDES="${LB_BASE}/includes" + fi + + # Setting templates + if [ -z "${LB_TEMPLATES}" ] + then + LB_TEMPLATES="${LB_BASE}/templates" + fi + + # Setting live build options + _BREAKPOINTS="${_BREAKPOINTS:-false}" + _COLOR="${_COLOR:-false}" + _DEBUG="${_DEBUG:-false}" + _FORCE="${_FORCE:-false}" + _QUIET="${_QUIET:-false}" + _VERBOSE="${_VERBOSE:-false}" + + ## config/bootstrap + + # Setting architecture value + if [ -z "${LB_ARCHITECTURE}" ] + then + if [ -x "/usr/bin/dpkg" ] + then + LB_ARCHITECTURE="$(dpkg --print-architecture)" + else + case "$(uname -m)" in + sparc|powerpc) + LB_ARCHITECTURE="$(uname -m)" + ;; + x86_64) + LB_ARCHITECTURE="amd64" + ;; + *) + Echo_warning "Can't determine architecture, assuming i386" + LB_ARCHITECTURE="i386" + ;; + esac + fi + fi + + # Include packages on base + # LB_BOOTSTRAP_INCLUDE + + # Exclude packages on base + # LB_BOOTSTRAP_EXCLUDE + + # Setting distribution configuration value + # LB_BOOTSTRAP_CONFIG + + # Setting flavour value + case "${LB_BOOTSTRAP}" in + cdebootstrap) + LB_BOOTSTRAP_FLAVOUR="${LB_BOOTSTRAP_FLAVOUR:-standard}" + ;; + esac + + # Setting bootstrap keyring + # LB_BOOTSTRAP_KEYRING + + # Setting mirror to fetch packages from + if [ -z "${LB_MIRROR_BOOTSTRAP}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_MIRROR_BOOTSTRAP="http://ftp.de.debian.org/debian/" + ;; + + emdebian) + LB_MIRROR_BOOTSTRAP="http://buildd.emdebian.org/grip/" + ;; + + ubuntu) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_MIRROR_BOOTSTRAP="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LB_MIRROR_BOOTSTRAP="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + LB_MIRROR_CHROOT="${LB_MIRROR_CHROOT:-${LB_MIRROR_BOOTSTRAP}}" + + # Setting security mirror to fetch packages from + if [ -z "${LB_MIRROR_CHROOT_SECURITY}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_MIRROR_CHROOT_SECURITY="http://security.debian.org/" + ;; + + emdebian) + LB_MIRROR_CHROOT_SECURITY="none" + ;; + + ubuntu) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_MIRROR_CHROOT_SECURITY="http://security.ubuntu.com/ubuntu/" + ;; + + *) + LB_MIRROR_CHROOT_SECURITY="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + # Setting volatile mirror to fetch packages from + if [ -z "${LB_MIRROR_CHROOT_VOLATILE}" ] + then + case "${LB_MODE}" in + debian|debian-release) + case "${LB_DISTRIBUTION}" in + lenny) + LB_MIRROR_CHROOT_VOLATILE="http://volatile.debian.org/debian-volatile/" + ;; + esac + ;; + + ubuntu) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_MIRROR_CHROOT_VOLATILE="http://security.ubuntu.com/ubuntu/" + ;; + + *) + LB_MIRROR_CHROOT_VOLATILE="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + + LB_MIRROR_CHROOT_VOLATILE="${LB_MIRROR_CHROOT_VOLATILE:-none}" + fi + + # Setting backports mirror to fetch packages from + if [ -z "${LB_MIRROR_CHROOT_BACKPORTS}" ] + then + case "${LB_MODE}" in + debian|debian-release) + case "${LB_DISTRIBUTION}" in + lenny|squeeze) + LB_MIRROR_CHROOT_BACKPORTS="http://backports.debian.org/debian-backports/" + ;; + esac + ;; + esac + + LB_MIRROR_CHROOT_BACKPORTS="${LB_MIRROR_CHROOT_BACKPORTS:-none}" + fi + + # Setting mirror which ends up in the image + if [ -z "${LB_MIRROR_BINARY}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_MIRROR_BINARY="http://cdn.debian.net/debian/" + ;; + + emdebian) + LB_MIRROR_BINARY="http://buildd.emdebian.org/grip/" + ;; + + ubuntu) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_MIRROR_BINARY="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LB_MIRROR_BINARY="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + # Setting security mirror which ends up in the image + if [ -z "${LB_MIRROR_BINARY_SECURITY}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_MIRROR_BINARY_SECURITY="http://security.debian.org/" + ;; + + emdebian) + LB_MIRROR_BINARY_SECURITY="none" + ;; + + ubuntu) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_MIRROR_BINARY_SECURITY="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LB_MIRROR_BINARY_SECURITY="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + # Setting volatile mirror which ends up in the image + if [ -z "${LB_MIRROR_BINARY_VOLATILE}" ] + then + case "${LB_MODE}" in + debian|debian-release) + case "${LB_DISTRIBUTION}" in + lenny) + LB_MIRROR_BINARY_VOLATILE="http://volatile.debian.org/debian-volatile/" + ;; + esac + ;; + + ubuntu) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_MIRROR_BINARY_VOLATILE="http://security.ubuntu.com/ubuntu/" + ;; + + *) + LB_MIRROR_BINARY_VOLATILE="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + + LB_MIRROR_BINARY_VOLATILE="${LB_MIRROR_BINARY_VOLATILE:-none}" + fi + + # Setting backports mirror which ends up in the image + if [ -z "${LB_MIRROR_BINARY_BACKPORTS}" ] + then + case "${LB_MODE}" in + debian|debian-release) + case "${LB_DISTRIBUTION}" in + lenny|squeeze) + LB_MIRROR_BINARY_BACKPORTS="http://backports.debian.org/debian-backports/" + ;; + esac + ;; + esac + + LB_MIRROR_BINARY_BACKPORTS="${LB_MIRROR_BINARY_BACKPORTS:-none}" + fi + + LB_MIRROR_DEBIAN_INSTALLER="${LB_MIRROR_DEBIAN_INSTALLER:-${LB_MIRROR_BOOTSTRAP}}" + + # Setting archive areas value + if [ -z "${LB_ARCHIVE_AREAS}" ] + then + case "${LB_MODE}" in + ubuntu) + LB_ARCHIVE_AREAS="main restricted" + ;; + + *) + LB_ARCHIVE_AREAS="main" + ;; + esac + fi + + ## config/chroot + + # Setting chroot filesystem + LB_CHROOT_FILESYSTEM="${LB_CHROOT_FILESYSTEM:-squashfs}" + + # Setting virtual root size + LB_VIRTUAL_ROOT_SIZE="${LB_VIRTUAL_ROOT_SIZE:-10000}" + + # Setting whether to expose root filesystem as read only + LB_EXPOSED_ROOT="${LB_EXPOSED_ROOT:-false}" + + # Setting union filesystem + LB_UNION_FILESYSTEM="${LB_UNION_FILESYSTEM:-aufs}" + + # LB_HOOKS + + # Setting interactive shell/X11/Xnest + LB_INTERACTIVE="${LB_INTERACTIVE:-false}" + + # Setting keyring packages + case "${LB_MODE}" in + debian|debian-release) + LB_KEYRING_PACKAGES="${LB_KEYRING_PACKAGES:-debian-archive-keyring}" + ;; + + emdebian) + LB_KEYRING_PACKAGES="${LB_KEYRING_PACKAGES:-debian-archive-keyring}" + ;; + + ubuntu) + LB_KEYRING_PACKAGES="${LB_KEYRING_PACKAGES:-ubuntu-keyring}" + ;; + esac + + # Setting language string + LB_LANGUAGE="${LB_LANGUAGE:-en}" + + # Setting linux flavour string + if [ -z "${LB_LINUX_FLAVOURS}" ] + then + case "${LB_ARCHITECTURE}" in + arm|armel) + Echo_error "There is no default kernel flavour defined for your architecture." + Echo_error "Please configure it manually with 'lb config -k FLAVOUR'." + exit 1 + ;; + + alpha) + case "${LB_MODE}" in + ubuntu) + Echo_error "Architecture ${LB_ARCHITECTURE} not supported on Ubuntu." + exit 1 + ;; + + *) + LB_LINUX_FLAVOURS="alpha-generic" + ;; + esac + ;; + + amd64) + case "${LB_MODE}" in + ubuntu) + LB_LINUX_FLAVOURS="generic" + ;; + + *) + LB_LINUX_FLAVOURS="amd64" + ;; + esac + ;; + + hppa) + case "${LB_MODE}" in + ubuntu) + LB_LINUX_FLAVOURS="hppa32 hppa64" + ;; + + *) + LB_LINUX_FLAVOURS="parisc" + ;; + esac + ;; + + i386) + case "${LB_MODE}" in + ubuntu) + LB_LINUX_FLAVOURS="generic" + ;; + + *) + case "${LIST}" in + stripped|minimal) + LB_LINUX_FLAVOURS="486" + ;; + + *) + LB_LINUX_FLAVOURS="486 686" + ;; + esac + ;; + esac + ;; + + ia64) + LB_LINUX_FLAVOURS="itanium" + ;; + + powerpc) + case "${LIST}" in + stripped|minimal) + LB_LINUX_FLAVOURS="powerpc" + ;; + + *) + LB_LINUX_FLAVOURS="powerpc powerpc64" + ;; + esac + ;; + + s390) + case "${LB_MODE}" in + ubuntu) + Echo_error "Architecture ${LB_ARCHITECTURE} not supported on Ubuntu." + exit 1 + ;; + + *) + LB_LINUX_FLAVOURS="s390" + ;; + esac + ;; + + sparc) + LB_LINUX_FLAVOURS="sparc64" + ;; + + *) + Echo_error "Architecture ${LB_ARCHITECTURE} not yet supported (FIXME)" + exit 1 + ;; + esac + fi + + # Set linux packages + if [ -z "${LB_LINUX_PACKAGES}" ] + then + case "${LB_MODE}" in + debian|debian-release|embedian) + case "${LB_DISTRIBUTION}" in + lenny) + LB_LINUX_PACKAGES="linux-image-2.6 \${LB_UNION_FILESYSTEM}-modules-2.6" + ;; + + *) + LB_LINUX_PACKAGES="linux-image-2.6" + ;; + esac + + if [ "${LB_CHROOT_FILESYSTEM}" = "squashfs" ] + then + case "${LB_DISTRIBUTION}" in + lenny) + LB_LINUX_PACKAGES="${LB_LINUX_PACKAGES} squashfs-modules-2.6" + ;; + esac + fi + + case "${LB_ENCRYPTION}" in + ""|false) + + ;; + + *) + LB_LINUX_PACKAGES="${LB_LINUX_PACKAGES} loop-aes-modules-2.6" + ;; + esac + ;; + + ubuntu) + LB_LINUX_PACKAGES="linux" + ;; + esac + fi + + # Setting packages string + case "${LB_MODE}" in + ubuntu) + LB_PACKAGES="${LB_PACKAGES:-ubuntu-minimal}" + ;; + + *) + LB_PACKAGES_LISTS="${LB_PACKAGES_LISTS:-standard}" + ;; + esac + + case "${LB_ENCRYPTION}" in + ""|false) + + ;; + + *) + if ! In_list loop-aes-utils "${LB_PACKAGES}" + then + LB_PACKAGES="${LB_PACKAGES} loop-aes-utils" + fi + ;; + esac + + # Setting tasks string + for LIST in ${LB_PACKAGES_LISTS} + do + case "${LIST}" in + stripped|minimal) + LB_APT="apt-get" + ;; + + gnome-desktop) + LB_PACKAGES_LISTS="$(echo ${LB_PACKAGES_LISTS} | sed -e 's|gnome-desktop||') standard-x11" + case "${LB_DISTRIBUTION}" in + lenny) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|gnome-desktop||' -e 's|desktop||') standard gnome-desktop desktop" + ;; + + *) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|gnome-desktop||' -e 's|desktop||' -e 's|laptop||') standard gnome-desktop desktop laptop" + ;; + esac + ;; + + kde-desktop) + LB_PACKAGES_LISTS="$(echo ${LB_PACKAGES_LISTS} | sed -e 's|kde-desktop||') standard-x11" + + case "${LB_DISTRIBUTION}" in + lenny) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|kde-desktop||' -e 's|desktop||') standard kde-desktop desktop" + ;; + + *) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|kde-desktop||' -e 's|desktop||' -e 's|laptop||') standard kde-desktop desktop laptop" + esac + ;; + + lxde-desktop) + LB_PACKAGES_LISTS="$(echo ${LB_PACKAGES_LISTS} | sed -e 's|lxde-desktop||') standard-x11" + + case "${LB_DISTRIBUTION}" in + lenny) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|lxde-desktop||' -e 's|desktop||') standard lxde-desktop desktop" + ;; + + *) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|lxde-desktop||' -e 's|desktop||' -e 's|laptop||') standard lxde-desktop desktop laptop" + ;; + esac + ;; + + xfce-desktop) + LB_PACKAGES_LISTS="$(echo ${LB_PACKAGES_LISTS} | sed -e 's|xfce-desktop||') standard-x11" + + case "${LB_DISTRIBUTION}" in + lenny) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|xfce-desktop||' -e 's|desktop||') standard xfce-desktop desktop" + ;; + + *) + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's|standard||' -e 's|xfce-desktop||' -e 's|desktop||' -e 's|laptop||') standard xfce-desktop desktop laptop" + ;; + esac + ;; + esac + done + + LB_PACKAGES_LISTS="$(echo ${LB_PACKAGES_LISTS} | sed -e 's| ||g')" + LB_TASKS="$(echo ${LB_TASKS} | sed -e 's| ||g')" + + # Setting security updates option + if [ "${LB_MIRROR_CHROOT_SECURITY}" = "none" ] || [ "${LB_MIRROR_BINARY_SECURITY}" = "none" ] + then + LB_SECURITY="false" + fi + + LB_SECURITY="${LB_SECURITY:-true}" + + # Setting volatile updates option + if [ "${LB_MIRROR_CHROOT_VOLATILE}" = "none" ] || [ "${LB_MIRROR_BINARY_VOLATILE}" = "none" ] + then + LB_VOLATILE="false" + fi + + LB_VOLATILE="${LB_VOLATILE:-true}" + + # Setting symlink convertion option + LB_SYMLINKS="${LB_SYMLINKS:-false}" + + # Setting sysvinit option + LB_SYSVINIT="${LB_SYSVINIT:-false}" + + ## config/binary + + # Setting image filesystem + case "${LB_ARCHITECTURE}" in + sparc) + LB_BINARY_FILESYSTEM="${LB_BINARY_FILESYSTEM:-ext2}" + ;; + + *) + LB_BINARY_FILESYSTEM="${LB_BINARY_FILESYSTEM:-fat16}" + ;; + esac + + # Setting image type + case "${LB_DISTRIBUTION}" in + squeeze|sid) + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_BINARY_IMAGES="${LB_BINARY_IMAGES:-iso-hybrid}" + ;; + + *) + LB_BINARY_IMAGES="${LB_BINARY_IMAGES:-iso}" + ;; + esac + ;; + + *) + LB_BINARY_IMAGES="${LB_BINARY_IMAGES:-iso}" + ;; + esac + + # Setting apt indices + if echo ${LB_PACKAGES_LISTS} | grep -qs -E "(stripped|minimal)\b" + then + LB_BINARY_INDICES="${LB_BINARY_INDICES:-none}" + else + LB_BINARY_INDICES="${LB_BINARY_INDICES:-true}" + fi + + # Setting bootloader + if [ -z "${LB_BOOTLOADER}" ] + then + case "${LB_ARCHITECTURE}" in + amd64|i386) + LB_BOOTLOADER="syslinux" + ;; + + powerpc) + LB_BOOTLOADER="yaboot" + ;; + + sparc) + LB_BOOTLOADER="silo" + ;; + esac + fi + + # Setting checksums + LB_CHECKSUMS="${LB_CHECKSUMS:-md5}" + + # Setting chroot option + LB_BUILD_WITH_CHROOT="${LB_BUILD_WITH_CHROOT:-true}" + + # Setting debian-installer option + LB_DEBIAN_INSTALLER="${LB_DEBIAN_INSTALLER:-false}" + + # Setting debian-installer distribution + LB_DEBIAN_INSTALLER_DISTRIBUTION="${LB_DEBIAN_INSTALLER_DISTRIBUTION:-${LB_DISTRIBUTION}}" + + # Setting debian-installer-gui + case "${LB_MODE}" in + debian) + case "${LB_DISTRIBUTION}" in + squeeze|sid) + LB_DEBIAN_INSTALLER_GUI="${LB_DEBIAN_INSTALLER_GUI:-false}" + ;; + + *) + LB_DEBIAN_INSTALLER_GUI="${LB_DEBIAN_INSTALLER_GUI:-true}" + ;; + esac + ;; + + ubuntu) + case "${LB_DEBIAN_INSTALLER_DISTRIBUTION}" in + karmic) + # Not available for Karmic currently. + LB_DEBIAN_INSTALLER_GUI="${LB_DEBIAN_INSTALLER_GUI:-false}" + ;; + + *) + LB_DEBIAN_INSTALLER_GUI="${LB_DEBIAN_INSTALLER_GUI:-true}" + ;; + esac + ;; + + *) + LB_DEBIAN_INSTALLER_GUI="${LB_DEBIAN_INSTALLER_GUI:-false}" + ;; + esac + + # Setting debian-installer preseed filename + if [ -z "${LB_DEBIAN_INSTALLER_PRESEEDFILE}" ] + then + if Find_files config/binary_debian-installer/preseed.cfg + then + LB_DEBIAN_INSTALLER_PRESEEDFILE="/preseed.cfg" + fi + + if Find_files config/binary_debian-installer/*.cfg && [ ! -e config/binary_debian-installer/preseed.cfg ] + then + Echo_warning "You have placed some preseeding files into config/binary_debian-installer but you didn't specify the default preseeding file through LB_DEBIAN_INSTALLER_PRESEEDFILE. This means that debian-installer will not take up a preseeding file by default." + fi + fi + + # Setting boot parameters + # LB_BOOTAPPEND_LIVE + if [ -n "${LB_DEBIAN_INSTALLER_PRESEEDFILE}" ] + then + case "${LB_BINARY_IMAGES}" in + iso*) + _LB_BOOTAPPEND_PRESEED="file=/cdrom/install/${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + + usb*) + if [ "${LB_MODE}" = "ubuntu" ] || [ "${LB_DEBIAN_INSTALLER}" = "live" ] + then + _LB_BOOTAPPEND_PRESEED="file=/cdrom/install/${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + else + _LB_BOOTAPPEND_PRESEED="file=/hd-media/install/${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + fi + ;; + + net) + case "${LB_DEBIAN_INSTALLER_PRESEEDFILE}" in + *://*) + _LB_BOOTAPPEND_PRESEED="file=${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + + *) + _LB_BOOTAPPEND_PRESEED="file=/${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + esac + ;; + esac + fi + + case "${LB_BINARY_IMAGES}" in + iso-hybrid|usb*) + # Try USB block devices for install media + if ! echo "${LB_BOOTAPPEND_INSTALL}" | grep -q try-usb + then + LB_BOOTAPPEND_INSTALL="cdrom-detect/try-usb=true ${LB_BOOTAPPEND_INSTALL}" + fi + ;; + esac + + if [ -n ${_LB_BOOTAPPEND_PRESEED} ] + then + LB_BOOTAPPEND_INSTALL="${LB_BOOTAPPEND_INSTALL} ${_LB_BOOTAPPEND_PRESEED}" + fi + + LB_BOOTAPPEND_INSTALL="$(echo ${LB_BOOTAPPEND_INSTALL} | sed -e 's/[ \t]*$//')" + + # Setting encryption + LB_ENCRYPTION="${LB_ENCRYPTION:-false}" + + # Setting grub splash + # LB_GRUB_SPLASH + + # Setting hostname + if [ -z "${LB_HOSTNAME}" ] + then + case "${LB_MODE}" in + embedian) + LB_HOSTNAME="embedian" + ;; + + ubuntu) + LB_HOSTNAME="ubuntu" + ;; + + *) + LB_HOSTNAME="debian" + ;; + esac + fi + + # Setting iso author + if [ -z "${LB_ISO_APPLICATION}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_ISO_APPLICATION="Debian Live" + ;; + + emdebian) + LB_ISO_APPLICATION="Emdebian Live" + ;; + + ubuntu) + LB_ISO_APPLICATION="Ubuntu Live" + ;; + esac + fi + + # Set iso preparer + LB_ISO_PREPARER="${LB_ISO_PREPARER:-live-build \$VERSION; http://packages.qa.debian.org/live-build}" + + # Set iso publisher + LB_ISO_PUBLISHER="${LB_ISO_PUBLISHER:-Debian Live project; http://live.debian.net/; debian-live@lists.debian.org}" + + # Setting iso volume + if [ -z "${LB_ISO_VOLUME}" ] + then + case "${LB_MODE}" in + debian) + LB_ISO_VOLUME="Debian ${LB_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)" + ;; + + debian-release) + eval VERSION="$`echo RELEASE_${LB_DISTRIBUTION}`" + LB_ISO_VOLUME="Debian ${VERSION} ${LB_ARCHITECTURE} live" + ;; + + emdebian) + LB_ISO_VOLUME="Emdebian ${LB_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)" + ;; + + ubuntu) + LB_ISO_VOLUME="Ubuntu ${LB_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)" + ;; + esac + fi + + # Setting memtest option + LB_MEMTEST="${LB_MEMTEST:-memtest86+}" + + # Setting win32-loader option + if [ "${LB_MODE}" != "ubuntu" ] + then + case "${LB_ARCHITECTURE}" in + amd64|i386) + if [ "${LB_DEBIAN_INSTALLER}" != "false" ] + then + LB_WIN32_LOADER="${LB_WIN32_LOADER:-true}" + else + LB_WIN32_LOADER="${LB_WIN32_LOADER:-false}" + fi + ;; + + *) + LB_WIN32_LOADER="${LB_WIN32_LOADER:-false}" + ;; + esac + fi + + # Setting netboot filesystem + LB_NET_ROOT_FILESYSTEM="${LB_NET_ROOT_FILESYSTEM:-nfs}" + + # Setting netboot server path + if [ -z "${LB_NET_ROOT_PATH}" ] + then + case "${LB_MODE}" in + debian|debian-release) + LB_NET_ROOT_PATH="/srv/debian-live" + ;; + + emdebian) + LB_NET_ROOT_PATH="/srv/emdebian-live" + ;; + + ubuntu) + LB_NET_ROOT_PATH="/srv/ubuntu-live" + ;; + esac + fi + + # Setting netboot server address + LB_NET_ROOT_SERVER="${LB_NET_ROOT_SERVER:-192.168.1.1}" + + # Setting net cow filesystem + LB_NET_COW_FILESYSTEM="${LB_NET_COW_FILESYSTEM:-nfs}" + + # Setting net tarball + LB_NET_TARBALL="${LB_NET_TARBALL:-gzip}" + + # Setting syslinux configuration file + # LB_SYSLINUX_CFG + + # Setting syslinux splash + # LB_SYSLINUX_SPLASH + + LB_SYSLINUX_TIMEOUT="${LB_SYSLINUX_TIMEOUT:-0}" + + # Setting syslinux menu + LB_SYSLINUX_MENU="${LB_SYSLINUX_MENU:-true}" + + # Setting syslinux menu live entries + case "${LB_MODE}" in + debian|debian-release) + LB_SYSLINUX_MENU_LIVE_ENTRY="${LB_SYSLINUX_MENU_LIVE_ENTRY:-Live}" + LB_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE="${LB_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE:-${LB_SYSLINUX_MENU_LIVE_ENTRY} (failsafe)}" + ;; + + *) + LB_SYSLINUX_MENU_LIVE_ENTRY="${LB_SYSLINUX_MENU_LIVE_ENTRY:-Start ${LB_ISO_APPLICATION}}" + LB_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE="${LB_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE:-${LB_SYSLINUX_MENU_LIVE_ENTRY} (failsafe)}" + ;; + esac + + # Settings memtest menu entry + LB_SYSLINUX_MENU_MEMTEST_ENTRY="${LB_SYSLINUX_MENU_MEMTEST_ENTRY:-Memory test}" + + # Setting username + case "${LB_MODE}" in + ubuntu) + LB_USERNAME="${LB_USERNAME:-ubuntu}" + ;; + + *) + LB_USERNAME="${LB_USERNAME:-user}" + ;; + esac + + ## config/source + + # Setting source option + LB_SOURCE="${LB_SOURCE:-false}" + + # Setting image type + LB_SOURCE_IMAGES="${LB_SOURCE_IMAGES:-tar}" + + # Setting fakeroot/fakechroot + LB_USE_FAKEROOT="${LB_USE_FAKEROOT:-false}" +} + +Check_defaults () +{ + if [ "${LB_CONFIG_VERSION}" ] + then + # We're only checking when we're actually running the checks + # that's why the check for emptyness of the version; + # however, as live-build always declares LB_CONFIG_VERSION + # internally, this is safe assumption (no cases where it's unset, + # except when bootstrapping the functions/defaults etc.). + CURRENT_CONFIG_VERSION="$(echo ${LB_CONFIG_VERSION} | awk -F. '{ print $1 }')" + + if [ ${CURRENT_CONFIG_VERSION} -ge 3 ] + then + Echo_error "This config tree is too new for this version of live-build (${VERSION})." + Echo_error "Aborting build, please get a new version of live-build." + + exit 1 + elif [ ${CURRENT_CONFIG_VERSION} -eq 1 ] + then + Echo_error "This config tree is too old for this version of live-build (${VERSION})." + Echo_error "Aborting build, please repopulate the config tree." + exit 1 + elif [ ${CURRENT_CONFIG_VERSION} -lt 1 ] + then + Echo_warning "This config tree does not specify a format version or has an unknown version number." + Echo_warning "Continuing build, but it could lead to errors or different results. Please repopulate the config tree." + fi + fi + + if echo ${LB_PACKAGES_LISTS} | grep -qs -E "(stripped|minimal)\b" + then + # aptitude + stripped|minimal + if [ "${LB_APT}" = "aptitude" ] + then + Echo_warning "You selected LB_PACKAGES_LISTS='%s' and LB_APT='aptitude'" "${LB_PACKAGES_LIST}. This configuration is potentially unsafe, as aptitude is not used in the stripped/minimal package lists." + fi + fi + + if [ "${LB_DEBIAN_INSTALLER}" != "false" ] + then + # d-i true, no caching + if ! echo ${LB_CACHE_STAGES} | grep -qs "bootstrap\b" || [ "${LB_CACHE}" != "true" ] || [ "${LB_CACHE_PACKAGES}" != "true" ] + then + Echo_warning "You have selected values of LB_CACHE, LB_CACHE_PACKAGES, LB_CACHE_STAGES and LB_DEBIAN_INSTALLER which will result in 'bootstrap' packages not being cached. This configuration is potentially unsafe as the bootstrap packages are re-used when integrating the Debian Installer." + fi + fi + + if [ "${LB_BOOTLOADER}" = "syslinux" ] + then + # syslinux + fat + case "${LB_BINARY_FILESYSTEM}" in + fat*) + ;; + *) + Echo_warning "You have selected values of LB_BOOTLOADER and LB_BINARY_FILESYSTEM which are incompatible - syslinux only supports FAT filesystems." + ;; + esac + fi + + case "${LB_BINARY_IMAGES}" in + usb*) + # grub or yaboot + usb + case "${LB_BOOTLOADER}" in + grub|yaboot) + Echo_error "You have selected a combination of bootloader and image type that is currently not supported by live-build. Please use either another bootloader or a different image type." + exit 1 + ;; + esac + ;; + esac + + if [ "$(echo ${LB_ISO_APPLICATION} | wc -c)" -gt 128 ] + then + Echo_warning "You have specified a value of LB_ISO_APPLICATION that is too long; the maximum length is 128 characters." + fi + + if [ "$(echo ${LB_ISO_PREPARER} | wc -c)" -gt 128 ] + then + Echo_warning "You have specified a value of LB_ISO_PREPARER that is too long; the maximum length is 128 characters." + fi + + if [ "$(echo ${LB_ISO_PUBLISHER} | wc -c)" -gt 128 ] + then + Echo_warning "You have specified a value of LB_ISO_PUBLISHER that is too long; the maximum length is 128 characters." + fi + + if [ "$(eval "echo ${LB_ISO_VOLUME}" | wc -c)" -gt 32 ] + then + Echo_warning "You have specified a value of LB_ISO_VOLUME that is too long; the maximum length is 32 characters." + fi + + if echo ${LB_PACKAGES_LISTS} | grep -qs -E "(stripped|minimal)\b" + then + if [ "${LB_BINARY_INDICES}" = "true" ] + then + Echo_warning "You have selected hook to minimise image size but you are still including package indices with your value of LB_BINARY_INDICES." + fi + fi + +} diff --git a/functions/echo.sh b/functions/echo.sh new file mode 100755 index 000000000..555bc42bb --- /dev/null +++ b/functions/echo.sh @@ -0,0 +1,251 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Echo () +{ + STRING="${1}" + shift + + if [ "${_L10N}" = "false" ] + then + printf "${STRING}\n" "${@}" + else + printf "$(eval_gettext "${STRING}")" "${@}"; echo; + fi +} + +Echo_debug () +{ + if [ "${_DEBUG}" = "true" ] + then + STRING="${1}" + shift + + if [ "${_L10N}" = "false" ] + then + printf "D: ${STRING}\n" "${@}" + else + printf "D: $(eval_gettext "${STRING}")" "${@}"; echo; + fi + fi +} + +Echo_debug_running () +{ + if [ "${_DEBUG}" = "true" ] + then + STRING="${1}" + shift + + if [ "${_L10N}" = "false" ] + then + printf "D: ${STRING}" "${@}" + else + printf "D: $(eval_gettext "${STRING}")" "${@}" + fi + + if [ "${_COLOR}" = "false" ] + then + printf "..." + else + printf "... ${YELLOW}${BLINK}running${NO_COLOR}" + fi + fi +} + +Echo_error () +{ + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "E:" + else + printf "${RED}E${NO_COLOR}:" + fi + + if [ "${_L10N}" = "false" ] + then + printf " ${STRING}\n" "${@}" >&2 + else + (printf " $(eval_gettext "${STRING}")" "${@}"; echo;) >&2 + fi +} + +Echo_message () +{ + if [ "${_QUIET}" != "true" ] + then + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "P:" + else + printf "${WHITE}P${NO_COLOR}:" + fi + + if [ "${_L10N}" = "false" ] + then + printf " ${STRING}\n" "${@}" + else + printf " $(eval_gettext "${STRING}")" "${@}"; echo; + fi + fi +} + +Echo_message_running () +{ + if [ "${_QUIET}" != "true" ] + then + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "P:" + else + printf "${WHITE}P${NO_COLOR}:" + fi + + if [ "${_L10N}" = "false" ] + then + printf " ${STRING}" "${@}" + else + printf " $(eval_gettext "${STRING}")" "${@}"; + fi + + if [ "${_COLOR}" = "false" ] + then + printf "..." + else + printf "... ${YELLOW}${BLINK}running${NO_COLOR}" + fi + fi +} + +Echo_verbose () +{ + if [ "${_VERBOSE}" = "true" ] + then + STRING="${1}" + shift + + if [ "${_L10N}" = "false" ] + then + printf "I: ${STRING}\n" "${@}" + else + printf "I: $(eval_gettext "${STRING}")" "${@}"; echo; + fi + fi +} + +Echo_verbose_running () +{ + if [ "${_VERBOSE}" != "true" ] + then + STRING="${1}" + shift + + if [ "${_L10N}" = "false" ] + then + printf "I: ${STRING}" "${@}" + else + printf "I: $(eval_gettext "${STRING}")" "${@}"; + fi + + if [ "${_COLOR}" = "false" ] + then + printf "..." + else + printf "... ${YELLOW}${BLINK}running${NO_COLOR}" + fi + fi +} + +Echo_warning () +{ + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "W:" + else + printf "${YELLOW}W${NO_COLOR}:" + fi + + if [ "${_L10N}" = "false" ] + then + printf " ${STRING}\n" "${@}" + else + printf " $(eval_gettext "${STRING}")" "${@}"; echo; + fi +} + +Echo_status () +{ + __RETURN="${?}" + + if [ "${_COLOR}" = "false" ] + then + if [ "${__RETURN}" = "0" ] + then + printf " done.\n" + else + printf " failed.\n" + fi + else + Cursor_columns_backward 8 + + if [ "${__RETURN}" = "0" ] + then + printf " ${GREEN}done${NO_COLOR}. \n" + else + printf " ${RED}failed${NO_COLOR}.\n" + fi + fi +} + +Echo_done () +{ + if [ "${_COLOR}" = "false" ] + then + printf " already done.\n" + else + Cursor_columns_backward 8 + + printf " ${GREEN}already done${NO_COLOR}.\n" + fi +} + +Echo_file () +{ + while read LINE + do + echo "${1}: ${LINE}" + done < "${1}" +} + +Echo_breakage () +{ + case "${LB_DISTRIBUTION}" in + sid|unstable) + Echo_message "If the following stage fails, the most likely cause of the problem is with your mirror configuration, a caching proxy or the sid distribution." + ;; + *) + Echo_message "If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy." + ;; + esac + + Echo_message "${@}" +} diff --git a/functions/exit.sh b/functions/exit.sh new file mode 100755 index 000000000..5fa1fa86f --- /dev/null +++ b/functions/exit.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Exit () +{ + VALUE="${?}" + + if [ "${_DEBUG}" = "true" ] + then + # Dump variables + set | grep -e ^LH + fi + + # Always exit true in case we are not able to unmount + # (e.g. due to running processes in chroot from user customizations) + Echo_message "Begin unmounting filesystems..." + + if [ -e /proc/mounts ] + then + for DIRECTORY in $(awk -v dir="${PWD}/chroot/" '$2 ~ dir { print $2 }' /proc/mounts | sort -r) + do + umount ${DIRECTORY} > /dev/null 2>&1 || true + done + else + for DIRECTORY in /dev/shm /dev/pts /dev /proc /selinux /sys + do + umount -f chroot/${DIRECTORY} > /dev/null 2>&1 || true + done + fi + + return ${VALUE} +} + +Setup_cleanup () +{ + Echo_message "Setting up cleanup function" + trap 'Exit' EXIT HUP INT QUIT TERM +} diff --git a/functions/help.sh b/functions/help.sh new file mode 100755 index 000000000..86f7782ac --- /dev/null +++ b/functions/help.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Help () +{ + Echo "%s - %s" "${PROGRAM}" "${DESCRIPTION}" + echo + Echo "Usage:" + echo + + if [ -n "${USAGE}" ] + then + Echo "${USAGE}" + echo + fi + Echo " %s [-h|--help]" "${PROGRAM}" + Echo " %s [-u|--usage]" "${PROGRAM}" + Echo " %s [-v|--version]" "${PROGRAM}" + echo + + if [ -n "${HELP}" ] + then + Echo "${HELP}" + echo + fi + + Echo "Report bugs to Debian Live project <http://live.debian.net/>." + exit 0 +} diff --git a/functions/l10n.sh b/functions/l10n.sh new file mode 100755 index 000000000..d32106b69 --- /dev/null +++ b/functions/l10n.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +if [ -x "$(which gettext.sh 2>/dev/null)" ] && Find_files /usr/share/locale/*/LC_MESSAGES/${PACKAGE}.mo +then + _L10N="true" + + # gettext domain (.mo file name) + TEXTDOMAIN="${PACKAGE}" + export TEXTDOMAIN + + # locale dir for gettext codes + TEXTDOMAINDIR="/usr/share/locale" + export TEXTDOMAINDIR + + # load gettext functions + . gettext.sh +else + _L10N="false" +fi diff --git a/functions/lockfile.sh b/functions/lockfile.sh new file mode 100755 index 000000000..ea551743f --- /dev/null +++ b/functions/lockfile.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Check_lockfile () +{ + FILE="${1}" + + if [ -z "${FILE}" ] + then + FILE="/var/lock/${PROGRAM}.lock" + fi + + # Checking lock file + if [ -f "${FILE}" ] + then + Echo_error "${PROGRAM} locked" + exit 1 + fi +} + +Create_lockfile () +{ + FILE="${1}" + + if [ -z "${FILE}" ] + then + FILE="/var/lock/${PROGRAM}.lock" + fi + + DIRECTORY="$(dirname ${FILE})" + + # Creating lock directory + mkdir -p "${DIRECTORY}" + + # Creating lock trap + trap 'ret=${?}; '"rm -f \"${FILE}\";"' exit ${ret}' EXIT HUP INT QUIT TERM + + # Creating lock file + touch "${FILE}" +} diff --git a/functions/losetup.sh b/functions/losetup.sh new file mode 100755 index 000000000..fa6cd8373 --- /dev/null +++ b/functions/losetup.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Losetup () +{ + DEVICE="${1}" + FILE="${2}" + PARTITION="${3:-1}" + + ${LB_ROOT_COMMAND} ${LB_LOSETUP} "${DEVICE}" "${FILE}" + FDISK_OUT="$(${LB_FDISK} -l -u ${DEVICE} 2>&1)" + ${LB_ROOT_COMMAND} ${LB_LOSETUP} -d "${DEVICE}" + + LOOPDEVICE="$(echo ${DEVICE}p${PARTITION})" + + if [ "${PARTITION}" = "0" ] + then + Echo_message "Mounting %s with offset 0" "${DEVICE}" + + ${LB_ROOT_COMMAND} ${LB_LOSETUP} "${DEVICE}" "${FILE}" + else + SECTORS="$(echo "$FDISK_OUT" | sed -ne "s|^$LOOPDEVICE[ *]*\([0-9]*\).*|\1|p")" + OFFSET="$(expr ${SECTORS} '*' 512)" + + Echo_message "Mounting %s with offset %s" "${DEVICE}" "${OFFSET}" + + ${LB_ROOT_COMMAND} ${LB_LOSETUP} -o "${OFFSET}" "${DEVICE}" "${FILE}" + fi +} + +Calculate_partition_size () +{ + ORIGINAL_SIZE="${1}" + FILESYSTEM="${2}" + + case "${FILESYSTEM}" in + ext2|ext3) + PERCENT="5" + ;; + *) + PERCENT="3" + ;; + esac + + echo $(expr ${ORIGINAL_SIZE} + ${ORIGINAL_SIZE} \* ${PERCENT} / 100 + 1) +} diff --git a/functions/man.sh b/functions/man.sh new file mode 100755 index 000000000..672ed7bc3 --- /dev/null +++ b/functions/man.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Man () +{ + if [ -x "$(which man 2>/dev/null)" ] + then + man lh_$(basename ${0}) + exit 0 + fi +} diff --git a/functions/packages.sh b/functions/packages.sh new file mode 100755 index 000000000..20d53df61 --- /dev/null +++ b/functions/packages.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Check_package () +{ + FILE="${1}" + PACKAGE="${2}" + + Check_installed "${FILE}" "${PACKAGE}" + + case "${INSTALL_STATUS}" in + 1) + _LB_PACKAGES="${_LB_PACKAGES} ${PACKAGE}" + ;; + + 2) + Echo_error "You need to install %s on your host system." "${PACKAGE}" + exit 1 + ;; + esac +} + +Install_package () +{ + if [ -n "${_LB_PACKAGES}" ] && [ "${LB_BUILD_WITH_CHROOT}" != "false" ] + then + case "${LB_APT}" in + apt|apt-get) + Chroot chroot "apt-get install -o APT::Install-Recommends=false ${APT_OPTIONS} ${_LB_PACKAGES}" + ;; + + aptitude) + Chroot chroot "aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LB_PACKAGES}" + ;; + esac + fi +} + +Remove_package () +{ + if [ -n "${_LB_PACKAGES}" ] && [ "${LB_BUILD_WITH_CHROOT}" != "false" ] + then + case "${LB_APT}" in + apt|apt-get) + Chroot chroot "apt-get remove --purge ${APT_OPTIONS} ${_LB_PACKAGES}" + ;; + + aptitude) + Chroot chroot "aptitude purge ${APTITUDE_OPTIONS} ${_LB_PACKAGES}" + ;; + esac + fi +} + +# Check_installed +# uses as return value global var INSTALL_STATUS +# INSTALL_STATUS : 0 if package is installed +# 1 if package isn't installed and we're in an apt managed system +# 2 if package isn't installed and we aren't in an apt managed system +Check_installed () +{ + FILE="${1}" + PACKAGE="${2}" + + case "${LB_BUILD_WITH_CHROOT}" in + true) + if Chroot chroot "dpkg-query -s ${PACKAGE}" 2> /dev/null | grep -qs "Status: install" + then + INSTALL_STATUS=0 + else + INSTALL_STATUS=1 + fi + ;; + false) + if which dpkg-query > /dev/null 2>&1 + then + if Chroot chroot "dpkg-query -s ${PACKAGE}" 2> /dev/null | grep -qs "Status: install" + then + INSTALL_STATUS=0 + else + INSTALL_STATUS=1 + fi + else + FILE="$(echo ${FILE} | sed -e 's|chroot||')" + + if [ ! -e "${FILE}" ] + then + INSTALL_STATUS=2 + else + INSTALL_STATUS=0 + fi + fi + ;; + esac +} + diff --git a/functions/packageslists.sh b/functions/packageslists.sh new file mode 100755 index 000000000..94f016fbf --- /dev/null +++ b/functions/packageslists.sh @@ -0,0 +1,98 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Expand_packagelist () +{ + _LB_EXPAND_QUEUE="$(basename "${1}")" + + shift + + while [ -n "${_LB_EXPAND_QUEUE}" ] + do + _LB_LIST_NAME="$(echo ${_LB_EXPAND_QUEUE} | cut -d" " -f1)" + _LB_EXPAND_QUEUE="$(echo ${_LB_EXPAND_QUEUE} | cut -s -d" " -f2-)" + _LB_LIST_LOCATION="" + _LB_NESTED=0 + _LB_ENABLED=1 + + for _LB_SEARCH_PATH in ${@} config/lists "${LB_BASE:-/usr/share/live/build}/lists" + do + if [ -e "${_LB_SEARCH_PATH}/${_LB_LIST_NAME}" ] + then + _LB_LIST_LOCATION="${_LB_SEARCH_PATH}/${_LB_LIST_NAME}" + break + fi + done + + if [ -z "${_LB_LIST_LOCATION}" ] + then + echo "W: Unknown package list '${_LB_LIST_NAME}'" >&2 + continue + fi + + while read _LB_LINE + do + case "${_LB_LINE}" in + \#if\ *) + if [ ${_LB_NESTED} -eq 1 ] + then + echo "E: Nesting conditionals is not supported" >&2 + exit 1 + fi + _LB_NESTED=1 + + _LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)" + _LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")" + + _LB_ENABLED=0 + for _LB_NEEDLE_PART in ${_LB_NEEDLE} + do + for _LB_HAYSTACK_PART in ${_LB_HAYSTACK} + do + if [ "${_LB_NEEDLE_PART}" = "${_LB_HAYSTACK_PART}" ] + then + _LB_ENABLED=1 + fi + done + done + ;; + + \#endif*) + _LB_NESTED=0 + _LB_ENABLED=1 + ;; + + \#*) + if [ ${_LB_ENABLED} -ne 1 ] + then + continue + fi + + # Find includes + _LB_INCLUDES="$(echo "${_LB_LINE}" | sed -n \ + -e 's|^#<include> \([^ ]*\)|\1|gp' \ + -e 's|^#include <\([^ ]*\)>|\1|gp')" + + # Add to queue + _LB_EXPAND_QUEUE="$(echo ${_LB_EXPAND_QUEUE} ${_LB_INCLUDES} | + sed -e 's|[ ]*$||' -e 's|^[ ]*||')" + ;; + + *) + if [ ${_LB_ENABLED} -eq 1 ] + then + echo "${_LB_LINE}" + fi + ;; + + esac + done < "${_LB_LIST_LOCATION}" + done +} diff --git a/functions/releases.sh b/functions/releases.sh new file mode 100755 index 000000000..cb5fca77f --- /dev/null +++ b/functions/releases.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +# Debian releases +RELEASE_lenny="5.0.6" +RELEASE_squeeze="6.0.0" +RELEASE_wheezy="7" +RELEASE_sid="unstable" + +# Ubuntu releases +RELEASE_dapper="6.06" # LTS +RELEASE_hardy="8.04" # LTS +RELEASE_intrepid="8.10" +RELEASE_jaunty="9.04" +RELEASE_karmic="9.10" +RELEASE_lucid="10.04" # LTS +RELEASE_maverick="10.10" diff --git a/functions/stagefile.sh b/functions/stagefile.sh new file mode 100755 index 000000000..504b6234a --- /dev/null +++ b/functions/stagefile.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Check_stagefile () +{ + FILE="${1}" + NAME="$(basename ${1})" + + # Checking stage file + if [ -f "${FILE}" ] + then + if [ "${_FORCE}" != "true" ] + then + # Skipping execution + Echo_warning "skipping %s" "${NAME}" + exit 0 + else + # Forcing execution + Echo_message "forcing %s" "${NAME}" + rm -f "${FILE}" + fi + fi +} + +Create_stagefile () +{ + FILE="${1}" + DIRECTORY="$(dirname ${1})" + + # Creating stage directory + mkdir -p "${DIRECTORY}" + + # Creating stage file + touch "${FILE}" +} + +Require_stagefile () +{ + NAME="$(basename ${0})" + FILES="${@}" + NUMBER="$(echo ${@} | wc -w)" + + for FILE in ${FILES} + do + # Find at least one of the required stages + if [ -f ${FILE} ] + then + CONTINUE="true" + NAME="${NAME} $(basename ${FILE})" + fi + done + + if [ "${CONTINUE}" != "true" ] + then + if [ "${NUMBER}" -eq 1 ] + then + Echo_error "%s: %s missing" "${NAME}" "${FILE}" + else + Echo_error "%s: one of %s is missing" "${NAME}" "${FILES}" + fi + + exit 1 + fi +} diff --git a/functions/templates.sh b/functions/templates.sh new file mode 100755 index 000000000..d365ccda2 --- /dev/null +++ b/functions/templates.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Check_templates () +{ + PACKAGE="${1}" + + if [ -d "config/templates/${PACKAGE}" ] + then + TEMPLATES="config/templates/${PACKAGE}" + elif [ -d "${LB_TEMPLATES}/${PACKAGE}" ] + then + TEMPLATES="${LB_TEMPLATES}/${PACKAGE}" + else + Echo_error "%s templates not accessible in %s nor config/templates" "${PACKAGE}" "${LB_TEMPLATES}" + exit 1 + fi +} diff --git a/functions/usage.sh b/functions/usage.sh new file mode 100755 index 000000000..ef82babee --- /dev/null +++ b/functions/usage.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Usage () +{ + printf "%s - %s\n" "${PROGRAM}" "${DESCRIPTION}" + echo + Echo "Usage:" + echo + + if [ -n "${USAGE}" ] + then + Echo " ${USAGE}" + echo + fi + + printf " %s [-h|--help]\n" "${PROGRAM}" + printf " %s [-u|--usage]\n" "${PROGRAM}" + printf " %s [-v|--version]\n" "${PROGRAM}" + echo + Echo "Try \" %s--help\" for more information." "${PROGRAM}" + + exit 1 +} diff --git a/functions/version.sh b/functions/version.sh new file mode 100755 index 000000000..9c1fcbf18 --- /dev/null +++ b/functions/version.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Version () +{ + Echo "%s, version %s" "${PROGRAM}" "${VERSION}" + Echo "This program is a part of %s" "${PACKAGE}" + echo + Echo "Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>" + echo + Echo "This program is free software: you can redistribute it and/or modify" + Echo "it under the terms of the GNU General Public License as published by" + Echo "the Free Software Foundation, either version 3 of the License, or" + Echo "(at your option) any later version." + echo + Echo "This program is distributed in the hope that it will be useful," + Echo "but WITHOUT ANY WARRANTY; without even the implied warranty of" + Echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" + Echo "GNU General Public License for more details." + echo + Echo "You should have received a copy of the GNU General Public License" + Echo "along with this program. If not, see <http://www.gnu.org/licenses/>." + echo + Echo "On Debian systems, the complete text of the GNU General Public License" + Echo "can be found in /usr/share/common-licenses/GPL-3 file." + echo + Echo "Homepage: <http://live.debian.net/>" + + exit 0 +} diff --git a/functions/wrapper.sh b/functions/wrapper.sh new file mode 100755 index 000000000..3b8a67232 --- /dev/null +++ b/functions/wrapper.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org> +## +## 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. + + +Apt () +{ + case "${LB_APT}" in + apt|apt-get) + Chroot chroot apt-get ${APT_OPTIONS} ${@} + ;; + + aptitude) + Chroot chroot aptitude ${APTITUDE_OPTIONS} ${@} + ;; + esac +} |