diff options
author | Daniel Baumann <daniel@debian.org> | 2009-11-22 14:36:42 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2009-11-22 14:38:00 +0100 |
commit | a62f12110b19a52a58d7eae871012202cfa16055 (patch) | |
tree | 0bd188079c808ee8956fb5304c46ce8266b49f75 /functions | |
download | vyos-live-build-a62f12110b19a52a58d7eae871012202cfa16055.tar.gz vyos-live-build-a62f12110b19a52a58d7eae871012202cfa16055.zip |
Renaming categories to archive areas (Closes: #519690).
Diffstat (limited to 'functions')
-rwxr-xr-x | functions/aliases.sh | 40 | ||||
-rwxr-xr-x | functions/architecture.sh | 92 | ||||
-rwxr-xr-x | functions/arguments.sh | 81 | ||||
-rwxr-xr-x | functions/breakpoints.sh | 19 | ||||
-rwxr-xr-x | functions/cache.sh | 60 | ||||
-rwxr-xr-x | functions/chroot.sh | 27 | ||||
-rwxr-xr-x | functions/color.sh | 37 | ||||
-rwxr-xr-x | functions/common.sh | 15 | ||||
-rwxr-xr-x | functions/conffile.sh | 54 | ||||
-rwxr-xr-x | functions/cursor.sh | 73 | ||||
-rwxr-xr-x | functions/defaults.sh | 1130 | ||||
-rwxr-xr-x | functions/echo.sh | 250 | ||||
-rwxr-xr-x | functions/exit.sh | 35 | ||||
-rwxr-xr-x | functions/help.sh | 35 | ||||
-rwxr-xr-x | functions/l10n.sh | 26 | ||||
-rwxr-xr-x | functions/legacy.sh | 18 | ||||
-rwxr-xr-x | functions/lockfile.sh | 46 | ||||
-rwxr-xr-x | functions/losetup.sh | 52 | ||||
-rwxr-xr-x | functions/man.sh | 17 | ||||
-rwxr-xr-x | functions/packages.sh | 102 | ||||
-rwxr-xr-x | functions/packageslists.sh | 97 | ||||
-rwxr-xr-x | functions/releases.sh | 25 | ||||
-rwxr-xr-x | functions/stagefile.sh | 70 | ||||
-rwxr-xr-x | functions/templates.sh | 24 | ||||
-rwxr-xr-x | functions/usage.sh | 30 | ||||
-rwxr-xr-x | functions/version.sh | 36 | ||||
-rwxr-xr-x | functions/wrapper.sh | 21 |
27 files changed, 2512 insertions, 0 deletions
diff --git a/functions/aliases.sh b/functions/aliases.sh new file mode 100755 index 000000000..859f34dc7 --- /dev/null +++ b/functions/aliases.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# aliases.sh - internal shell aliases +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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..278ec6a6f --- /dev/null +++ b/functions/architecture.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +# architecture.sh - handle architecture specific support +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 ${LH_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|lpia|x86_64) + CROSS="amd64 i386 lpia" + ;; + + powerpc|ppc64) + CROSS="powerpc ppc64" + ;; + + *) + CROSS="${HOST}" + ;; + esac + + Check_architecture "${CROSS}" +} + +Check_multiarchitecture () +{ + if [ "$(echo ${LH_ARCHITECTURE} | wc -w)" -gt "1" ] + then + # First, only support multiarch on iso + if [ "${LH_BINARY_IMAGES}" = "iso" ] + then + # Assemble multi-arch + case "${LH_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" + ;; + + lpia) + DESTDIR="${DESTDIR}.lpi" + DESTDIR_LIVE="${DESTDIR_LIVE}.lpi" + DESTDIR_INSTALL="${DESTDIR_INSTALL}.lpi" + ;; + + powerpc) + DESTDIR="${DESTDIR}.ppc" + DESTDIR_LIVE="${DESTDIR_LIVE}.ppc" + DESTDIR_INSTALL="${DESTDIR_INSTALL}.ppc" + ;; + esac + fi + fi +} diff --git a/functions/arguments.sh b/functions/arguments.sh new file mode 100755 index 000000000..bbc439c84 --- /dev/null +++ b/functions/arguments.sh @@ -0,0 +1,81 @@ +#!/bin/sh + +# arguments.sh - handle common arguments +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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="enabled" + shift + ;; + + -c|--conffile) + _CONFFILE="${2}" + shift 2 + ;; + + --debug) + _DEBUG="enabled" + shift + ;; + + --force) + _FORCE="enabled" + shift + ;; + + -h|--help) + Man + shift + ;; + + --quiet) + _QUIET="enabled" + shift + ;; + + -u|--usage) + Usage + shift + ;; + + --verbose) + _VERBOSE="enabled" + 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..2f078e15f --- /dev/null +++ b/functions/breakpoints.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# breakpoints.sh - run with breakpoints +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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}" = "enabled" ] + 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..ca5e5ed0e --- /dev/null +++ b/functions/cache.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +# cache.sh - manage package cache +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 [ "${LH_CACHE}" = "enabled" ] && [ "${LH_CACHE_PACKAGES}" = "enabled" ] + 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 [ "${LH_CACHE}" = "enabled" ] && [ "${LH_CACHE_PACKAGES}" = "enabled" ] + 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..420abe18a --- /dev/null +++ b/functions/chroot.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# chroot.sh - /usr/sbin/chroot wrapper script +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 [ "${LH_USE_FAKEROOT}" != "enabled" ] + then + ${LH_ROOT_COMMAND} 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="${LH_APT_FTP_PROXY}" http_proxy="${LH_APT_HTTP_PROXY}" DEBIAN_FRONTEND="${LH_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LH_DEBCONF_PRIORITY}" DEBCONF_NOWARNINGS="${LH_DEBCONF_NOWARNINGS}" XORG_CONFIG="custom" ${COMMANDS} + else + # Building with fakeroot/fakechroot + ${LH_ROOT_COMMAND} chroot "${CHROOT}" ${COMMANDS} + fi + + return "${?}" +} diff --git a/functions/color.sh b/functions/color.sh new file mode 100755 index 000000000..97ac6832f --- /dev/null +++ b/functions/color.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# color.sh - define color values +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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..2be9e5421 --- /dev/null +++ b/functions/common.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# common.sh - common things for all live-helpers +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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. + +PROGRAM="$(basename ${0})" +PACKAGE="live-helper" +VERSION="1.0.6-1" +CONFIG_VERSION="$(echo ${VERSION} | awk -F- '{ print $1 }')" + +PATH="${PWD}/scripts:${PATH}" diff --git a/functions/conffile.sh b/functions/conffile.sh new file mode 100755 index 000000000..9d87a33cd --- /dev/null +++ b/functions/conffile.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +# conffile.sh - handle configuration files +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 "${LH_CONFIG}" ] + then + FILES="${LH_CONFIG}" + else + for FILE in ${@} + do + FILES="${FILES} ${FILE} ${FILE}.${LH_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..b343d3f81 --- /dev/null +++ b/functions/cursor.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# cursor.sh - define cursor movements +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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..30cdfc6f7 --- /dev/null +++ b/functions/defaults.sh @@ -0,0 +1,1130 @@ +#!/bin/sh + +# defaults.sh - handle default values +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 + + # Setting mode + if [ -z "${LH_MODE}" ] + then + LH_MODE="debian" + fi + + # Setting distribution name + if [ -z "${LH_DISTRIBUTION}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_DISTRIBUTION="lenny" + ;; + + emdebian) + LH_DISTRIBUTION="sid" + ;; + + ubuntu) + LH_DISTRIBUTION="jaunty" + ;; + esac + fi + + # Setting package manager + if [ "${LH_DISTRIBUTION}" = "etch" ] + then + LH_APT="${LH_APT:-aptitude}" + else + LH_APT="${LH_APT:-apt}" + fi + + # Setting apt ftp proxy + if [ -z "${LH_APT_FTP_PROXY}" ] && [ -n "${ftp_proxy}" ] + then + LH_APT_FTP_PROXY="${ftp_proxy}" + else + if [ -n "${LH_APT_FTP_PROXY}" ] && [ "${LH_APT_FTP_PROXY}" != "${ftp_proxy}" ] + then + ftp_proxy="${LH_APT_FTP_PROXY}" + fi + fi + + # Setting apt http proxy + if [ -z "${LH_APT_HTTP_PROXY}" ] && [ -n "${http_proxy}" ] + then + LH_APT_HTTP_PROXY="${http_proxy}" + else + if [ -n "${LH_APT_HTTP_PROXY}" ] && [ "${LH_APT_HTT_PROXY}" != "${http_proxy}" ] + then + http_proxy="${LH_APT_HTTP_PROXY}" + fi + fi + + # Setting apt pdiffs + LH_APT_PDIFFS="${LH_APT_PDIFFS:-enabled}" + + # Setting apt pipeline + # LH_APT_PIPELINE + + APT_OPTIONS="${APT_OPTIONS:---yes}" + APTITUDE_OPTIONS="${APTITUDE_OPTIONS:---assume-yes}" + + GZIP_OPTIONS="${GZIP_OPTIONS:---best}" + + if gzip --help | grep -qs "\-\-rsyncable" && \ + ! echo ${GZIP_OPTIONS} | grep -q rsyncable + then + GZIP_OPTIONS="${GZIP_OPTIONS} --rsyncable" + else + GZIP_OPTIONS="$(echo ${GZIP_OPTIONS} | sed -e 's|--rsyncable||')" + fi + + # Setting apt recommends + case "${LH_MODE}" in + debian|debian-release|ubuntu) + LH_APT_RECOMMENDS="${LH_APT_RECOMMENDS:-enabled}" + ;; + + emdebian) + LH_APT_RECOMMENDS="${LH_APT_RECOMMENDS:-disabled}" + ;; + esac + + # Setting apt secure + LH_APT_SECURE="${LH_APT_SECURE:-enabled}" + + # Setting bootstrap program + if [ -z "${LH_BOOTSTRAP}" ] || ( [ ! -x "$(which ${LH_BOOTSTRAP} 2>/dev/null)" ] && [ "${LH_BOOTSTRAP}" != "copy" ] ) + then + if [ -x "/usr/sbin/debootstrap" ] + then + LH_BOOTSTRAP="debootstrap" + elif [ -x "/usr/bin/cdebootstrap" ] + then + LH_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 + LH_CACHE="${LH_CACHE:-enabled}" + LH_CACHE_INDICES="${LH_CACHE_INDICES:-disabled}" + LH_CACHE_PACKAGES="${LH_CACHE_PACKAGES:-enabled}" + LH_CACHE_STAGES="${LH_CACHE_STAGES:-bootstrap}" + + # Setting debconf frontend + LH_DEBCONF_FRONTEND="${LH_DEBCONF_FRONTEND:-noninteractive}" + LH_DEBCONF_NOWARNINGS="${LH_DEBCONF_NOWARNINGS:-yes}" + LH_DEBCONF_PRIORITY="${LH_DEBCONF_PRIORITY:-critical}" + + case "${LH_DEBCONF_NOWARNINGS}" in + enabled) + LH_DEBCONF_NOWARNINGS="yes" + ;; + + disabled) + LH_DEBCONF_NOWARNINGS="no" + ;; + esac + + # Setting initramfs hook + if [ -z "${LH_INITRAMFS}" ] + then + LH_INITRAMFS="auto" + else + if [ "${LH_INITRAMFS}" = "auto" ] + then + case "${LH_MODE}" in + debian|debian-release) + if [ "${LH_DISTRIBUTION}" = "etch" ] + then + LH_INITRAMFS="casper" + else + LH_INITRAMFS="live-initramfs" + fi + ;; + + ubuntu) + LH_INITRAMFS="casper" + ;; + + *) + LH_INITRAMFS="live-initramfs" + ;; + esac + fi + fi + + # Setting fdisk + if [ -z "${LH_FDISK}" ] || [ ! -x "${LH_FDISK}" ] + then + # Workaround for gnu-fdisk divertion + # (gnu-fdisk is buggy, #445304). + if [ -x /sbin/fdisk.distrib ] + then + LH_FDISK="fdisk.distrib" + elif [ -x /sbin/fdisk ] + then + LH_FDISK="fdisk" + else + Echo_error "Can't process file /sbin/fdisk" + fi + fi + + # Setting losetup + if [ -z "${LH_LOSETUP}" ] || [ "${LH_LOSETUP}" != "/sbin/losetup.orig" ] + then + # Workaround for loop-aes-utils divertion + # (loop-aes-utils' losetup lacks features). + if [ -x /sbin/losetup.orig ] + then + LH_LOSETUP="losetup.orig" + elif [ -x /sbin/losetup ] + then + LH_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 + LH_ROOT_COMMAND="" + else + if [ -x /usr/bin/sudo ] + then + # FIXME: this is disabled until considered safe + #LH_ROOT_COMMAND="sudo" + LH_ROOT_COMMAND="" + fi + fi + + # Setting tasksel + LH_TASKSEL="${LH_TASKSEL:-tasksel}" + + # Setting root directory + if [ -z "${LH_ROOT}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_ROOT="debian-live" + ;; + + emdebian) + LH_ROOT="emdebian-live" + ;; + + ubuntu) + LH_ROOT="ubuntu-live" + ;; + esac + fi + + # Setting includes + if [ -z "${LH_INCLUDES}" ] + then + LH_INCLUDES="${LH_BASE:-/usr/share/live-helper}/includes" + fi + + # Setting templates + if [ -z "${LH_TEMPLATES}" ] + then + LH_TEMPLATES="${LH_BASE:-/usr/share/live-helper}/templates" + fi + + # Setting live helper options + _BREAKPOINTS="${_BREAKPOINTS:-disabled}" + _COLOR="${_COLOR:-false}" + _DEBUG="${_DEBUG:-disabled}" + _FORCE="${_FORCE:-disabled}" + _QUIET="${_QUIET:-disabled}" + _VERBOSE="${_VERBOSE:-disabled}" + + ## config/bootstrap + + # Setting architecture value + if [ -z "${LH_ARCHITECTURE}" ] + then + if [ -x "/usr/bin/dpkg" ] + then + LH_ARCHITECTURE="$(dpkg --print-architecture)" + else + case "$(uname -m)" in + sparc|powerpc) + LH_ARCHITECTURE="$(uname -m)" + ;; + x86_64) + LH_ARCHITECTURE="amd64" + ;; + *) + Echo_warning "Can't determine architecture, assuming i386" + LH_ARCHITECTURE="i386" + ;; + esac + fi + fi + + # Include packages on base + # LH_BOOTSTRAP_INCLUDE + + # Exclude packages on base + # LH_BOOTSTRAP_EXCLUDE + + # Setting distribution configuration value + # LH_BOOTSTRAP_CONFIG + + # Setting flavour value + case "${LH_BOOTSTRAP}" in + cdebootstrap) + LH_BOOTSTRAP_FLAVOUR="${LH_BOOTSTRAP_FLAVOUR:-standard}" + ;; + esac + + # Setting bootstrap keyring + # LH_BOOTSTRAP_KEYRING + + # Setting mirror to fetch packages from + if [ -z "${LH_MIRROR_BOOTSTRAP}" ] + then + case "${LH_MODE}" in + debian|debian-release) + case "${LH_ARCHITECTURE}" in + amd64|i386) + LH_MIRROR_BOOTSTRAP="http://ftp.de.debian.org/debian/" + ;; + + *) + LH_MIRROR_BOOTSTRAP="http://ftp.de.debian.org/debian/" + ;; + esac + ;; + + emdebian) + LH_MIRROR_BOOTSTRAP="http://buildd.emdebian.org/grip/" + ;; + + ubuntu) + case "${LH_ARCHITECTURE}" in + amd64|i386) + LH_MIRROR_BOOTSTRAP="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LH_MIRROR_BOOTSTRAP="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + LH_MIRROR_CHROOT="${LH_MIRROR_CHROOT:-${LH_MIRROR_BOOTSTRAP}}" + + # Setting security mirror to fetch packages from + if [ -z "${LH_MIRROR_CHROOT_SECURITY}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_MIRROR_CHROOT_SECURITY="http://security.debian.org/" + ;; + + emdebian) + LH_MIRROR_CHROOT_SECURITY="none" + ;; + + ubuntu) + case "${LH_ARCHITECTURE}" in + amd64|i386) + LH_MIRROR_CHROOT_SECURITY="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LH_MIRROR_CHROOT_SECURITY="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + # Setting mirror which ends up in the image + if [ -z "${LH_MIRROR_BINARY}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_MIRROR_BINARY="http://cdn.debian.net/debian/" + ;; + + emdebian) + LH_MIRROR_BINARY="http://buildd.emdebian.org/grip/" + ;; + + ubuntu) + case "${LH_ARCHITECTURE}" in + amd64|i386) + LH_MIRROR_BINARY="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LH_MIRROR_BINARY="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + # Setting security mirror which ends up in the image + if [ -z "${LH_MIRROR_BINARY_SECURITY}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_MIRROR_BINARY_SECURITY="http://security.debian.org/" + ;; + + emdebian) + LH_MIRROR_BINARY_SECURITY="none" + ;; + + ubuntu) + case "${LH_ARCHITECTURE}" in + amd64|i386) + LH_MIRROR_BINARY_SECURITY="http://archive.ubuntu.com/ubuntu/" + ;; + + *) + LH_MIRROR_BINARY_SECURITY="http://ports.ubuntu.com/" + ;; + esac + ;; + esac + fi + + # Setting archive areas value + if [ -z "${LH_ARCHIVE_AREAS}" ] + then + case "${LH_MODE}" in + ubuntu) + LH_ARCHIVE_AREAS="main restricted" + ;; + + *) + LH_ARCHIVE_AREAS="main" + ;; + esac + fi + + ## config/chroot + + # Setting chroot filesystem + LH_CHROOT_FILESYSTEM="${LH_CHROOT_FILESYSTEM:-squashfs}" + + # Setting virtual root size + LH_VIRTUAL_ROOT_SIZE="${LH_VIRTUAL_ROOT_SIZE:-10000}" + + # Setting whether to expose root filesystem as read only + LH_EXPOSED_ROOT="${LH_EXPOSED_ROOT:-disabled}" + + # Setting union filesystem + if [ -z "${LH_UNION_FILESYSTEM}" ] + then + if [ "${LH_DISTRIBUTION}" = "etch" ] + then + LH_UNION_FILESYSTEM="unionfs" + else + LH_UNION_FILESYSTEM="aufs" + fi + fi + + # LH_HOOKS + + # Setting interactive shell/X11/Xnest + LH_INTERACTIVE="${LH_INTERACTIVE:-disabled}" + + # Setting keyring packages + case "${LH_MODE}" in + debian|debian-release) + LH_KEYRING_PACKAGES="${LH_KEYRING_PACKAGES:-debian-archive-keyring}" + ;; + + emdebian) + LH_KEYRING_PACKAGES="${LH_kEYRING_PACKAGES:-debian-archive-keyring}" + ;; + + ubuntu) + LH_KEYRING_PACKAGES="${LH_KEYRING_PACKAGES:-ubuntu-keyring}" + ;; + esac + + # Setting language string + LH_LANGUAGE="${LH_LANGUAGE:-en}" + + # Setting linux flavour string + if [ -z "${LH_LINUX_FLAVOURS}" ] + then + case "${LH_ARCHITECTURE}" in + alpha) + case "${LH_MODE}" in + ubuntu) + Echo_error "Architecture ${LH_ARCHITECTURE} not supported on Ubuntu." + exit 1 + ;; + + *) + LH_LINUX_FLAVOURS="alpha-generic" + ;; + esac + ;; + + amd64) + case "${LH_MODE}" in + ubuntu) + LH_LINUX_FLAVOURS="generic" + ;; + + *) + LH_LINUX_FLAVOURS="amd64" + ;; + esac + ;; + + hppa) + case "${LH_MODE}" in + ubuntu) + LH_LINUX_FLAVOURS="hppa32 hppa64" + ;; + + *) + LH_LINUX_FLAVOURS="parisc" + ;; + esac + ;; + + i386) + case "${LH_MODE}" in + ubuntu) + LH_LINUX_FLAVOURS="generic" + ;; + + *) + case "${LIST}" in + stripped|minimal) + LH_LINUX_FLAVOURS="486" + ;; + + *) + LH_LINUX_FLAVOURS="486 686" + ;; + esac + ;; + esac + ;; + + ia64) + LH_LINUX_FLAVOURS="itanium" + ;; + + lpia) + case "${LH_MODE}" in + debian|debian-release|embedian) + Echo_error "Architecture ${LH_ARCHITECTURE} not supported on ${LH_MODE}." + exit 1 + ;; + + *) + LH_LINUX_FLAVOURS="lpia" + ;; + esac + ;; + + powerpc) + case "${LIST}" in + stripped|minimal) + LH_LINUX_FLAVOURS="powerpc" + ;; + + *) + LH_LINUX_FLAVOURS="powerpc powerpc64" + ;; + esac + ;; + + s390) + case "${LH_MODE}" in + ubuntu) + Echo_error "Architecture ${LH_ARCHITECTURE} not supported on Ubuntu." + exit 1 + ;; + + *) + LH_LINUX_FLAVOURS="s390" + ;; + esac + ;; + + sparc) + if [ "${LH_DISTRIBUTION}" = "etch" ] + then + LH_LINUX_FLAVOURS="sparc32" + else + LH_LINUX_FLAVOURS="sparc64" + fi + ;; + + arm|armel|m68k) + Echo_error "You need to specify the linux kernel flavour manually on ${LH_ARCHITECTURE} (FIXME)." + exit 1 + ;; + + *) + Echo_error "Architecture ${LH_ARCHITECTURE} not yet supported (FIXME)" + exit 1 + ;; + esac + fi + + # Set linux packages + if [ -z "${LH_LINUX_PACKAGES}" ] + then + case "${LH_MODE}" in + debian|debian-release|embedian) + case "${LH_DISTRIBUTION}" in + etch|lenny|squeeze) + LH_LINUX_PACKAGES="linux-image-2.6 \${LH_UNION_FILESYSTEM}-modules-2.6" + ;; + + *) + LH_LINUX_PACKAGES="linux-image-2.6" + ;; + esac + + if [ "${LH_CHROOT_FILESYSTEM}" = "squashfs" ] + then + case "${LH_DISTRIBUTION}" in + etch|lenny) + LH_LINUX_PACKAGES="${LH_LINUX_PACKAGES} squashfs-modules-2.6" + ;; + esac + fi + + case "${LH_ENCRYPTION}" in + ""|disabled) + + ;; + + *) + LH_LINUX_PACKAGES="${LH_LINUX_PACKAGES} loop-aes-modules-2.6" + ;; + esac + ;; + + ubuntu) + LH_LINUX_PACKAGES="linux" + ;; + esac + fi + + # Setting packages string + case "${LH_MODE}" in + ubuntu) + LH_PACKAGES="${LH_PACKAGES:-ubuntu-minimal}" + ;; + + *) + LH_PACKAGES_LISTS="${LH_PACKAGES_LISTS:-standard}" + ;; + esac + + case "${LH_ENCRYPTION}" in + ""|disabled) + + ;; + + *) + if ! In_list loop-aes-utils "${LH_PACKAGES}" + then + LH_PACKAGES="${LH_PACKAGES} loop-aes-utils" + fi + ;; + esac + + # Setting tasks string + for LIST in ${LH_PACKAGES_LISTS} + do + case "${LIST}" in + stripped|minimal) + LH_APT="apt-get" + ;; + + gnome-desktop) + LH_PACKAGES_LISTS="$(echo ${LH_PACKAGES_LISTS} | sed -e 's|gnome-desktop||') standard-x11" + LH_TASKS="$(echo ${LH_TASKS} | sed -e 's|standard||' -e 's|gnome-desktop||' -e 's|desktop||') standard gnome-desktop desktop" + ;; + + kde-desktop) + LH_PACKAGES_LISTS="$(echo ${LH_PACKAGES_LISTS} | sed -e 's|kde-desktop||') standard-x11" + LH_TASKS="$(echo ${LH_TASKS} | sed -e 's|standard||' -e 's|kde-desktop||' -e 's|desktop||') standard kde-desktop desktop" + ;; + + lxde-desktop) + LH_PACKAGES_LISTS="$(echo ${LH_PACKAGES_LISTS} | sed -e 's|lxde-desktop||') standard-x11" + LH_TASKS="$(echo ${LH_TASKS} | sed -e 's|standard||' -e 's|lxde-desktop||' -e 's|desktop||') standard lxde-desktop desktop" + ;; + + xfce-desktop) + LH_PACKAGES_LISTS="$(echo ${LH_PACKAGES_LISTS} | sed -e 's|xfce-desktop||') standard-x11" + LH_TASKS="$(echo ${LH_TASKS} | sed -e 's|standard||' -e 's|xfce-desktop||' -e 's|desktop||') standard xfce-desktop desktop" + ;; + esac + done + + LH_PACKAGES_LISTS="$(echo ${LH_PACKAGES_LISTS} | sed -e 's| ||g')" + LH_TASKS="$(echo ${LH_TASKS} | sed -e 's| ||g')" + + # Setting security updates option + if [ "${LH_MIRROR_CHROOT_SECURITY}" = "none" ] || [ "${LH_MIRROR_BINARY_SECURITY}" = "none" ] + then + LH_SECURITY="disabled" + fi + + LH_SECURITY="${LH_SECURITY:-enabled}" + + # Setting symlink convertion option + LH_SYMLINKS="${LH_SYMLINKS:-disabled}" + + # Setting sysvinit option + LH_SYSVINIT="${LH_SYSVINIT:-disabled}" + + ## config/binary + + # Setting image filesystem + case "${LH_ARCHITECTURE}" in + sparc) + LH_BINARY_FILESYSTEM="${LH_BINARY_FILESYSTEM:-ext2}" + ;; + + *) + LH_BINARY_FILESYSTEM="${LH_BINARY_FILESYSTEM:-fat16}" + ;; + esac + + # Setting image type + LH_BINARY_IMAGES="${LH_BINARY_IMAGES:-iso}" + + # Setting apt indices + if echo ${LH_PACKAGES_LISTS} | grep -qs -E "(stripped|minimal)\b" + then + LH_BINARY_INDICES="${LH_BINARY_INDICES:-none}" + else + LH_BINARY_INDICES="${LH_BINARY_INDICES:-enabled}" + fi + + # Setting bootloader + if [ -z "${LH_BOOTLOADER}" ] + then + case "${LH_ARCHITECTURE}" in + amd64|i386|lpia) + LH_BOOTLOADER="syslinux" + ;; + + powerpc) + LH_BOOTLOADER="yaboot" + ;; + + sparc) + LH_BOOTLOADER="silo" + ;; + esac + fi + + # Setting checksums + LH_CHECKSUMS="${LH_CHECKSUMS:-enabled}" + + # Setting chroot option + LH_CHROOT_BUILD="${LH_CHROOT_BUILD:-enabled}" + + # Setting debian-installer option + LH_DEBIAN_INSTALLER="${LH_DEBIAN_INSTALLER:-disabled}" + + # Setting debian-installer distribution + LH_DEBIAN_INSTALLER_DISTRIBUTION="${LH_DEBIAN_INSTALLER_DISTRIBUTION:-${LH_DISTRIBUTION}}" + + # Setting debian-installer-gui + case "${LH_MODE}" in + debian) + LH_DEBIAN_INSTALLER_GUI="${LH_DEBIAN_INSTALLER_GUI:-enabled}" + ;; + + ubuntu) + case "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" in + karmic) + # Not available for Karmic currently. + LH_DEBIAN_INSTALLER_GUI="${LH_DEBIAN_INSTALLER_GUI:-disabled}" + ;; + + *) + LH_DEBIAN_INSTALLER_GUI="${LH_DEBIAN_INSTALLER_GUI:-enabled}" + ;; + esac + ;; + + *) + LH_DEBIAN_INSTALLER_GUI="${LH_DEBIAN_INSTALLER_GUI:-disabled}" + ;; + esac + + # Setting debian-installer preseed filename + if [ -z "${LH_DEBIAN_INSTALLER_PRESEEDFILE}" ] + then + if Find_files config/binary_debian-installer/preseed.cfg + then + LH_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 LH_DEBIAN_INSTALLER_PRESEEDFILE. This means that debian-installer will not take up a preseeding file by default." + fi + fi + + # Setting boot parameters + # LH_BOOTAPPEND_LIVE + if [ -n "${LH_DEBIAN_INSTALLER_PRESEEDFILE}" ] + then + case "${LH_BINARY_IMAGES}" in + iso) + _LH_BOOTAPPEND_PRESEED="file=/cdrom/install/${LH_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + + usb-hdd) + if [ "${LH_MODE}" = "ubuntu" ] || [ "${LH_DEBIAN_INSTALLER}" = "live" ] + then + _LH_BOOTAPPEND_PRESEED="file=/cdrom/install/${LH_DEBIAN_INSTALLER_PRESEEDFILE}" + else + _LH_BOOTAPPEND_PRESEED="file=/hd-media/install/${LH_DEBIAN_INSTALLER_PRESEEDFILE}" + fi + ;; + + net) + case "${LH_DEBIAN_INSTALLER_PRESEEDFILE}" in + *://*) + _LH_BOOTAPPEND_PRESEED="file=${LH_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + + *) + _LH_BOOTAPPEND_PRESEED="file=/${LH_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + esac + ;; + esac + fi + + if [ "${LH_BINARY_IMAGES}" = "usb-hdd" ] + then + # Try USB block devices for install media + LH_BOOTAPPEND_INSTALL="cdrom-detect/try-usb=true ${LH_BOOTAPPEND_INSTALL}" + fi + + if [ -n ${_LH_BOOTAPPEND_PRESEED} ] + then + LH_BOOTAPPEND_INSTALL="${LH_BOOTAPPEND_INSTALL} ${_LH_BOOTAPPEND_PRESEED}" + fi + + if [ -n "${LH_BOOTAPPEND_LIVE}" ] + then + LH_BOOTAPPEND_INSTALL="${LH_BOOTAPPEND_INSTALL} -- \${LH_BOOTAPPEND_LIVE}" + fi + + # Setting encryption + LH_ENCRYPTION="${LH_ENCRYPTION:-disabled}" + + # Setting grub splash + # LH_GRUB_SPLASH + + # Setting hostname + if [ -z "${LH_HOSTNAME}" ] + then + case "${LH_MODE}" in + embedian) + LH_HOSTNAME="embedian" + ;; + + ubuntu) + LH_HOSTNAME="ubuntu" + ;; + + *) + LH_HOSTNAME="debian" + ;; + esac + fi + + # Setting iso author + if [ -z "${LH_ISO_APPLICATION}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_ISO_APPLICATION="Debian Live" + ;; + + emdebian) + LH_ISO_APPLICATION="Emdebian Live" + ;; + + ubuntu) + LH_ISO_APPLICATION="Ubuntu Live" + ;; + esac + fi + + # Set iso preparer + LH_ISO_PREPARER="${LH_ISO_PREPARER:-live-helper \$VERSION; http://packages.qa.debian.org/live-helper}" + + # Set iso publisher + LH_ISO_PUBLISHER="${LH_ISO_PUBLISHER:-Debian Live project; http://debian-live.alioth.debian.org/; debian-live@lists.debian.org}" + + # Setting iso volume + if [ -z "${LH_ISO_VOLUME}" ] + then + case "${LH_MODE}" in + debian) + LH_ISO_VOLUME="Debian ${LH_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)" + ;; + + debian-release) + eval VERSION="$`echo RELEASE_${LH_DISTRIBUTION}`" + LH_ISO_VOLUME="Debian ${VERSION} ${LH_ARCHITECTURE} live" + ;; + + emdebian) + LH_ISO_VOLUME="Emdebian ${LH_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)" + ;; + + ubuntu) + LH_ISO_VOLUME="Ubuntu ${LH_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)" + ;; + esac + fi + + # Setting memtest option + LH_MEMTEST="${LH_MEMTEST:-memtest86+}" + + # Setting win32-loader option + case "${LH_ARCHITECTURE}" in + amd64|i386|lpia) + if [ "${LH_DEBIAN_INSTALLER}" != "disabled" ] + then + LH_WIN32_LOADER="${LH_WIN32_LOADER:-enabled}" + else + LH_WIN32_LOADER="${LH_WIN32_LOADER:-disabled}" + fi + ;; + + *) + LH_WIN32_LOADER="${LH_WIN32_LOADER:-disabled}" + ;; + esac + + # Setting netboot filesystem + LH_NET_ROOT_FILESYSTEM="${LH_NET_ROOT_FILESYSTEM:-nfs}" + + # Setting netboot server path + if [ -z "${LH_NET_ROOT_PATH}" ] + then + case "${LH_MODE}" in + debian|debian-release) + LH_NET_ROOT_PATH="/srv/debian-live" + ;; + + emdebian) + LH_NET_ROOT_PATH="/srv/emdebian-live" + ;; + + ubuntu) + LH_NET_ROOT_PATH="/srv/ubuntu-live" + ;; + esac + fi + + # Setting netboot server address + LH_NET_ROOT_SERVER="${LH_NET_ROOT_SERVER:-192.168.1.1}" + + # Setting net cow filesystem + LH_NET_COW_FILESYSTEM="${LH_NET_COW_FILESYSTEM:-nfs}" + + # Setting net tarball + LH_NET_TARBALL="${LH_NET_TARBALL:-gzip}" + + # Setting syslinux configuration file + # LH_SYSLINUX_CFG + + # Setting syslinux splash + # LH_SYSLINUX_SPLASH + + LH_SYSLINUX_TIMEOUT="${LH_SYSLINUX_TIMEOUT:-0}" + + # Setting syslinux menu + case "${LH_DISTRIBUTION}" in + etch) + LH_SYSLINUX_MENU="${LH_SYSLINUX_MENU:-disabled}" + ;; + + *) + LH_SYSLINUX_MENU="${LH_SYSLINUX_MENU:-enabled}" + ;; + esac + + # Setting syslinux menu live entries + case "${LH_MODE}" in + debian|debian-release) + LH_SYSLINUX_MENU_LIVE_ENTRY="${LH_SYSLINUX_MENU_LIVE_ENTRY:-Live}" + LH_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE="${LH_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE:-${LH_SYSLINUX_MENU_LIVE_ENTRY} (failsafe)}" + ;; + + *) + LH_SYSLINUX_MENU_LIVE_ENTRY="${LH_SYSLINUX_MENU_LIVE_ENTRY:-Start ${LH_ISO_APPLICATION}}" + LH_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE="${LH_SYSLINUX_MENU_LIVE_ENTRY_FAILSAFE:-${LH_SYSLINUX_MENU_LIVE_ENTRY} (failsafe)}" + ;; + esac + + # Settings memtest menu entry + LH_SYSLINUX_MENU_MEMTEST_ENTRY="${LH_SYSLINUX_MENU_MEMTEST_ENTRY:-Memory test}" + + # Setting username + case "${LH_MODE}" in + ubuntu) + LH_USERNAME="${LH_USERNAME:-ubuntu}" + ;; + + *) + LH_USERNAME="${LH_USERNAME:-user}" + ;; + esac + + ## config/source + + # Setting source option + LH_SOURCE="${LH_SOURCE:-disabled}" + + # Setting image type + LH_SOURCE_IMAGES="${LH_SOURCE_IMAGES:-tar}" + + # Setting fakeroot/fakechroot + LH_USE_FAKEROOT="${LH_USE_FAKEROOT:-disabled}" +} + +Check_defaults () +{ + if [ "${LH_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-helper always declares LH_CONFIG_VERSION + # internally, this is safe assumption (no cases where it's unset, + # except when bootstrapping the functions/defaults etc.). + CURRENT_CONFIG_VERSION="$(echo ${LH_CONFIG_VERSION} | awk -F. '{ print $1 }')" + + if [ ${CURRENT_CONFIG_VERSION} -ge 2 ] + then + Echo_error "This config tree is too new for this version of live-helper (${VERSION})." + Echo_error "Aborting build, please get a new version of live-helper." + + 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 [ "${LH_DISTRIBUTION}" = "etch" ] + then + # etch + live-initramfs + if [ "${LH_INITRAMFS}" = "live-initramfs" ] + then + Echo_warning "You selected LH_DISTRIBUTION='etch' and LH_INITRAMFS='live-initramfs'. This configuration is potentially unsafe as live-initramfs is not part of the etch distribution. Either make sure that live-initramfs is installable (e.g. through setting up etch-backports repository as third-party source or putting a valid live-initramfs deb into config/chroot_local-packages) or change your config to the etch default (casper)." + fi + + # etch + aufs + if [ "${LH_UNION_FILESYSTEM}" = "aufs" ] + then + Echo_warning "You selected LH_DISTRIBUTION='etch' and LH_UNION_FILESYSTEM='aufs'. This configuration is potentially unsafe as live-initramfs is not part of the etch distribution. Either make sure that live-initramfs is installable (e.g. through setting up etch-backports repository as third-party source or putting a valid live-initramfs deb into config/chroot_local-packages) or change your config to the etch default (casper)." + + fi + fi + + if echo ${LH_PACKAGES_LISTS} | grep -qs -E "(stripped|minimal)\b" + then + # aptitude + stripped|minimal + if [ "${LH_APT}" = "aptitude" ] + then + Echo_warning "You selected LH_PACKAGES_LISTS='%s' and LH_APT='aptitude'" "${LH_PACKAGES_LIST}. This configuration is potentially unsafe, as aptitude is not used in the stripped/minimal package lists." + fi + fi + + if [ "${LH_DEBIAN_INSTALLER}" != "disabled" ] + then + # d-i enabled, no caching + if ! echo ${LH_CACHE_STAGES} | grep -qs "bootstrap\b" || [ "${LH_CACHE}" != "enabled" ] || [ "${LH_CACHE_PACKAGES}" != "enabled" ] + then + Echo_warning "You have selected values of LH_CACHE, LH_CACHE_PACKAGES, LH_CACHE_STAGES and LH_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 [ "${LH_BOOTLOADER}" = "syslinux" ] + then + # syslinux + fat + case "${LH_BINARY_FILESYSTEM}" in + fat*) + ;; + *) + Echo_warning "You have selected values of LH_BOOTLOADER and LH_BINARY_FILESYSTEM which are incompatible - syslinux only supports FAT filesystems." + ;; + esac + fi + + if [ "${LH_BINARY_IMAGES}" = "usb-hdd" ] + then + # grub or yaboot + usb-hdd + case "${LH_BOOTLOADER}" in + grub|yaboot) + Echo_error "You have selected a combination of bootloader and image type that is currently not supported by live-helper. Please use either another bootloader or a different image type." + exit 1 + ;; + esac + fi + + if [ "$(echo ${LH_ISO_APPLICATION} | wc -c)" -gt 128 ] + then + Echo_warning "You have specified a value of LH_ISO_APPLICATION that is too long; the maximum length is 128 characters." + fi + + if [ "$(echo ${LH_ISO_PREPARER} | wc -c)" -gt 128 ] + then + Echo_warning "You have specified a value of LH_ISO_PREPARER that is too long; the maximum length is 128 characters." + fi + + if [ "$(echo ${LH_ISO_PUBLISHER} | wc -c)" -gt 128 ] + then + Echo_warning "You have specified a value of LH_ISO_PUBLISHER that is too long; the maximum length is 128 characters." + fi + + if [ "$(eval "echo ${LH_ISO_VOLUME}" | wc -c)" -gt 32 ] + then + Echo_warning "You have specified a value of LH_ISO_VOLUME that is too long; the maximum length is 32 characters." + fi + + if echo ${LH_PACKAGES_LISTS} | grep -qs -E "(stripped|minimal)\b" + then + if [ "${LH_BINARY_INDICES}" = "enabled" ] + then + Echo_warning "You have selected hook to minimise image size but you are still including package indices with your value of LH_BINARY_INDICES." + fi + fi + +} diff --git a/functions/echo.sh b/functions/echo.sh new file mode 100755 index 000000000..7af07a966 --- /dev/null +++ b/functions/echo.sh @@ -0,0 +1,250 @@ +#!/bin/sh + +# echo.sh - define output methods +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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}" = "enabled" ] + 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}" = "enabled" ] + 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}" != "enabled" ] + 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}" != "enabled" ] + 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}" = "enabled" ] + 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}" != "enabled" ] + 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 "${LH_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..bbfaf5837 --- /dev/null +++ b/functions/exit.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# exit.sh - cleanup +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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}" = "enabled" ] + 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..." + 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 + + 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..832878c71 --- /dev/null +++ b/functions/help.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# help.sh - print help information +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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://debian-live.alioth.debian.org/>." + exit 0 +} diff --git a/functions/l10n.sh b/functions/l10n.sh new file mode 100755 index 000000000..c2f167af5 --- /dev/null +++ b/functions/l10n.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# l10n.sh - load the needed localization things for all lh messages +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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/legacy.sh b/functions/legacy.sh new file mode 100755 index 000000000..422c20d38 --- /dev/null +++ b/functions/legacy.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# legacy.sh - handle live-helper 2.x warnigns +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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. + +# Obsoleting 'lh_foo_bar' calls in favour for 'lh foo_bar' + +BASENAME="$(basename ${0})" + +if [ -z "${LH}" ] && [ "$(echo ${BASENAME} | awk '{ print $1 }')" != "lh" ] +then + Echo_warning "live-helper 2.0 will deprecate all dashed forms of commands." + Echo_warning "Please use \'$(echo ${BASENAME} | sed -e 's|lh_|lh |')\' instead of \'${BASENAME}\'." +fi diff --git a/functions/lockfile.sh b/functions/lockfile.sh new file mode 100755 index 000000000..8ade76ee4 --- /dev/null +++ b/functions/lockfile.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# lockfile.sh - handle lock files +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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..1b1f61f42 --- /dev/null +++ b/functions/losetup.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +# losetup - wrapper around losetup +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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}" + + ${LH_ROOT_COMMAND} ${LH_LOSETUP} "${DEVICE}" "${FILE}" + FDISK_OUT="$(${LH_FDISK} -l -u ${DEVICE} 2>&1)" + ${LH_ROOT_COMMAND} ${LH_LOSETUP} -d "${DEVICE}" + + LOOPDEVICE="$(echo ${DEVICE}p${PARTITION})" + + if [ "${PARTITION}" = "0" ] + then + Echo_message "Mounting %s with offset 0" "${DEVICE}" + + ${LH_ROOT_COMMAND} ${LH_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}" + + ${LH_ROOT_COMMAND} ${LH_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..72213e2f8 --- /dev/null +++ b/functions/man.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# man.sh - print man information +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 $(basename ${0}) + exit 0 + fi +} diff --git a/functions/packages.sh b/functions/packages.sh new file mode 100755 index 000000000..13c0bf4db --- /dev/null +++ b/functions/packages.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +# packages.sh - handle packages installation +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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) + _LH_PACKAGES="${_LH_PACKAGES} ${PACKAGE}" + ;; + + 2) + Echo_error "You need to install %s on your host system." "${PACKAGE}" + exit 1 + ;; + esac +} + +Install_package () +{ + if [ -n "${_LH_PACKAGES}" ] && [ "${LH_CHROOT_BUILD}" != "disabled" ] + then + case "${LH_APT}" in + apt|apt-get) + Chroot chroot "apt-get install -o APT::Install-Recommends=false ${APT_OPTIONS} ${_LH_PACKAGES}" + ;; + + aptitude) + Chroot chroot "aptitude install --without-recommends ${APTITUDE_OPTIONS} ${_LH_PACKAGES}" + ;; + esac + fi +} + +Remove_package () +{ + if [ -n "${_LH_PACKAGES}" ] && [ "${LH_CHROOT_BUILD}" != "disabled" ] + then + case "${LH_APT}" in + apt|apt-get) + Chroot chroot "apt-get remove --purge ${APT_OPTIONS} ${_LH_PACKAGES}" + ;; + + aptitude) + Chroot chroot "aptitude purge ${APTITUDE_OPTIONS} ${_LH_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 "${LH_CHROOT_BUILD}" in + enabled) + if Chroot chroot "dpkg-query -s ${PACKAGE}" 2> /dev/null | grep -qs "Status: install" + then + INSTALL_STATUS=0 + else + INSTALL_STATUS=1 + fi + ;; + disabled) + 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..6ce0c520a --- /dev/null +++ b/functions/packageslists.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +# packagelists.sh - expands package list includes +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 () +{ + _LH_EXPAND_QUEUE="$(basename "${1}")" + + shift + + while [ -n "${_LH_EXPAND_QUEUE}" ] + do + _LH_LIST_NAME="$(echo ${_LH_EXPAND_QUEUE} | cut -d" " -f1)" + _LH_EXPAND_QUEUE="$(echo ${_LH_EXPAND_QUEUE} | cut -s -d" " -f2-)" + _LH_LIST_LOCATION="" + _LH_NESTED=0 + _LH_ENABLED=1 + + for _LH_SEARCH_PATH in ${@} "${LH_BASE:-/usr/share/live-helper}/lists" + do + if [ -e "${_LH_SEARCH_PATH}/${_LH_LIST_NAME}" ] + then + _LH_LIST_LOCATION="${_LH_SEARCH_PATH}/${_LH_LIST_NAME}" + break + fi + done + + if [ -z "${_LH_LIST_LOCATION}" ] + then + echo "W: Unknown package list '${_LH_LIST_NAME}'" >&2 + continue + fi + + while read _LH_LINE + do + case "${_LH_LINE}" in + \#if\ *) + if [ ${_LH_NESTED} -eq 1 ] + then + echo "E: Nesting conditionals is not supported" >&2 + exit 1 + fi + _LH_NESTED=1 + + _LH_NEEDLE="$(echo "${_LH_LINE}" | cut -d' ' -f3-)" + _LH_HAYSTACK="$(eval "echo \$LH_$(echo "${_LH_LINE}" | cut -d' ' -f2)")" + + _LH_ENABLED=0 + for _LH_NEEDLE_PART in ${_LH_NEEDLE} + do + for _LH_HAYSTACK_PART in ${_LH_HAYSTACK} + do + if [ "${_LH_NEEDLE_PART}" = "${_LH_HAYSTACK_PART}" ] + then + _LH_ENABLED=1 + fi + done + done + ;; + + \#endif*) + _LH_NESTED=0 + _LH_ENABLED=1 + ;; + + \#*) + if [ ${_LH_ENABLED} -ne 1 ] + then + continue + fi + + # Find includes + _LH_INCLUDES="$(echo "${_LH_LINE}" | sed -n \ + -e 's|^#<include> \([^ ]*\)|\1|gp' \ + -e 's|^#include <\([^ ]*\)>|\1|gp')" + + # Add to queue + _LH_EXPAND_QUEUE="$(echo ${_LH_EXPAND_QUEUE} ${_LH_INCLUDES} | + sed -e 's|[ ]*$||' -e 's|^[ ]*||')" + ;; + + *) + if [ ${_LH_ENABLED} -eq 1 ] + then + echo "${_LH_LINE}" + fi + ;; + + esac + done < "${_LH_LIST_LOCATION}" + done +} diff --git a/functions/releases.sh b/functions/releases.sh new file mode 100755 index 000000000..c383c0864 --- /dev/null +++ b/functions/releases.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# releases.sh - list release information +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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_etch="4.0 r8" +RELEASE_lenny="5.0.3" +RELEASE_squeeze="6" +RELEASE_sid="unstable" + +# Ubuntu releases +RELEASE_dapper="6.06" +RELEASE_edgy="6.10" +RELEASE_feisty="7.04" +RELEASE_gutsy="7.10" +RELEASE_hardy="8.04" +RELEASE_intrepid="8.10" +RELEASE_jaunty="9.04" +RELEASE_karmic="9.10" +RELEASE_lucid="10.04" diff --git a/functions/stagefile.sh b/functions/stagefile.sh new file mode 100755 index 000000000..10f06fade --- /dev/null +++ b/functions/stagefile.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# stagefile.sh - handle stage files +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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}" != "enabled" ] + 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..eec52f38f --- /dev/null +++ b/functions/templates.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# templates.sh - handle templates files +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 "${LH_TEMPLATES}/${PACKAGE}" ] + then + TEMPLATES="${LH_TEMPLATES}/${PACKAGE}" + else + Echo_error "%s templates not accessible in %s nor config/templates" "${PACKAGE}" "${LH_TEMPLATES}" + exit 1 + fi +} diff --git a/functions/usage.sh b/functions/usage.sh new file mode 100755 index 000000000..d99cb9e2c --- /dev/null +++ b/functions/usage.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# usage.sh - print usage information +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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..5ac6f6fae --- /dev/null +++ b/functions/version.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# version.sh - print version information +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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-2009 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://debian-live.alioth.debian.org/>" + + exit 0 +} diff --git a/functions/wrapper.sh b/functions/wrapper.sh new file mode 100755 index 000000000..dcc728f8f --- /dev/null +++ b/functions/wrapper.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# wrapper.sh - external command wrappers +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper 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 "${LH_APT}" in + apt|apt-get) + Chroot chroot apt-get ${APT_OPTIONS} ${@} + ;; + + aptitude) + Chroot chroot aptitude ${APTITUDE_OPTIONS} ${@} + ;; + esac +} |