From 32322960234c8ec91e0d42835a3ec5ee63305070 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 2 Feb 2019 11:00:00 +0100 Subject: Adding upstream version 20190202. Signed-off-by: Daniel Baumann --- system-build/functions/aliases.sh | 44 ++ system-build/functions/architectures.sh | 124 ++++ system-build/functions/arguments.sh | 82 +++ system-build/functions/breakpoints.sh | 20 + system-build/functions/cache.sh | 63 +++ system-build/functions/chroot.sh | 38 ++ system-build/functions/chroot_bind_path.sh | 38 ++ system-build/functions/color.sh | 38 ++ system-build/functions/common.sh | 18 + system-build/functions/conffile.sh | 55 ++ system-build/functions/configuration.sh | 38 ++ system-build/functions/cursor.sh | 74 +++ system-build/functions/defaults.sh | 882 +++++++++++++++++++++++++++++ system-build/functions/echo.sh | 206 +++++++ system-build/functions/exit.sh | 63 +++ system-build/functions/help.sh | 36 ++ system-build/functions/lockfile.sh | 47 ++ system-build/functions/losetup.sh | 119 ++++ system-build/functions/man.sh | 18 + system-build/functions/packagelists.sh | 151 +++++ system-build/functions/packages.sh | 85 +++ system-build/functions/stagefile.sh | 71 +++ system-build/functions/usage.sh | 31 + system-build/functions/wrapper.sh | 17 + 24 files changed, 2358 insertions(+) create mode 100755 system-build/functions/aliases.sh create mode 100755 system-build/functions/architectures.sh create mode 100755 system-build/functions/arguments.sh create mode 100755 system-build/functions/breakpoints.sh create mode 100755 system-build/functions/cache.sh create mode 100755 system-build/functions/chroot.sh create mode 100755 system-build/functions/chroot_bind_path.sh create mode 100755 system-build/functions/color.sh create mode 100755 system-build/functions/common.sh create mode 100755 system-build/functions/conffile.sh create mode 100755 system-build/functions/configuration.sh create mode 100755 system-build/functions/cursor.sh create mode 100755 system-build/functions/defaults.sh create mode 100755 system-build/functions/echo.sh create mode 100755 system-build/functions/exit.sh create mode 100755 system-build/functions/help.sh create mode 100755 system-build/functions/lockfile.sh create mode 100755 system-build/functions/losetup.sh create mode 100755 system-build/functions/man.sh create mode 100755 system-build/functions/packagelists.sh create mode 100755 system-build/functions/packages.sh create mode 100755 system-build/functions/stagefile.sh create mode 100755 system-build/functions/usage.sh create mode 100755 system-build/functions/wrapper.sh (limited to 'system-build/functions') diff --git a/system-build/functions/aliases.sh b/system-build/functions/aliases.sh new file mode 100755 index 0000000..3df028f --- /dev/null +++ b/system-build/functions/aliases.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 + if [ ! -L ${FILE} ] + then + : > ${FILE} + fi + done +} diff --git a/system-build/functions/architectures.sh b/system-build/functions/architectures.sh new file mode 100755 index 0000000..7c6c48c --- /dev/null +++ b/system-build/functions/architectures.sh @@ -0,0 +1,124 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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_architectures () +{ + ARCHITECTURES="${@}" + VALID="false" + + for ARCHITECTURE in ${ARCHITECTURES} + do + if [ "$(echo ${LB_ARCHITECTURES} | grep ${ARCHITECTURE})" ] + then + VALID="true" + break + fi + done + + if [ "${ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ] + then + VALID="true" + + if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ] + then + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURES} was not found" + VALID="false" + fi + + if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ] + then + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable" + VALID="false" + fi + + fi + + if [ "${VALID}" = "false" ] + then + Echo_warning "skipping %s, foreign architecture(s)." "${0}" + exit 0 + fi +} + +Check_crossarchitectures () +{ + 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 + + if [ "${LB_ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ] + then + + if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ] + then + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURES} was not found" + exit 0 + fi + + if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ] + then + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable" + exit 0 + fi + return + fi + + + Check_architectures "${CROSS}" +} + +Check_multiarchitectures () +{ + if [ "$(echo ${LB_ARCHITECTURES} | wc -w)" -gt "1" ] + then + # First, only support multiarch on iso + case "${LIVE_IMAGE_TYPE}" 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/system-build/functions/arguments.sh b/system-build/functions/arguments.sh new file mode 100755 index 0000000..eede5c5 --- /dev/null +++ b/system-build/functions/arguments.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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) + echo "${VERSION}" + exit 0 + ;; + + --) + shift + break + ;; + + *) + Echo_error "internal error %s" "${0}" + exit 1 + ;; + esac + done +} diff --git a/system-build/functions/breakpoints.sh b/system-build/functions/breakpoints.sh new file mode 100755 index 0000000..55f4d42 --- /dev/null +++ b/system-build/functions/breakpoints.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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/system-build/functions/cache.sh b/system-build/functions/cache.sh new file mode 100755 index 0000000..467a674 --- /dev/null +++ b/system-build/functions/cache.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 [ -e "${DIRECTORY}" ] + then + # Restore old cache + if [ "$(stat --printf %d ${DIRECTORY}/)" = "$(stat --printf %d chroot/var/cache/apt/archives/)" ] + then + # with hardlinks + find "${DIRECTORY}" -name "*.deb" | xargs cp -fl -t chroot/var/cache/apt/archives + else + # without hardlinks + find "${DIRECTORY}" -name "*.deb" | xargs cp -t chroot/var/cache/apt/archives + fi + fi + fi +} + +Save_cache () +{ + DIRECTORY="${1}" + + if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ] + then + # Cleaning current cache + # In case of interrupted or incomplete builds, this may return an error, + # but we still do want to save the cache. + Chroot chroot "apt-get autoclean" || true + + 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/system-build/functions/chroot.sh b/system-build/functions/chroot.sh new file mode 100755 index 0000000..88c5466 --- /dev/null +++ b/system-build/functions/chroot.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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}" + + ENV="" + + for _FILE in config/environment config/environment.chroot + do + if [ -e "${_FILE}" ] + then + ENV="${ENV} $(grep -v '^#' ${_FILE})" + fi + done + + # Only pass SOURCE_DATE_EPOCH if its already set + if [ "${SOURCE_DATE_EPOCH:-}" != "" ] + then + ENV="${ENV} SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" + fi + + ${_LINUX32} chroot "${CHROOT}" /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" DEBIAN_FRONTEND="${LB_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LB_DEBCONF_PRIORITY}" DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" ${ENV} ${COMMANDS} + + return "${?}" +} diff --git a/system-build/functions/chroot_bind_path.sh b/system-build/functions/chroot_bind_path.sh new file mode 100755 index 0000000..b296f69 --- /dev/null +++ b/system-build/functions/chroot_bind_path.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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_bind_path () +{ + CHROOT="$(readlink -f ${1})" + BIND_SRC="$(readlink -f ${2})" + + BIND_DEST=$(echo "${BIND_SRC}" | sed -e 's|/\+||') + if [ ! -d "${CHROOT}/${BIND_DEST}" -o \ + -z "$(cat /proc/mounts | awk -vdir="${CHROOT}/${BIND_DEST}" '$2 ~ dir { print $2}')" ] + then + Echo_message "Binding local repository path" + mkdir -p "${CHROOT}/${BIND_DEST}" + mount --bind "${LB_PARENT_MIRROR_CHROOT#file:}" \ + "${CHROOT}/${BIND_DEST}" + fi +} + +Chroot_unbind_path () +{ + CHROOT="$(readlink -f ${1})" + BIND_SRC="$(readlink -f ${2})" + + BIND_DEST=$(echo "${BIND_SRC}" | sed -e 's|/\+||') + if [ -d "${CHROOT}/${BIND_DEST}" ] + then + Echo_message "Unbinding local repository path" + umount "${CHROOT}/${BIND_DEST}" > /dev/null 2>&1 || true + fi +} diff --git a/system-build/functions/color.sh b/system-build/functions/color.sh new file mode 100755 index 0000000..6eb4019 --- /dev/null +++ b/system-build/functions/color.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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/system-build/functions/common.sh b/system-build/functions/common.sh new file mode 100755 index 0000000..9fbdc3f --- /dev/null +++ b/system-build/functions/common.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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="live-build" +VERSION="$(if [ -e ${LIVE_BUILD}/VERSION.txt ]; then cat ${LIVE_BUILD}/VERSION.txt; else cat /usr/share/live/build/VERSION.txt; fi)" +CONFIG_VERSION="$(echo ${VERSION} | awk -F- '{ print $1 }')" + +# FIXME +LIVE_BUILD_VERSION="${CONFIG_VERSION}" + +PATH="${PWD}/local/bin:${PATH}" diff --git a/system-build/functions/conffile.sh b/system-build/functions/conffile.sh new file mode 100755 index 0000000..13407c3 --- /dev/null +++ b/system-build/functions/conffile.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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_ARCHITECTURES} ${FILE}.${DISTRIBUTION}" + FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lb_||')" + FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lb_||').${ARCHITECTURE}" + FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lb_||').${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/system-build/functions/configuration.sh b/system-build/functions/configuration.sh new file mode 100755 index 0000000..6c0fb2f --- /dev/null +++ b/system-build/functions/configuration.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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_configuration () +{ + _CONFIGURATION_FILE="${1}" + _FIELD_NAME="${2}" + + if [ -e "${_CONFIGURATION_FILE}" ] + then + _FIELD_BODY="$(grep ^${_FIELD_NAME}: ${_CONFIGURATION_FILE} | awk '{ $1=""; print $0 }' | sed -e 's|^ ||')" + fi + + echo ${_FIELD_BODY} +} + +Set_configuration () +{ + _CONFIGURATION_FILE="${1}" + _FIELD_NAME="${2}" + _FIELD_BODY="${3}" + + if grep -qs "^${_FIELD_NAME}:" "${_CONFIGURATION_FILE}" + then + # Update configuration + sed -i -e "s|^${_FIELD_NAME}:.*$|${_FIELD_NAME}: ${_FIELD_BODY}|" "${_CONFIGURATION_FILE}" + else + # Append configuration + echo "${_FIELD_NAME}: ${_FIELD_BODY}" >> "${_CONFIGURATION_FILE}" + fi +} diff --git a/system-build/functions/cursor.sh b/system-build/functions/cursor.sh new file mode 100755 index 0000000..1f683a1 --- /dev/null +++ b/system-build/functions/cursor.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 "\c" + printf "" +} + +Cursor_restore_position () +{ + #echo -e "\c" + printf "" +} + +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 "\c" + printf "" +} + +Cursor_erase_EOL () +{ + #echo -e "\c" + printf "" +} diff --git a/system-build/functions/defaults.sh b/system-build/functions/defaults.sh new file mode 100755 index 0000000..e1106a7 --- /dev/null +++ b/system-build/functions/defaults.sh @@ -0,0 +1,882 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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. + + +New_configuration () +{ + ## Runtime + + # Image: Architecture + if [ -x "/usr/bin/dpkg" ] + then + CURRENT_IMAGE_ARCHITECTURE="$(dpkg --print-architecture)" + else + case "$(uname -m)" in + x86_64) + CURRENT_IMAGE_ARCHITECTURE="amd64" + ;; + + i?86) + CURRENT_IMAGE_ARCHITECTURE="i386" + ;; + + *) + Echo_warning "Unable to determine current architecture, using ${CURRENT_IMAGE_ARCHITECTURE}" + ;; + esac + fi + + + ## Configuration + + # Configuration-Version + LIVE_CONFIGURATION_VERSION="${LIVE_CONFIGURATION_VERSION:-$(Get_configuration config/build Configuration-Version)}" + LIVE_CONFIGURATION_VERSION="${LIVE_CONFIGURATION_VERSION:-${LIVE_BUILD_VERSION}}" + export LIVE_CONFIGURATION_VERSION + + # Image: Name + LIVE_IMAGE_NAME="${LIVE_IMAGE_NAME:-$(Get_configuration config/build Name)}" + LIVE_IMAGE_NAME="${LIVE_IMAGE_NAME:-system}" + export LIVE_IMAGE_NAME + + # Image: Architecture (FIXME: Support and default to 'any') + LB_ARCHITECTURES="${LB_ARCHITECTURES:-$(Get_configuration config/build Architecture)}" + LB_ARCHITECTURES="${LB_ARCHITECTURES:-${CURRENT_IMAGE_ARCHITECTURE}}" + export LB_ARCHITECTURES + + # Image: Archive Areas + LB_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS:-$(Get_configuration config/build Archive-Areas)}" + + case "${LB_MODE}" in + progress-linux) + LB_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS:-main contrib non-free}" + ;; + + *) + LB_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS:-main}" + ;; + esac + + export LB_ARCHIVE_AREAS + + # Image: Archive Areas + LB_PARENT_ARCHIVE_AREAS="${LB_PARENT_ARCHIVE_AREAS:-$(Get_configuration config/build Parent-Archive-Areas)}" + LB_PARENT_ARCHIVE_AREAS="${LB_PARENT_ARCHIVE_AREAS:-${LB_ARCHIVE_AREAS}}" + export LB_PARENT_ARCHIVE_AREAS + + # Image: Type + LIVE_IMAGE_TYPE="${LIVE_IMAGE_TYPE:-$(Get_configuration config/build Type)}" + LIVE_IMAGE_TYPE="${LIVE_IMAGE_TYPE:-iso-hybrid}" + export LIVE_IMAGE_TYPE +} + +Set_defaults () +{ + # FIXME + New_configuration + + ## config/common + + if [ -e local/live-build ] + then + LIVE_BUILD="${LIVE_BUILD:-${PWD}/local/live-build}" + export LIVE_BUILD + fi + + # Setting system type + LB_SYSTEM="${LB_SYSTEM:-live}" + + # Setting mode + LB_MODE="${LB_MODE:-debian}" + + # Setting distribution name + case "${LB_MODE}" in + progress-linux) + LB_DISTRIBUTION="${LB_DISTRIBUTION:-cairon}" + LB_DERIVATIVE="true" + LB_DERIVATIVE_IS_BASED_ON="debian" + ;; + + *) + LB_DISTRIBUTION="${LB_DISTRIBUTION:-stretch}" + LB_DERIVATIVE="false" + ;; + esac + + case "${LB_MODE}" in + progress-linux) + case "${LB_DISTRIBUTION}" in + baureo|baureo-backports) + LB_PARENT_DISTRIBUTION="${LB_PARENT_DISTRIBUTION:-wheezy}" + LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION:-${LB_PARENT_DISTRIBUTION}}" + ;; + + cairon|cairon-backports) + LB_PARENT_DISTRIBUTION="${LB_PARENT_DISTRIBUTION:-sid}" + LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION:-${LB_PARENT_DISTRIBUTION}}" + ;; + esac + + LB_BACKPORTS="${LB_BACKPORTS:-true}" + ;; + + *) + LB_PARENT_DISTRIBUTION="${LB_PARENT_DISTRIBUTION:-${LB_DISTRIBUTION}}" + LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION:-${LB_PARENT_DISTRIBUTION}}" + + LB_BACKPORTS="${LB_BACKPORTS:-false}" + ;; + esac + + # Setting package manager + LB_APT="${LB_APT:-apt}" + + # Setting apt ftp proxy + LB_APT_FTP_PROXY="${LB_APT_FTP_PROXY}" + + # Setting apt http proxy + LB_APT_HTTP_PROXY="${LB_APT_HTTP_PROXY}" + + # Setting apt pipeline + # LB_APT_PIPELINE + + APT_OPTIONS="${APT_OPTIONS:---yes}" + + BZIP2_OPTIONS="${BZIP2_OPTIONS:--6}" + + GZIP_OPTIONS="${GZIP_OPTIONS:--6}" + + if gzip --help | grep -qs "\-\-rsyncable" + then + GZIP_OPTIONS="$(echo ${GZIP_OPTIONS} | sed -e 's|--rsyncable||') --rsyncable" + fi + + LZIP_OPTIONS="${LZIP_OPTIONS:--6}" + + LZMA_OPTIONS="${LZMA_OPTIONS:--6}" + + XZ_OPTIONS="${XZ_OPTIONS:--6}" + + # Setting apt recommends + case "${LB_MODE}" in + progress-linux) + LB_APT_RECOMMENDS="${LB_APT_RECOMMENDS:-false}" + ;; + + *) + LB_APT_RECOMMENDS="${LB_APT_RECOMMENDS:-true}" + ;; + esac + + # Setting apt secure + LB_APT_SECURE="${LB_APT_SECURE:-true}" + + # Setting apt source + case "${LB_MODE}" in + progress-linux) + LB_APT_SOURCE_ARCHIVES="${LB_APT_SOURCE_ARCHIVES:-false}" + ;; + + *) + LB_APT_SOURCE_ARCHIVES="${LB_APT_SOURCE_ARCHIVES:-true}" + ;; + esac + + # 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_PRIORITY="${LB_DEBCONF_PRIORITY:-critical}" + + # Setting initramfs hook + case "${LB_SYSTEM}" in + live) + LB_INITRAMFS="${LB_INITRAMFS:-system-boot}" + ;; + + normal) + LB_INITRAMFS="${LB_INITRAMFS:-none}" + ;; + esac + + LB_INITRAMFS_COMPRESSION="${LB_INITRAMFS_COMPRESSION:-gzip}" + + # Setting initsystem + case "${LB_MODE}" in + progress-linux) + case "${LB_DISTRIBUTION}" in + cairon*) + LB_INITSYSTEM="${LB_INITSYSTEM:-systemd}" + ;; + + *) + LB_INITSYSTEM="${LB_INITSYSTEM:-sysvinit}" + ;; + esac + ;; + + *) + case "${LB_SYSTEM}" in + live) + LB_INITSYSTEM="${LB_INITSYSTEM:-systemd}" + ;; + + normal) + LB_INITSYSTEM="${LB_INITSYSTEM:-none}" + ;; + esac + ;; + esac + + # 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 [ "${LB_ARCHITECTURES}" = "i386" ] && [ "${CURRENT_IMAGE_ARCHITECTURE}" = "amd64" ] + then + # Use linux32 when building amd64 images on i386 + _LINUX32="linux32" + else + _LINUX32="" + fi + + # Setting tasksel + LB_TASKSEL="${LB_TASKSEL:-apt}" + + # Setting root directory + case "${LB_MODE}" in + progress-linux) + LB_ROOT="${LB_ROOT:-progress-linux}" + ;; + + *) + LB_ROOT="${LB_ROOT:-${LB_MODE}-live}" + ;; + esac + + # 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 mirror to fetch packages from + case "${LB_MODE}" in + debian) + LB_MIRROR_BOOTSTRAP="${LB_MIRROR_BOOTSTRAP:-https://deb.debian.org/debian}" + LB_PARENT_MIRROR_BOOTSTRAP="${LB_PARENT_MIRROR_BOOTSTRAP:-${LB_MIRROR_BOOTSTRAP}}" + ;; + + progress-linux) + LB_PARENT_MIRROR_BOOTSTRAP="${LB_PARENT_MIRROR_BOOTSTRAP:-https://deb.debian.org/debian}" + LB_MIRROR_BOOTSTRAP="${LB_MIRROR_BOOTSTRAP:-http://cdn.archive.progress-linux.org/packages}" + ;; + esac + + LB_PARENT_MIRROR_CHROOT="${LB_PARENT_MIRROR_CHROOT:-${LB_PARENT_MIRROR_BOOTSTRAP}}" + LB_MIRROR_CHROOT="${LB_MIRROR_CHROOT:-${LB_MIRROR_BOOTSTRAP}}" + + # Setting security mirror to fetch packages from + case "${LB_MODE}" in + debian) + LB_MIRROR_CHROOT_SECURITY="${LB_MIRROR_CHROOT_SECURITY:-http://security.debian.org}" + LB_PARENT_MIRROR_CHROOT_SECURITY="${LB_PARENT_MIRROR_CHROOT_SECURITY:-${LB_MIRROR_CHROOT_SECURITY}}" + ;; + + progress-linux) + LB_PARENT_MIRROR_CHROOT_SECURITY="${LB_PARENT_MIRROR_CHROOT_SECURITY:-http://security.debian.org}" + LB_MIRROR_CHROOT_SECURITY="${LB_MIRROR_CHROOT_SECURITY:-${LB_MIRROR_CHROOT}}" + ;; + esac + + # Setting mirror which ends up in the image + case "${LB_MODE}" in + debian) + LB_MIRROR_BINARY="${LB_MIRROR_BINARY:-https://deb.debian.org/debian}" + LB_PARENT_MIRROR_BINARY="${LB_PARENT_MIRROR_BINARY:-${LB_MIRROR_BINARY}}" + ;; + + progress-linux) + LB_PARENT_MIRROR_BINARY="${LB_PARENT_MIRROR_BINARY:-https://deb.debian.org/debian}" + LB_MIRROR_BINARY="${LB_MIRROR_BINARY:-${LB_MIRROR_CHROOT}}" + ;; + esac + + # Setting security mirror which ends up in the image + case "${LB_MODE}" in + debian) + LB_MIRROR_BINARY_SECURITY="${LB_MIRROR_BINARY_SECURITY:-http://security.debian.org}" + LB_PARENT_MIRROR_BINARY_SECURITY="${LB_PARENT_MIRROR_BINARY_SECURITY:-${LB_MIRROR_BINARY_SECURITY}}" + ;; + + progress-linux) + LB_PARENT_MIRROR_BINARY_SECURITY="${LB_PARENT_MIRROR_BINARY_SECURITY:-http://security.debian.org}" + LB_MIRROR_BINARY_SECURITY="${LB_MIRROR_BINARY_SECURITY:-${LB_MIRROR_CHROOT}}" + ;; + esac + + case "${LB_MODE}" in + progress-linux) + LB_PARENT_MIRROR_DEBIAN_INSTALLER="${LB_PARENT_MIRROR_DEBIAN_INSTALLER:-${LB_MIRROR_CHROOT}}" + LB_MIRROR_DEBIAN_INSTALLER="${LB_MIRROR_DEBIAN_INSTALLER:-${LB_MIRROR_CHROOT}}" + ;; + + *) + LB_MIRROR_DEBIAN_INSTALLER="${LB_MIRROR_DEBIAN_INSTALLER:-${LB_MIRROR_CHROOT}}" + LB_PARENT_MIRROR_DEBIAN_INSTALLER="${LB_PARENT_MIRROR_DEBIAN_INSTALLER:-${LB_PARENT_MIRROR_CHROOT}}" + ;; + esac + + ## config/system + + # Setting chroot filesystem + LB_CHROOT_FILESYSTEM="${LB_CHROOT_FILESYSTEM:-squashfs}" + + # Setting union filesystem + LB_UNION_FILESYSTEM="${LB_UNION_FILESYSTEM:-aufs}" + + # Setting interactive shell/X11/Xnest + LB_INTERACTIVE="${LB_INTERACTIVE:-false}" + + # Setting keyring packages + LB_KEYRING_PACKAGES="${LB_KEYRING_PACKAGES:-debian-archive-keyring}" + + # Setting linux flavour string + case "${LB_ARCHITECTURES}" in + arm64) + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-arm64}" + ;; + + armel) + # armel will have special images: one rootfs image and many additional kernel images. + # therefore we default to all available armel flavours + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-kirkwood orion5x versatile}" + ;; + + armhf) + # armhf will have special images: one rootfs image and many additional kernel images. + # therefore we default to all available armhf flavours + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-armmp armmp-lpae}" + ;; + + amd64) + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-amd64}" + ;; + + i386) + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-686-pae}" + ;; + + ia64) + case "${LB_MODE}" in + progress-linux) + Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode." + exit 1 + ;; + + *) + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-itanium}" + ;; + esac + ;; + + powerpc) + case "${LB_MODE}" in + progress-linux) + Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode." + exit 1 + ;; + + *) + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-powerpc64 powerpc}" + ;; + esac + ;; + + s390x) + case "${LB_MODE}" in + progress-linux) + Echo_error "Architecture ${LB_ARCHITECTURES} not supported in the ${LB_MODE} mode." + exit 1 + ;; + + *) + LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS:-s390x}" + ;; + esac + ;; + + *) + Echo_error "Architecture(s) ${LB_ARCHITECTURES} not yet supported (FIXME)" + exit 1 + ;; + esac + + # Set linux packages + LB_LINUX_PACKAGES="${LB_LINUX_PACKAGES:-linux-image}" + + # Setting security updates option + case "${LB_PARENT_DISTRIBUTION}" in + sid) + LB_SECURITY="${LB_SECURITY:-false}" + ;; + + *) + LB_SECURITY="${LB_SECURITY:-true}" + ;; + esac + + # Setting updates updates option + case "${LB_PARENT_DISTRIBUTION}" in + sid) + LB_UPDATES="${LB_UPDATES:-false}" + ;; + + *) + LB_UPDATES="${LB_UPDATES:-true}" + ;; + esac + + ## config/binary + + # Setting image filesystem + LB_BINARY_FILESYSTEM="${LB_BINARY_FILESYSTEM:-fat32}" + + # Setting image type + case "${LB_ARCHITECTURES}" in + amd64|i386) + LIVE_IMAGE_TYPE="${LIVE_IMAGE_TYPE:-iso-hybrid}" + ;; + + *) + LIVE_IMAGE_TYPE="${LIVE_IMAGE_TYPE:-iso}" + ;; + esac + + # Setting apt indices + case "${LB_MODE}" in + progress-linux) + LB_APT_INDICES="${LB_APT_INDICES:-false}" + ;; + + *) + LB_APT_INDICES="${LB_APT_INDICES:-true}" + ;; + esac + + # Setting bootloader + if [ -z "${LB_BOOTLOADERS}" ] + then + case "${LB_ARCHITECTURES}" in + amd64|i386) + LB_BOOTLOADERS="syslinux" + ;; + esac + fi + + # Setting checksums + case "${LB_MODE}" in + progress-linux) + LB_CHECKSUMS="${LB_CHECKSUMS:-sha256}" + ;; + + *) + LB_CHECKSUMS="${LB_CHECKSUMS:-md5}" + ;; + esac + + # Setting compression + LB_COMPRESSION="${LB_COMPRESSION:-none}" + + # Setting zsync + LB_ZSYNC="${LB_ZSYNC:-true}" + + # Setting chroot option + LB_BUILD_WITH_CHROOT="${LB_BUILD_WITH_CHROOT:-true}" + + LB_BUILD_WITH_TMPFS="${LB_BUILD_WITH_TMPFS:-false}" + + # Setting debian-installer option + LB_DEBIAN_INSTALLER="${LB_DEBIAN_INSTALLER:-false}" + + LB_DEBIAN_INSTALLER_DISTRIBUTION="${LB_DEBIAN_INSTALLER_DISTRIBUTION:-${LB_DISTRIBUTION}}" + + # Setting debian-installer-gui + case "${LB_MODE}" in + debian|progress-linux) + LB_DEBIAN_INSTALLER_GUI="${LB_DEBIAN_INSTALLER_GUI:-true}" + ;; + + *) + 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/debian-installer/preseed.cfg + then + LB_DEBIAN_INSTALLER_PRESEEDFILE="/preseed.cfg" + fi + + if Find_files config/debian-installer/*.cfg && [ ! -e config/debian-installer/preseed.cfg ] + then + Echo_warning "You have placed some preseeding files into config/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 + case "${LB_INITRAMFS}" in + system-boot) + LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE:-boot=live components quiet splash}" + LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE:-boot=live components memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal}" + ;; + + none) + LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE:-quiet splash}" + LB_BOOTAPPEND_LIVE_FAILSAFE="${LB_BOOTAPPEND_LIVE_FAILSAFE:-memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal}" + ;; + esac + + if [ -n "${LB_DEBIAN_INSTALLER_PRESEEDFILE}" ] + then + case "${LIVE_IMAGE_TYPE}" in + iso*) + _LB_BOOTAPPEND_PRESEED="file=/cdrom/install/${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + + hdd*) + _LB_BOOTAPPEND_PRESEED="file=/hd-media/install/${LB_DEBIAN_INSTALLER_PRESEEDFILE}" + ;; + + netboot) + 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 + + 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 grub splash + # LB_GRUB_SPLASH + + # Setting iso author + case "${LB_MODE}" in + debian) + LB_ISO_APPLICATION="${LB_ISO_APPLICATION:-Debian Live}" + ;; + + progress-linux) + LB_ISO_APPLICATION="${LB_ISO_APPLICATION:-Progress Linux}" + ;; + esac + + # Set iso preparer + LB_ISO_PREPARER="${LB_ISO_PREPARER:-live-build \$VERSION; http://live-systems.org/devel/live-build}" + + # Set iso publisher + case "${LB_MODE}" in + progress-linux) + LB_ISO_PUBLISHER="${LB_ISO_PUBLISHER:-Progress Linux; http://www.progress-linux.org/; progress-project@lists.progress-linux.org}" + ;; + + *) + LB_ISO_PUBLISHER="${LB_ISO_PUBLISHER:-Live Systems project; http://live-systems.org/; debian-live@lists.debian.org}" + ;; + esac + + # Setting hdd options + case "${LB_MODE}" in + debian) + LB_HDD_LABEL="${LB_HDD_LABEL:-DEBIAN_LIVE}" + ;; + + progress-linux) + LB_HDD_LABEL="${LB_HDD_LABEL:-PROGRESS_$(echo ${LB_DISTRIBUTION} | tr "[a-z]" "[A-Z]")}" + ;; + esac + + # Setting hdd size + LB_HDD_SIZE="${LB_HDD_SIZE:-auto}" + + # Setting iso volume + case "${LB_MODE}" in + debian) + LB_ISO_VOLUME="${LB_ISO_VOLUME:-Debian ${LB_DISTRIBUTION} \$(date +%Y%m%d-%H:%M)}" + ;; + + progress-linux) + LB_ISO_VOLUME="${LB_ISO_VOLUME:-Progress ${LB_DISTRIBUTION}}" + ;; + esac + + # Setting memtest option + LB_MEMTEST="${LB_MEMTEST:-none}" + + # Setting loadlin option + case "${LB_MODE}" in + progress-linux) + + ;; + + *) + case "${LB_ARCHITECTURES}" in + amd64|i386) + if [ "${LB_DEBIAN_INSTALLER}" != "false" ] + then + LB_LOADLIN="${LB_LOADLIN:-true}" + else + LB_LOADLIN="${LB_LOADLIN:-false}" + fi + ;; + + *) + LB_LOADLIN="${LB_LOADLIN:-false}" + ;; + esac + ;; + esac + + # Setting win32-loader option + case "${LB_MODE}" in + progress-linux) + + ;; + + *) + case "${LB_ARCHITECTURES}" 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 + ;; + esac + + # Setting netboot filesystem + LB_NET_ROOT_FILESYSTEM="${LB_NET_ROOT_FILESYSTEM:-nfs}" + + # Setting netboot server path + case "${LB_MODE}" in + progress-linux) + LB_NET_ROOT_PATH="${LB_NET_ROOT_PATH:-/srv/progress-linux}" + ;; + + *) + LB_NET_ROOT_PATH="${LB_NET_ROOT_PATH:-/srv/${LB_MODE}-live}" + ;; + esac + + # 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:-true}" + + # Setting firmware option + LB_FIRMWARE_CHROOT="${LB_FIRMWARE_CHROOT:-true}" + LB_FIRMWARE_BINARY="${LB_FIRMWARE_BINARY:-true}" + + # Setting swap file + LB_SWAP_FILE_SIZE="${LB_SWAP_FILE_SIZE:-512}" + + ## config/source + + # Setting source option + LB_SOURCE="${LB_SOURCE:-false}" + + # Setting image type + LB_SOURCE_IMAGES="${LB_SOURCE_IMAGES:-tar}" +} + +Check_defaults () +{ + if [ -n "${LIVE_BUILD_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 LIVE_BUILD_VERSION + # internally, this is safe assumption (no cases where it's unset, + # except when bootstrapping the functions/defaults etc.). + + CURRENT_CONFIGURATION_VERSION="$(echo ${LIVE_CONFIGURATION_VERSION} | awk -F. ' { print $1 }')" + + if [ -n "${CURRENT_CONFIGURATION_VERSION}" ] + then + CORRECT_VERSION="$(echo ${LIVE_BUILD_VERSION} | awk -F. '{ print $1 }')" + TOO_NEW_VERSION="$((${CORRECT_VERSION} + 1))" + TOO_OLD_VERSION="$((${CORRECT_VERSION} - 1))" + + if [ ${CURRENT_CONFIGURATION_VERSION} -ne ${CORRECT_VERSION} ] + then + if [ ${CURRENT_CONFIGURATION_VERSION} -ge ${TOO_NEW_VERSION} ] + then + Echo_error "This config tree is too new for live-build (${VERSION})." + Echo_error "Aborting build, please update live-build." + + exit 1 + elif [ ${CURRENT_CONFIGURATION_VERSION} -le ${TOO_OLD_VERSION} ] + then + Echo_error "This config tree is too old for live-build (${VERSION})." + Echo_error "Aborting build, please update the configuration." + + exit 1 + else + Echo_warning "This configuration does not specify a version or has a unknown version." + Echo_warning "Continuing build, please correct the configuration." + fi + fi + fi + fi + + case "${LB_BINARY_FILESYSTEM}" in + ntfs) + if [ ! -x "$(which ntfs-3g 2>/dev/null)" ] + then + Echo_error "Using ntfs as the binary filesystem is currently only supported" + Echo_error "if ntfs-3g is installed on the host system." + + exit 1 + fi + ;; + esac + + if echo ${LB_HDD_LABEL} | grep -qs ' ' + then + Echo_error "There are currently no whitespaces supported in hdd labels." + + exit 1 + 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 + + + LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }') + + if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ] + then + # syslinux + fat or ntfs, or extlinux + ext[234] or btrfs + case "${LB_BINARY_FILESYSTEM}" in + fat*|ntfs|ext[234]|btrfs) + ;; + *) + Echo_warning "You have selected values of LB_BOOTLOADER and LB_BINARY_FILESYSTEM which are incompatible - the syslinux family only support FAT, NTFS, ext[234] or btrfs filesystems." + ;; + esac + fi + + case "${LIVE_IMAGE_TYPE}" in + hdd*) + case "${LB_PRIMARY_BOOTLOADER}" in + grub) + 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 + + # Architectures to use foreign bootstrap for + LB_BOOTSTRAP_QEMU_ARCHITECTURES="${LB_BOOTSTRAP_QEMU_ARCHITECTURES:-}" + + # Packages to exclude for the foreign/ports bootstrapping + LB_BOOTSTRAP_QEMU_EXCLUDE="${LB_BOOTSTRAP_QEMU_EXCLUDE:-}" + + # Ports using foreign bootstrap need a working qemu-*-system. This is the location it + LB_BOOTSTRAP_QEMU_STATIC="${LB_BOOTSTRAP_QEMU_STATIC:-}" + +} diff --git a/system-build/functions/echo.sh b/system-build/functions/echo.sh new file mode 100755 index 0000000..96b742c --- /dev/null +++ b/system-build/functions/echo.sh @@ -0,0 +1,206 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 + + printf "${STRING}\n" "${@}" +} + +Echo_debug () +{ + if [ "${_DEBUG}" = "true" ] + then + STRING="${1}" + shift + + printf "D: ${STRING}\n" "${@}" + fi +} + +Echo_debug_running () +{ + if [ "${_DEBUG}" = "true" ] + then + STRING="${1}" + shift + + printf "D: ${STRING}" "${@}" + + 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 + + printf " ${STRING}\n" "${@}" >&2 +} + +Echo_message () +{ + if [ "${_QUIET}" != "true" ] + then + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "P:" + else + printf "${WHITE}P${NO_COLOR}:" + fi + + printf " ${STRING}\n" "${@}" + fi +} + +Echo_message_running () +{ + if [ "${_QUIET}" != "true" ] + then + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "P:" + else + printf "${WHITE}P${NO_COLOR}:" + fi + + printf " ${STRING}" "${@}" + + if [ "${_COLOR}" = "true" ] + then + printf "... ${YELLOW}${BLINK}running${NO_COLOR}" + else + printf "..." + fi + fi +} + +Echo_verbose () +{ + if [ "${_VERBOSE}" = "true" ] + then + STRING="${1}" + shift + + printf "I: ${STRING}\n" "${@}" + fi +} + +Echo_verbose_running () +{ + if [ "${_VERBOSE}" != "true" ] + then + STRING="${1}" + shift + + printf "I: ${STRING}" "${@}" + + if [ "${_COLOR}" = "true" ] + then + printf "... ${YELLOW}${BLINK}running${NO_COLOR}" + else + printf "..." + fi + fi +} + +Echo_warning () +{ + STRING="${1}" + shift + + if [ "${_COLOR}" = "false" ] + then + printf "W:" + else + printf "${YELLOW}W${NO_COLOR}:" + fi + + printf " ${STRING}\n" "${@}" +} + +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_PARENT_DISTRIBUTION}" in + sid) + 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/system-build/functions/exit.sh b/system-build/functions/exit.sh new file mode 100755 index 0000000..6ff9cdc --- /dev/null +++ b/system-build/functions/exit.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 ^LB + 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 /root/config + do + umount -f chroot/${DIRECTORY} > /dev/null 2>&1 || true + done + fi + + rm -f .build/chroot_devpts + rm -f .build/chroot_proc + rm -f .build/chroot_selinuxfs + rm -f .build/chroot_sysfs + + Echo_message "Saving caches..." + + # We can't really know at which part we're failing, + # but let's assume that if there's any binary stage file arround + # we are in binary stage. + + if ls .build/binary* > /dev/null 2>&1 + then + Save_cache cache/packages.binary + else + Save_cache cache/packages.chroot + fi + + return ${VALUE} +} + +Setup_cleanup () +{ + Echo_message "Setting up cleanup function" + trap 'Exit' EXIT HUP INT QUIT TERM +} diff --git a/system-build/functions/help.sh b/system-build/functions/help.sh new file mode 100755 index 0000000..cd9344b --- /dev/null +++ b/system-build/functions/help.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 the Live Systems project ." + exit 0 +} diff --git a/system-build/functions/lockfile.sh b/system-build/functions/lockfile.sh new file mode 100755 index 0000000..cabb85f --- /dev/null +++ b/system-build/functions/lockfile.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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=".build/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=".build/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/system-build/functions/losetup.sh b/system-build/functions/losetup.sh new file mode 100755 index 0000000..0346ff6 --- /dev/null +++ b/system-build/functions/losetup.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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. + +Lodetach () +{ + DEVICE="${1}" + ATTEMPT="${2:-1}" + + if [ "${ATTEMPT}" -gt 3 ] + then + Echo_error "Failed to detach loop device '${DEVICE}'." + exit 1 + fi + + # Changes to block devices result in uevents which trigger rules which in + # turn access the loop device (ex. udisks-part-id, blkid) which can cause + # a race condition. We call 'udevadm settle' to help avoid this. + if [ -x "$(which udevadm 2>/dev/null)" ] + then + udevadm settle + fi + + # Loop back devices aren't the most reliable when it comes to writes. + # We sleep and sync for good measure - better than build failure. + sync + sleep 1 + + ${LB_LOSETUP} -d "${DEVICE}" || Lodetach "${DEVICE}" "$(expr ${ATTEMPT} + 1)" +} + +Losetup () +{ + DEVICE="${1}" + FILE="${2}" + PARTITION="${3:-1}" + + ${LB_LOSETUP} --read-only "${DEVICE}" "${FILE}" + FDISK_OUT="$(${LB_FDISK} -l -u ${DEVICE} 2>&1)" + Lodetach "${DEVICE}" + + LOOPDEVICE="$(echo ${DEVICE}p${PARTITION})" + + if [ "${PARTITION}" = "0" ] + then + Echo_message "Mounting %s with offset 0" "${DEVICE}" + + ${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_LOSETUP} -o "${OFFSET}" "${DEVICE}" "${FILE}" + fi +} + +# adapted from lib/ext2fs/mkjournal.c, default block size is 4096 bytes (/etc/mke2fs.conf). +ext2fs_default_journal_size() +{ + SIZE="$1" + if [ "${SIZE}" -lt "8" ]; then # 2048*4096 + echo 0 + elif [ "${SIZE}" -lt "128" ]; then # 32768*4096 + echo 4 + elif [ "${SIZE}" -lt "1024" ]; then # 256*1024*4096 + echo 16 + elif [ "${SIZE}" -lt "2048" ]; then # 512*1024*4096 + echo 32 + elif [ "${SIZE}" -lt "4096" ]; then # 1024*1024*4096 + echo 64 + else + echo 128 + fi +} + +Calculate_partition_size_without_journal () +{ + WITHOUT_JOURNAL_ORIGINAL_SIZE="${1}" + WITHOUT_JOURNAL_FILESYSTEM="${2}" + + case "${WITHOUT_JOURNAL_FILESYSTEM}" in + ext2|ext3|ext4) + PERCENT="6" + ;; + *) + PERCENT="3" + ;; + esac + + echo $(expr ${WITHOUT_JOURNAL_ORIGINAL_SIZE} + ${WITHOUT_JOURNAL_ORIGINAL_SIZE} \* ${PERCENT} / 100 + 1) +} + +Calculate_partition_size () +{ + ORIGINAL_SIZE="${1}" + FILESYSTEM="${2}" + + case "${FILESYSTEM}" in + ext3|ext4) + NON_JOURNAL_SIZE=$(Calculate_partition_size_without_journal ${ORIGINAL_SIZE} ${FILESYSTEM}) + PROJECTED_JOURNAL_SIZE=$(ext2fs_default_journal_size ${NON_JOURNAL_SIZE}) + PROJECTED_PARTITION_SIZE=$(expr ${ORIGINAL_SIZE} + ${PROJECTED_JOURNAL_SIZE}) + PRE_FINAL_PARTITION_SIZE=$(Calculate_partition_size_without_journal ${PROJECTED_PARTITION_SIZE} ${FILESYSTEM}) + JOURNAL_SIZE=$(ext2fs_default_journal_size ${PRE_FINAL_PARTITION_SIZE}) + + expr $(Calculate_partition_size_without_journal ${ORIGINAL_SIZE} ${FILESYSTEM}) + ${JOURNAL_SIZE} + ;; + *) + Calculate_partition_size_without_journal ${ORIGINAL_SIZE} ${FILESYSTEM} + ;; + esac +} diff --git a/system-build/functions/man.sh b/system-build/functions/man.sh new file mode 100755 index 0000000..11366b7 --- /dev/null +++ b/system-build/functions/man.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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/system-build/functions/packagelists.sh b/system-build/functions/packagelists.sh new file mode 100755 index 0000000..0ee13ce --- /dev/null +++ b/system-build/functions/packagelists.sh @@ -0,0 +1,151 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 ${@} + 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 + + printf "$(cat ${_LB_LIST_LOCATION})\n" | while read _LB_LINE + do + case "${_LB_LINE}" in + \!*) + _EXEC="$(echo ${_LB_LINE} | sed -e 's|^!||')" + + case "${LB_BUILD_WITH_CHROOT}" in + true) + chroot chroot sh -c "${_EXEC}" + ;; + + false) + eval ${_EXEC} + ;; + esac + ;; + + \#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 + ;; + + \#nif\ *) + 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 + ;; + + \#*) + # Skip comments + ;; + + *) + if [ ${_LB_ENABLED} -eq 1 ] + then + echo "${_LB_LINE}" + fi + ;; + + esac + done + done +} + +Discover_package_architectures () +{ + _LB_EXPANDED_PKG_LIST="${1}" + _LB_DISCOVERED_ARCHITECTURES="" + + shift + + if [ -e "${_LB_EXPANDED_PKG_LIST}" ] && [ -s "${_LB_EXPANDED_PKG_LIST}" ] + then + while read _LB_PACKAGE_LINE + do + # Lines from the expanded package list may have multiple, space-separated packages + for _LB_PACKAGE_LINE_PART in ${_LB_PACKAGE_LINE} + do + # Looking for : + if [ -n "$(echo ${_LB_PACKAGE_LINE_PART} | awk -F"=" '{print $1}' | awk -F':' '{print $2}')" ] + then + _LB_DISCOVERED_ARCHITECTURES="${_LB_DISCOVERED_ARCHITECTURES} $(echo ${_LB_PACKAGE_LINE_PART} | awk -F':' '{print $2}')" + fi + done + done < "${_LB_EXPANDED_PKG_LIST}" + + # Output unique architectures, alpha-sorted, one per line + echo "${_LB_DISCOVERED_ARCHITECTURES}" | tr -s '[:space:]' '\n' | sort | uniq + fi +} diff --git a/system-build/functions/packages.sh b/system-build/functions/packages.sh new file mode 100755 index 0000000..fce097f --- /dev/null +++ b/system-build/functions/packages.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 () +{ + CHROOT="${1}" + FILE="${2}" + PACKAGE="${3}" + + Check_installed "${CHROOT}" "${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 + Chroot chroot "apt-get install -o APT::Install-Recommends=false ${APT_OPTIONS} ${_LB_PACKAGES}" + fi +} + +Remove_package () +{ + if [ -n "${_LB_PACKAGES}" ] && [ "${LB_BUILD_WITH_CHROOT}" != "false" ] + then + Chroot chroot "apt-get remove --purge ${APT_OPTIONS} ${_LB_PACKAGES}" + 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 () +{ + CHROOT="${1}" + FILE="${2}" + PACKAGE="${3}" + + if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] && [ "${CHROOT}" = "chroot" ] + 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 + 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 + if [ ! -e "${FILE}" ] + then + INSTALL_STATUS=2 + else + INSTALL_STATUS=0 + fi + fi + fi +} + diff --git a/system-build/functions/stagefile.sh b/system-build/functions/stagefile.sh new file mode 100755 index 0000000..c1be52c --- /dev/null +++ b/system-build/functions/stagefile.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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, already done" "${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/system-build/functions/usage.sh b/system-build/functions/usage.sh new file mode 100755 index 0000000..86809ad --- /dev/null +++ b/system-build/functions/usage.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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/system-build/functions/wrapper.sh b/system-build/functions/wrapper.sh new file mode 100755 index 0000000..c8dccb3 --- /dev/null +++ b/system-build/functions/wrapper.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann +## +## This program 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 () +{ + CHROOT="${1}" + shift + + Chroot ${CHROOT} apt-get ${APT_OPTIONS} ${@} +} -- cgit v1.2.3