diff options
Diffstat (limited to '')
22 files changed, 3891 insertions, 0 deletions
diff --git a/system-build/scripts/build/binary b/system-build/scripts/build/binary new file mode 100755 index 0000000..551431d --- /dev/null +++ b/system-build/scripts/build/binary @@ -0,0 +1,106 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Automatically populating config tree +if [ -x auto/config ] && [ ! -e .build/config ] +then + Echo_message "Automatically populating config tree." + lb config +fi + +# Setting static variables +DESCRIPTION="$(Echo 'build binary images')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +# Setup cleanup function +Setup_cleanup + +# Preparing root filesystem +lb binary_chroot ${@} + +if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] +then + # Configuring chroot + lb chroot_devpts install ${@} + lb chroot_proc install ${@} + lb chroot_selinuxfs install ${@} + lb chroot_sysfs install ${@} + lb chroot_hosts install ${@} + lb chroot_resolv install ${@} + lb chroot_hostname install ${@} + lb chroot_sysv-rc install ${@} + lb chroot_apt install-binary ${@} + lb chroot_archives chroot install ${@} +fi + +# Building root filesystem +lb binary_rootfs ${@} +lb binary_manifest ${@} + +# Prepare images +lb binary_package-lists ${@} +lb binary_linux-image ${@} +lb binary_memtest ${@} +lb binary_grub-legacy ${@} +lb binary_grub-pc ${@} +lb binary_loopback_cfg ${@} +lb binary_syslinux ${@} +lb binary_disk ${@} +lb binary_loadlin ${@} +lb binary_win32-loader ${@} +lb binary_includes ${@} +lb binary_hooks ${@} +lb binary_checksums ${@} + +if [ "${LB_BUILD_WITH_CHROOT}" != "true" ] +then + lb chroot_devpts install ${@} + lb chroot_proc install ${@} + lb chroot_selinuxfs install ${@} + lb chroot_sysfs install ${@} +fi + +# Building images +lb binary_iso ${@} +lb binary_netboot ${@} +lb binary_tar ${@} +lb binary_hdd ${@} + +lb binary_zsync ${@} + +if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] +then + # Deconfiguring chroot + rm -f .build/chroot_archives + lb chroot_apt remove ${@} + lb chroot_hostname remove ${@} + lb chroot_resolv remove ${@} + lb chroot_hosts remove ${@} + lb chroot_sysv-rc remove ${@} + lb chroot_dpkg remove ${@} + lb chroot_debianchroot remove ${@} +fi + +lb chroot_sysfs remove ${@} +lb chroot_selinuxfs remove ${@} +lb chroot_proc remove ${@} +lb chroot_devpts remove ${@} diff --git a/system-build/scripts/build/binary_checksums b/system-build/scripts/build/binary_checksums new file mode 100755 index 0000000..a64334e --- /dev/null +++ b/system-build/scripts/build/binary_checksums @@ -0,0 +1,96 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'create binary checksums')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LB_CHECKSUMS}" = "none" ] +then + exit 0 +fi + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_checksums + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +for CHECKSUM in ${LB_CHECKSUMS} +do + case "${LB_MODE}" in + progress-linux) + CHECKSUMS="$(echo ${CHECKSUM} | tr [a-z] [A-Z])SUMS" + ;; + + *) + CHECKSUMS="${CHECKSUM}sum.txt" + ;; + esac + + Echo_message "Begin creating binary ${CHECKSUMS}..." + + # Remove old checksums + if [ -f binary/${CHECKSUMS} ] + then + rm -f binary/${CHECKSUMS} + fi + + # Calculating checksums + cd binary + find . -type f \ + \! -path './isolinux/isolinux.bin' \ + \! -path './boot/boot.bin' \ + \! -path './boot/grub/stage2_eltorito' \ + \! -path './*SUMS' \ + \! -path './*sum.txt' \ + -print0 | sort -z | xargs -0 ${CHECKSUM}sum > ../${CHECKSUMS} + +cat > ${CHECKSUMS} << EOF +## This file contains the list of ${CHECKSUM} checksums of all files on this +## medium. +## +## You can verify them automatically with the 'verify-checksums' boot parameter, +## or, manually with: '${CHECKSUM}sum -c ${CHECKSUMS}'. +## +## +EOF + + cat ../${CHECKSUMS} >> ${CHECKSUMS} + rm -f ../${CHECKSUMS} + + cd "${OLDPWD}" +done + +# File list +cd binary +find . | sed -e 's|^.||g' | grep "^/" | sort > ../${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.contents +cd "${OLDPWD}" + +# Creating stage file +Create_stagefile .build/binary_checksums diff --git a/system-build/scripts/build/binary_chroot b/system-build/scripts/build/binary_chroot new file mode 100755 index 0000000..d809b7f --- /dev/null +++ b/system-build/scripts/build/binary_chroot @@ -0,0 +1,101 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'copy chroot into chroot')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +Echo_message "Begin copying chroot..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_chroot + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Normally, virtual filesystems are not mounted here, but people tend to be lazy +if [ -f chroot/proc/version ] +then + umount chroot/proc +fi + +if [ -d chroot/sys/kernel ] +then + umount chroot/sys +fi + +if [ "${LB_BUILD_WITH_CHROOT}" = "false" ] +then + exit 0 +fi + +if [ "${LB_CACHE}" = "true" ] && Find_files cache/binary_rootfs/filesystem* +then + exit 0 +fi + +Echo_message "This may take a while." + +# Removing old chroot +rm -rf chroot/chroot +rm -rf chroot.tmp + +# Copying new chroot +if [ -d cache/bootstrap ] && [ "${LB_CHROOT_FILESYSTEM}" != "none" ] && [ "${LB_CHROOT_FILESYSTEM}" != "plain" ] +then + mv chroot chroot.tmp + cp -a cache/bootstrap chroot + touch chroot/chroot.cache +else + cp -a chroot chroot.tmp +fi + +mv chroot.tmp chroot/chroot + +# Handling chroot excludes +if [ -f config/rootfs/excludes ] && [ "${LB_CHROOT_FILESYSTEM}" != "squashfs" ] +then + case "${LB_BUILD_WITH_CHROOT}" in + true) + cp config/rootfs/excludes chroot/chroot/excludes + # Not using Chroot() here because we want explicitly /bin/bash (for the time being) + chroot chroot/chroot /usr/bin/env -i xargs --arg-file=/excludes -I FILE bash -c 'rm -rf FILE' + rm -f chroot/chroot/excludes + ;; + + false) + cp config/rootfs/excludes chroot/excludes + # Not using Chroot() here because we want explicitly /bin/bash (for the time being) + chroot chroot /usr/bin/env -i xargs --arg-file=/excludes -I FILE bash -c 'rm -rf FILE' + rm -f chroot/excludes + ;; + esac +fi + +# Creating stage file +Create_stagefile .build/binary_chroot diff --git a/system-build/scripts/build/binary_disk b/system-build/scripts/build/binary_disk new file mode 100755 index 0000000..7ddcc35 --- /dev/null +++ b/system-build/scripts/build/binary_disk @@ -0,0 +1,175 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'install disk information into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +case "${LIVE_IMAGE_TYPE}" in + iso*|hdd*) + ;; + *) + exit 0 + ;; +esac + +Echo_message "Begin installing disk information..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_disk + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +mkdir -p binary/.disk + +ARCHITECTURE="$(echo ${LB_ARCHITECTURES} | sed -e 's| |/|g')" +DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | cut -b 1 | tr '[a-z]' '[A-Z]')" +DISTRIBUTION="${DISTRIBUTION}$(echo ${LB_DISTRIBUTION} | cut -b 2-)" + +if [ -e chroot/etc/os-release ] +then + VERSION="$(. chroot/etc/os-release && echo ${VERSION_ID})" +fi + +VERSION="${VERSION:-none}" + +case "${LB_MODE}" in + debian) + TITLE="Debian GNU/Linux" + STRING="Official Snapshot ${ARCHITECTURE}" + TRACE="project/trace/ftp-master.debian.org" + ;; + + progress-linux) + TITLE="Progress Linux" + STRING="${VERSION} (${DISTRIBUTION}) - ${ARCHITECTURE}" + TRACE="project/trace/archive-master.progress-linux.org" + ;; + + *) + TITLE="Debian GNU/Linux" + STRING="Snapshot ${ARCHITECTURE}" + TRACE="" + ;; +esac + +if [ -n "${TRACE}" ] +then + case "${LB_DERIVATIVE}" in + true) + echo "$(echo ${LB_PARENT_MIRROR_BOOTSTRAP} | awk -F:// '{ print $2 }'): $(wget -q ${LB_PARENT_MIRROR_BOOTSTRAP}/${TRACE} -O - | head -n 1)" \ + > binary/.disk/archive_trace + + echo "$(echo ${LB_MIRROR_BOOTSTRAP} | awk -F:// '{ print $2 }'): $(wget -q ${LB_MIRROR_BOOTSTRAP}/${TRACE} -O - | head -n 1)" \ + >> binary/.disk/archive_trace + ;; + + false) + echo "$(wget -q ${LB_PARENT_MIRROR_BOOTSTRAP}/${TRACE} -O - | head -n 1)" \ + > binary/.disk/archive_trace + ;; + esac +fi + +case "${LB_DEBIAN_INSTALLER}" in + cdrom) + echo "main" > binary/.disk/base_components + + touch binary/.disk/base_installable + + echo "full_cd" > binary/.disk/cd_type + + echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/CD Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info + + for LOCATION in "${LIVE_BUILD}/data/debian-cd" /usr/share/live/build/data/debian-cd + do + if [ -e "${LOCATION}" ] + then + cp "${LOCATION}/${LB_PARENT_DISTRIBUTION}/${LB_ARCHITECTURES}_udeb_include" binary/.disk/udeb_include + + continue + fi + done + ;; + + true|netinst|live) + echo "main" > binary/.disk/base_components + + touch binary/.disk/base_installable + + if [ "${LB_DEBIAN_INSTALLER}" = "live" ] + then + echo "live" > binary/.disk/cd_type + echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/INSTALL Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info + else + echo "not_complete" > binary/.disk/cd_type + echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/NETINST Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info + fi + + for LOCATION in "${LIVE_BUILD}/data/debian-cd" /usr/share/live/build/data/debian-cd + do + if [ -e "${LOCATION}" ] + then + cp "${LOCATION}/${LB_PARENT_DISTRIBUTION}/${LB_ARCHITECTURES}_netinst_udeb_include" binary/.disk/udeb_include + + continue + fi + done + + if [ "${LB_DEBIAN_INSTALLER}" = "live" ] + then + echo "live-installer" >> binary/.disk/udeb_include + fi + ;; + + businesscard) + echo "main" > binary/.disk/base_components + + echo "not_complete" > binary/.disk/cd_type + + echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE/BC Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info + + for LOCATION in "${LIVE_BUILD}/data/debian-cd" /usr/share/live/build/data/debian-cd + do + if [ -e "${LOCATION}" ] + then + cp "${LOCATION}/${LB_PARENT_DISTRIBUTION}/${LB_ARCHITECTURES}_businesscard_udeb_include" binary/.disk/udeb_include + + continue + fi + done + ;; + + false) + echo "${TITLE} ${VERSION} \"${DISTRIBUTION}\" - ${STRING} LIVE Binary $(date +%Y%m%d-%H:%M)" > binary/.disk/info + ;; +esac + +# Creating stage file +Create_stagefile .build/binary_disk diff --git a/system-build/scripts/build/binary_grub-legacy b/system-build/scripts/build/binary_grub-legacy new file mode 100755 index 0000000..a9fb74b --- /dev/null +++ b/system-build/scripts/build/binary_grub-legacy @@ -0,0 +1,288 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'installs grub-legacy into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +FOUND_MYSELF="" +IFS="," +for BOOTLOADER in ${LB_BOOTLOADERS} +do + + case ${BOOTLOADER} in + "grub-legacy" ) + FOUND_MYSELF="True" + break ;; + esac + +done + +if [ -z ${FOUND_MYSELF} ] ; then + exit 0 +fi + +Echo_message "Begin installing grub-legacy..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_grub-legacy + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Check architecture +Check_architectures amd64 i386 +Check_crossarchitectures + +# Checking depends +Check_package chroot /usr/sbin/grub grub-legacy + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +# Local functions +Grub_live_entry () +{ + LABEL="${1}" + KERNEL="${2}" + INITRD="${3}" + APPEND="${4}" + + LINUX_LIVE="${LINUX_LIVE}\ntitle\t\tDebian GNU/Linux - ${LABEL}" + LINUX_LIVE="${LINUX_LIVE}\nkernel\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}" + LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}" +} + +Grub_install_entry () +{ + LABEL="${1}" + KERNEL="${2}" + INITRD="${3}" + APPEND="${4}" + + QAPPEND="quiet" + + for TYPE in Install Expert Rescue Auto + do + case "${TYPE}" in + Install) + TAPPEND="${APPEND} ${QAPPEND}" + ;; + + Expert) + TAPPEND="priority=low ${APPEND}" + ;; + + Rescue) + TAPPEND="rescue/enable=true ${APPEND} ${QAPPEND}" + ;; + + Auto) + TAPPEND="auto=true priority=critical ${APPEND} ${QAPPEND}" + ;; + esac + + case "${LABEL}" in + Text) + TYPE_SUFFIX="" + ;; + GUI) + TYPE_SUFFIX="gui" + ;; + esac + + + LINUX_INSTALL="${LINUX_INSTALL}\ntitle\t\t${LABEL} ${TYPE}" + LINUX_INSTALL="${LINUX_INSTALL}\nkernel\t\t/${KERNEL} ${TAPPEND} ${LB_BOOTAPPEND_INSTALL}" + LINUX_INSTALL="${LINUX_INSTALL}\ninitrd\t\t/${INITRD}" + done +} + +if [ -e "config/bootloaders/grub-legacy" ] +then + # Internal local copy + _SOURCE="config/bootloaders/grub-legacy" +else + # Internal system copy + if [ -n "${LIVE_BUILD}" ] + then + _SOURCE="${LIVE_BUILD}/share/bootloaders/grub-legacy" + else + _SOURCE="/usr/share/live/build/bootloaders/grub-legacy" + fi +fi + +case "${LB_INITRAMFS}" in + system-boot) + INITFS="live" + ;; + + *) + INITFS="" + ;; +esac + +# Setting destination directory +case "${LIVE_IMAGE_TYPE}" in + iso*|tar) + case "${LB_INITRAMFS}" in + system-boot) + DESTDIR_LIVE="binary/live" + ;; + + *) + DESTDIR_LIVE="binary/boot" + ;; + esac + + DESTDIR_INSTALL="binary/install" + ;; + + hdd*|netboot) + Echo_warning "Bootloader in this image type not yet supported by live-build." + Echo_warning "This would produce a not bootable image, aborting (FIXME)." + exit 1 + ;; +esac + +Check_multiarchitectures + +# Creating directory +mkdir -p "${DESTDIR_LIVE}" + +# Setting boot parameters +if [ "${LB_UNION_FILESYSTEM}" != "aufs" ] +then + LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}" +fi + +if [ -n "${LB_NET_COW_PATH}" ] +then + Echo_error "Net cow not yet supported on grub-legacy" + exit 1 +fi + +LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's| ||')" + +# Assembling kernel configuration + +# Default entries +DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')" +DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})" +DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')" + +Grub_live_entry "live" "$(basename ${DESTDIR_LIVE})/${DEFAULT_KERNEL}" "$(basename ${DESTDIR_LIVE})/${DEFAULT_INITRD}" + +if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ] +then + Grub_live_entry "live (fail-safe mode)" "$(basename ${DESTDIR_LIVE})/${DEFAULT_KERNEL}" "$(basename ${DESTDIR_LIVE})/${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}" +fi + +for KERNEL in chroot/boot/vmlinuz-* +do + VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')" + + Grub_live_entry "live, kernel ${VERSION}" "$(basename ${DESTDIR_LIVE})/$(basename ${KERNEL})" "$(basename ${DESTDIR_LIVE})/initrd.img-${VERSION}" + Grub_live_entry "live, kernel ${VERSION} (fail-safe mode)" "$(basename ${DESTDIR_LIVE})/$(basename ${KERNEL})" "$(basename ${DESTDIR_LIVE})/initrd.img-${VERSION}" "${LB_BOOTAPPEND_FAILSAFE}" +done + +LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')" + +# Assembling debian-installer configuration +if [ "${LB_DEBIAN_INSTALLER}" != "false" ] +then + LINUX_LIVE="title\t\tLive:\nroot\n\n${LINUX_LIVE}" + LINUX_INSTALL="title\t\tInstaller:\nroot" + + VMLINUZ_DI="install/vmlinuz" + INITRD_DI="install/initrd.gz" + APPEND_DI="vga=normal" + + VMLINUZ_GI="install/gtk/vmlinuz" + INITRD_GI="install/gtk/initrd.gz" + APPEND_GI="video=vesa:ywrap,mtrr vga=788" + + if [ -f "binary/${VMLINUZ_DI}" ] && [ -f "binary/${INITRD_DI}" ] + then + Grub_install_entry "Text" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}" + fi + + if [ -f "binary/${VMLINUZ_GI}" ] && [ -f "binary/${INITRD_GI}" ] + then + Grub_install_entry "GUI" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}" + fi +fi + +LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')" + +# Assembling memtest configuration +if [ -f "${DESTDIR_LIVE}"/memtest ] +then + MEMTEST="title\t\tOther:\nroot" + MEMTEST="${MEMTEST}\n\ntitle\t\t${LB_MEMTEST}\nkernel\t\t/$(basename ${DESTDIR_LIVE})/memtest" + MEMTEST="$(/bin/echo ${MEMTEST} | sed -e 's|//|/|g')" +fi + +# Copying templates +mkdir -p binary/boot/grub +cp -r "${_SOURCE}"/* binary/boot/grub + +case ${LIVE_IMAGE_TYPE} in + iso*) + FILES="chroot/usr/lib/grub/*/stage2_eltorito" + ;; + + hdd*|tar) + FILES="chroot/usr/lib/grub/*/stage1 chroot/usr/lib/grub/*/e2fs_stage1_5 chroot/usr/lib/grub/*/stage2" + ;; +esac + +if [ "${LB_BUILD_WITH_CHROOT}" = "false" ] +then + FILES="$(echo ${FILES} | sed -e 's|chroot||g')" +fi + +# Copying grub +cp ${FILES} binary/boot/grub + +sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" -e "s|MEMTEST|${MEMTEST}|" binary/boot/grub/menu.lst +sed -i -e "s#LB_BOOTAPPEND_INSTALL#${LB_BOOTAPPEND_INSTALL}#" -e "s#LB_BOOTAPPEND_LIVE#${LB_BOOTAPPEND_LIVE}#" binary/boot/grub/menu.lst + +sed -i -e 's|\ $||g' binary/boot/grub/menu.lst + +# Saving cache +Save_cache cache/packages.binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .build/binary_grub diff --git a/system-build/scripts/build/binary_grub-pc b/system-build/scripts/build/binary_grub-pc new file mode 100755 index 0000000..f3a6450 --- /dev/null +++ b/system-build/scripts/build/binary_grub-pc @@ -0,0 +1,263 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'installs grub-pc into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +FOUND_MYSELF="" +OLDIFS="$IFS" +IFS="," +for BOOTLOADER in ${LB_BOOTLOADERS} +do + + case ${BOOTLOADER} in + "grub-pc" ) + FOUND_MYSELF="True" + break ;; + esac + +done +IFS="$OLDIFS" + +if [ -z ${FOUND_MYSELF} ] ; then + exit 0 +fi + +Echo_message "Begin installing grub-pc..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_grub + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Check architecture +Check_architectures amd64 i386 +Check_crossarchitectures + +# Checking depends +Check_package chroot /usr/bin/grub-mkimage grub-pc + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +# Local functions +Grub_live_entry () +{ + LABEL="${1}" + KERNEL="${2}" + INITRD="${3}" + APPEND="${4}" + + LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {" + LINUX_LIVE="${LINUX_LIVE}\nlinux\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}" + LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}" + LINUX_LIVE="${LINUX_LIVE}\n}" +} + +Grub_install_entry () +{ + LABEL="${1}" + KERNEL="${2}" + INITRD="${3}" + APPEND="${4}" + + if [ "${LABEL}" != "rescue" ] && [ "${LABEL}" != "rescuegui" ] + then + APPEND="${APPEND} quiet" + fi + + LINUX_INSTALL="${LINUX_INSTALL}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {" + LINUX_INSTALL="${LINUX_INSTALL}\nlinux\t\t/${KERNEL} ${APPEND} LB_BOOTAPPEND_INSTALL" + LINUX_INSTALL="${LINUX_INSTALL}\ninitrd\t\t/${INITRD}" + LINUX_INSTALL="${LINUX_INSTALL}\n}" +} + +if [ -e "config/bootloaders/grub-pc" ] +then + # Internal local copy + _SOURCE="config/bootloaders/grub-pc" +else + # Internal system copy + if [ -n "${LIVE_BUILD}" ] + then + _SOURCE="${LIVE_BUILD}/share/bootloaders/grub-pc" + else + _SOURCE="/usr/share/live/build/bootloaders/grub-pc" + fi +fi + +case "${LB_INITRAMFS}" in + system-boot) + INITFS="live" + ;; + + *) + INITFS="" + ;; +esac + +# Setting destination directory +case "${LIVE_IMAGE_TYPE}" in + iso*|tar) + case "${LB_INITRAMFS}" in + system-boot) + DESTDIR_LIVE="binary/live" + ;; + + *) + DESTDIR_LIVE="binary/live" + ;; + esac + + DESTDIR_INSTALL="binary/install" + ;; + + hdd*|netboot) + Echo_warning "Bootloader in this image type not yet supported by live-build." + Echo_warning "This would produce a not bootable image, aborting (FIXME)." + exit 1 + ;; +esac + +Check_multiarchitectures + +# Creating directory +mkdir -p "${DESTDIR_LIVE}" + +# Setting boot parameters +if [ "${LB_UNION_FILESYSTEM}" != "aufs" ] +then + LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}" +fi + +if [ -n "${LB_NET_COW_PATH}" ] +then + Echo_error "Net cow not yet supported on grub" + exit 1 +fi + +LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's| ||')" + +# Assembling kernel configuration + +# Default entries +DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')" +DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})" +DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')" + +Grub_live_entry "live" "$(basename ${DESTDIR_LIVE})/${DEFAULT_KERNEL}" "$(basename ${DESTDIR_LIVE})/${DEFAULT_INITRD}" + +if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ] +then + Grub_live_entry "live (fail-safe mode)" "$(basename ${DESTDIR_LIVE})/${DEFAULT_KERNEL}" "$(basename ${DESTDIR_LIVE})/${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}" +fi + +for KERNEL in chroot/boot/vmlinuz-* +do + VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')" + + Grub_live_entry "live, kernel ${VERSION}" "$(basename ${DESTDIR_LIVE})/$(basename ${KERNEL})" "$(basename ${DESTDIR_LIVE})/initrd.img-${VERSION}" + Grub_live_entry "live, kernel ${VERSION} (fail-safe mode)" "$(basename ${DESTDIR_LIVE})/$(basename ${KERNEL})" "$(basename ${DESTDIR_LIVE})/initrd.img-${VERSION}" "${LB_BOOTAPPEND_FAILSAFE}" +done + +LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')" + +# Assembling debian-installer configuration +if [ "${LB_DEBIAN_INSTALLER}" != "false" ] +then + LINUX_LIVE="#\t \"Live\"\n${LINUX_LIVE}" + LINUX_INSTALL="#\t \"Installer\"\n" + + VMLINUZ_DI="install/vmlinuz" + INITRD_DI="install/initrd.gz" + APPEND_DI="vga=normal" + + VMLINUZ_GI="install/gtk/vmlinuz" + INITRD_GI="install/gtk/initrd.gz" + APPEND_GI="video=vesa:ywrap,mtrr vga=788" + + Grub_install_entry "install" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}" + Grub_install_entry "installgui" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}" + Grub_install_entry "expert" "${VMLINUZ_DI}" "${INITRD_DI}" "priority=low ${APPEND_DI}" + Grub_install_entry "expertgui" "${VMLINUZ_GI}" "${INITRD_GI}" "priority=low ${APPEND_GI}" + Grub_install_entry "rescue" "${VMLINUZ_DI}" "${INITRD_DI}" "rescue/enable=true ${APPEND_DI}" + Grub_install_entry "rescuegui" "${VMLINUZ_GI}" "${INITRD_GI}" "rescue/enable=true ${APPEND_GI}" + Grub_install_entry "auto" "${VMLINUZ_DI}" "${INITRD_DI}" "auto=true priority=critical ${APPEND_DI}" + Grub_install_entry "autogui" "${VMLINUZ_GI}" "${INITRD_GI}" "auto=true priority=critical ${APPEND_GI}" +fi + +LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')" + +# Assembling memtest configuration +if [ -f "${DESTDIR_LIVE}"/memtest ] +then + MEMTEST="#\t \"Other\"\n" + MEMTEST="${MEMTEST}\nmenuentry\t\"${LB_MEMTEST}\" {\nlinux16\t$(basename ${DESTDIR_LIVE})/memtest\n}" + MEMTEST="$(/bin/echo ${MEMTEST} | sed -e 's|//|/|g')" +fi + +# Copying templates +mkdir -p binary/boot/grub/i386-pc +cp -r "${_SOURCE}"/* binary/boot/grub + +case ${LIVE_IMAGE_TYPE} in + iso*) + FILES="chroot/usr/lib/grub/i386-pc/*.mod chroot/usr/lib/grub/i386-pc/*.lst chroot/usr/lib/grub/i386-pc/efiemu??.o chroot/usr/share/grub/*.pf2" + ;; + + hdd*|tar) + FILES="chroot/usr/lib/grub/i386-pc/*" + ;; +esac + +if [ "${LB_BUILD_WITH_CHROOT}" = "false" ] +then + FILES="$(echo ${FILES} | sed -e 's|chroot||g')" +fi + +# Copying grub +cp ${FILES} binary/boot/grub/i386-pc + +sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" -e "s|MEMTEST|${MEMTEST}|" binary/boot/grub/grub.cfg +sed -i -e "s#LB_BOOTAPPEND_INSTALL#${LB_BOOTAPPEND_INSTALL}#" -e "s#LB_BOOTAPPEND_LIVE#${LB_BOOTAPPEND_LIVE}#" binary/boot/grub/grub.cfg + +sed -i -e 's|\ $||g' binary/boot/grub/grub.cfg + +# Saving cache +Save_cache cache/packages.binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .build/binary_grub diff --git a/system-build/scripts/build/binary_hdd b/system-build/scripts/build/binary_hdd new file mode 100755 index 0000000..1e7489c --- /dev/null +++ b/system-build/scripts/build/binary_hdd @@ -0,0 +1,348 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build binary image')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if ! In_list hdd "${LIVE_IMAGE_TYPE}" +then + exit 0 +fi + +Echo_message "Begin building binary hdd image..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap .build/chroot_proc + +# Checking stage file +Check_stagefile .build/binary_hdd + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Checking depends +case "${LB_BINARY_FILESYSTEM}" in + fat*) + Check_package chroot /sbin/mkdosfs dosfstools + ;; + + ntfs) + Check_package chroot /sbin/mkfs.nfts ntfs-3g + ;; +esac + +Check_package chroot /usr/share/doc/mtools mtools +Check_package chroot /sbin/parted parted + +echo "${LB_BOOTLOADERS}" | \ +while IFS="," read -r BOOTLOADER +do + case "${BOOTLOADER}" in + grub) + Check_package chroot /usr/sbin/grub grub + ;; + esac +done + +LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }') + +case ${LB_PRIMARY_BOOTLOADER} in + syslinux) + case ${LB_BINARY_FILESYSTEM} in + fat*|ntfs) + _BOOTLOADER=syslinux + ;; + ext[234]|btrfs) + _BOOTLOADER=extlinux + ;; + *) + Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}" + exit 1 + ;; + esac + Check_package chroot /usr/bin/${_BOOTLOADER} ${_BOOTLOADER} + ;; +esac + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +# Remove old binary +if [ -f ${LIVE_iMAGE_NAME}.img ] +then + rm -f ${LIVE_iMAGE_NAME}.img +fi + +# Enforce fat32 if we find individual files bigger than 2GB +if [ "${LB_BINARY_FILESYSTEM}" = "fat16" ] && [ -n "$(find binary -size +1999M)" ] +then + Echo_warning "FAT16 doesn't support files larger than 2GB, automatically enforcing FAT32." + + LB_BINARY_FILESYSTEM="fat32" + export LB_BINARY_FILESYSTEM +fi + +# Enforce fat32 if we have images in total bigger than 2GB +if [ "${LB_BINARY_FILESYSTEM}" = "fat16" ] && [ "$(du -s binary | awk '{ print $1 }')" -gt "1900000" ] +then + Echo_warning "FAT16 doesn't support partitions larger than 2GB, automatically enforcing FAT32" + + LB_BINARY_FILESYSTEM="fat32" + export LB_BINARY_FILESYSTEM +fi + +# Enforce ntfs if we find individual files bigger than 4GB +if [ "${LB_BINARY_FILESYSTEM}" = "fat32" ] && [ -n "$(find binary -size +3999M)" ] +then + Echo_warning "FAT32 doesn't support files larger than 4GB, automatically enforcing NTFS." + + LB_BINARY_FILESYSTEM="ntfs" + export LB_BINARY_FILESYSTEM +fi + +# Everything which comes here needs to be cleaned up, +if [ "$LB_HDD_SIZE" = "auto" ]; +then + DU_DIM="$(du -ms binary | cut -f1)" + REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_BINARY_FILESYSTEM})" +else + REAL_DIM=$LB_HDD_SIZE +fi + +dd if=/dev/zero of=chroot/binary.img bs=1024k count=0 seek=${REAL_DIM} +FREELO="$(${LB_LOSETUP} -f)" +if [ ! -b chroot/${FREELO} ] +then + MAKEDEV="true" + + mv chroot/dev chroot/dev.tmp + find /dev | cpio -dmpu chroot +fi + +echo "!!! The following error/warning messages can be ignored !!!" +Losetup $FREELO chroot/binary.img 0 + +PARTITION_TABLE_TYPE="msdos" + +case "${LB_BINARY_FILESYSTEM}" in + ext2|ext3|ext4) + PARTITION_TYPE="ext2" + ;; + + fat16|fat32) + PARTITION_TYPE="${LB_BINARY_FILESYSTEM}" + ;; + + ntfs) + PARTITION_TYPE="NTFS" + ;; + + *) + Echo_error "Unsupported binary filesystem %s" "${LB_BINARY_FILESYSTEM}" + exit 1 + ;; +esac + +case "${LB_BUILD_WITH_CHROOT}" in + true) + Chroot chroot "parted -s ${FREELO} mklabel ${PARTITION_TABLE_TYPE}" || true + if [ "x${LB_HDD_PARTITION_START}" = "x" ]; + then + Chroot chroot "parted -a optimal -s ${FREELO} mkpart primary\ + ${PARTITION_TYPE} 0% 100%" || true + else + Echo_message "using partition start at ${LB_HDD_PARTITION_START}" + Chroot chroot "parted -s ${FREELO} mkpart primary ${PARTITION_TYPE}\ + ${LB_HDD_PARTITION_START} 100%" || true + fi + Chroot chroot "parted -s ${FREELO} set 1 boot on" || true + Chroot chroot "parted -s ${FREELO} set 1 lba off" || true + + if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ] + then + dd if=chroot/usr/lib/SYSLINUX/mbr.bin of=${FREELO} bs=440 count=1 + fi + ;; + + false) + parted -s ${FREELO} mklabel ${PARTITION_TABLE_TYPE} || true + if [ "x${LB_HDD_PARTITION_START}" = "x" ]; + then + parted -a optimal -s ${FREELO} mkpart primary ${PARTITION_TYPE}\ + 0% 100% || true + else + Echo_message "using partition start at ${LB_HDD_PARTITION_START}" + parted -s ${FREELO} mkpart primary ${PARTITION_TYPE}\ + ${LB_HDD_PARTITION_START} 100% || true + fi + parted -s "${FREELO}" set 1 boot on || true + parted -s "${FREELO}" set 1 lba off || true + + if [ "${LB_PRIMARY_BOOTLOADER}" = "syslinux" ] + then + dd if=/usr/lib/SYSLINUX/mbr.bin of=${FREELO} bs=440 count=1 + fi + ;; +esac + +Lodetach ${FREELO} + +FREELO="$(${LB_LOSETUP} -f)" +Losetup $FREELO chroot/binary.img 1 + +case "${LB_BINARY_FILESYSTEM}" in + ext2|ext3|ext4) + MKFS="${LB_BINARY_FILESYSTEM}" + MKFS_OPTIONS="-L ${LB_HDD_LABEL} -m 0 -O ^64bit" + MOUNT_OPTIONS="" + ;; + + fat16) + MKFS="vfat" + MKFS_OPTIONS="-F 16 -n ${LB_HDD_LABEL}" + MOUNT_OPTIONS="" + ;; + + fat32) + MKFS="vfat" + MKFS_OPTIONS="-F 32 -n ${LB_HDD_LABEL}" + MOUNT_OPTIONS="" + ;; + + ntfs) + MKFS="ntfs" + MKFS_OPTIONS="-L ${LB_HDD_LABEL}" + MOUNT_OPTIONS="-t ntfs-3g" + ;; +esac + +case "${LB_BUILD_WITH_CHROOT}" in + true) + Chroot chroot "mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO}" + ;; + + false) + mkfs.${MKFS} ${MKFS_OPTIONS} ${FREELO} + ;; +esac + +case "${LB_BINARY_FILESYSTEM}" in + fat*) + CP_OPTIONS="-r -L" + ;; + + *) + CP_OPTIONS="-a" + ;; +esac + +Echo_message "Copying binary contents into image..." + +mkdir -p chroot/binary.tmp +mount ${MOUNT_OPTIONS} ${FREELO} chroot/binary.tmp +cp -T ${CP_OPTIONS} binary/ chroot/binary.tmp + +FIXME() +{ +if [ "${LB_PRIMARY_BOOTLOADER}" = "grub" ] +then + +cat > chroot/grub.sh << EOF +cd binary.tmp +grub --batch << EOM +find /live/vmlinuz +EOM +EOF + + rootpartition="$(Chroot chroot 'sh grub.sh' 2>/dev/null | grep -A 1 'find /live/vmlinuz' | grep -v 'find /live/vmlinuz')" + hdddev="$(echo $rootpartition | sed -e 's|,[[:digit:]]||')" + echo "Root partition is $rootpartition, device is: $hdddev" + + echo "WAITING..." && read WAIT + +#cat > chroot/grub.sh << EOF +#grub --batch << EOM +#root $rootpartition +#setup $hdddev +#EOM +#EOF + +#Chroot chroot "sh grub.sh" + + rm -f chroot/grub.sh +fi +} + +case "${_BOOTLOADER}" in + syslinux) + _SYSLINUX_INSTALLER="syslinux ${FREELO}" + ;; + extlinux) + _SYSLINUX_INSTALLER="extlinux --install /binary.tmp/boot/extlinux" + ;; + *) + _SYSLINUX_INSTALLER="" + ;; +esac + +if [ -n "${_SYSLINUX_INSTALLER}" ] +then + case "${LB_BUILD_WITH_CHROOT}" in + true) + Chroot chroot "${_SYSLINUX_INSTALLER}" + ;; + false) + ${_SYSLINUX_INSTALLER} + ;; + esac +fi + +umount chroot/binary.tmp +rmdir chroot/binary.tmp + +Lodetach ${FREELO} + +echo "!!! The above error/warning messages can be ignored !!!" + +if [ -n "${MAKEDEV}" ] +then + rm -rf chroot/dev + mv chroot/dev.tmp chroot/dev +fi + +mv chroot/binary.img ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.img + +# Saving cache +Save_cache cache/packages.binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .build/binary_hdd diff --git a/system-build/scripts/build/binary_hooks b/system-build/scripts/build/binary_hooks new file mode 100755 index 0000000..0458ce9 --- /dev/null +++ b/system-build/scripts/build/binary_hooks @@ -0,0 +1,81 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'execute hooks in binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +Echo_message "Begin executing hooks..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_hooks + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +## Processing distribution hooks + +# Running hooks +for _HOOK in ${LB_BINARY_HOOKS} +do + for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks + do + for FILE in "${LOCATION}"/????-"${_HOOK}".binary + do + if [ -e "${FILE}" ] + then + cd binary + "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + cd "${OLDPWD}" + fi + done + done +done + +## Processing local hooks +for HOOK in config/hooks/normal/*.binary config/hooks/live/*.binary +do + if [ ! -e "${HOOK}" ] + then + continue + fi + + # Making hook executable + if [ ! -x "${HOOK}" ] + then + chmod +x "${HOOK}" + fi + + # Executing hook + cd binary + ../"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + cd "${OLDPWD}" +done + +# Creating stage file +Create_stagefile .build/binary_hooks diff --git a/system-build/scripts/build/binary_includes b/system-build/scripts/build/binary_includes new file mode 100755 index 0000000..48bb6e5 --- /dev/null +++ b/system-build/scripts/build/binary_includes @@ -0,0 +1,57 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'copy files into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +Echo_message "Begin copying binary includes..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/includes.binary + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +if Find_files config/includes.binary/ +then + # Copying includes + cd config/includes.binary + find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/binary + cd "${OLDPWD}" + + # Removing symlinks + case "${LIVE_IMAGE_TYPE}" in + hdd*) + find binary -type l | xargs rm -f + ;; + esac + + # Creating stage file + Create_stagefile .build/binary_includes +fi diff --git a/system-build/scripts/build/binary_iso b/system-build/scripts/build/binary_iso new file mode 100755 index 0000000..bd659a2 --- /dev/null +++ b/system-build/scripts/build/binary_iso @@ -0,0 +1,220 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build iso binary image')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +case "${LIVE_IMAGE_TYPE}" in + iso) + IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.iso" + ;; + + iso-hybrid) + IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso" + ;; + + *) + exit 0 + ;; +esac + +Echo_message "Begin building binary iso image..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_iso + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Checking depends +Check_package chroot /usr/bin/xorriso xorriso +Check_package chroot /usr/lib/ISOLINUX/isohdpfx.bin isolinux + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +# Remove old iso image +if [ -f ${IMAGE} ] +then + rm -f ${IMAGE} +fi + +# Handle xorriso generic options +XORRISO_OPTIONS="-R -r -J -joliet-long -l -cache-inodes -iso-level 3" + +# Handle xorriso live-build specific options +if [ "${LIVE_IMAGE_TYPE}" = "iso-hybrid" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -partition_offset 16" +fi + +if [ "${_QUIET}" = "true" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -quiet" +fi + +if [ "${_VERBOSE}" = "true" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -v" +fi + +if [ -n "${LB_ISO_APPLICATION}" ] && [ "${LB_ISO_APPLICATION}" != "none" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -A \"${LB_ISO_APPLICATION}\"" +fi + +if [ -n "${LB_ISO_PREPARER}" ] && [ "${LB_ISO_PREPARER}" != "none" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -p \"${LB_ISO_PREPARER}\"" +fi + +if [ -n "${LB_ISO_PUBLISHER}" ] && [ "${LB_ISO_PUBLISHER}" != "none" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -publisher \"${LB_ISO_PUBLISHER}\"" +fi + +if [ -n "${LB_ISO_VOLUME}" ] && [ "${LB_ISO_VOLUME}" != "none" ] +then + XORRISO_OPTIONS="${XORRISO_OPTIONS} -V \"${LB_ISO_VOLUME}\"" +fi + +# Set an explicit modification date +XORRISO_OPTIONS="${XORRISO_OPTIONS} --modification-date=$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m%d%H%m%S00)" + +LB_PRIMARY_BOOTLOADER=$(echo "${LB_BOOTLOADERS}" | awk -F, '{ print $1 }') + +# Handle xorriso architecture specific options +case "${LB_PRIMARY_BOOTLOADER}" in + grub) + XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table" + XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito" + XORRISO_EXCLUDE="boot/grub/stage2_eltorito" + ;; + + grub-pc) + XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table" + XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J" + XORRISO_EXCLUDE="boot/grub/grub_eltorito" + ;; + + syslinux) + case "${LB_MODE}" in + progress-linux) + XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat" + XORRISO_EXCLUDE="boot/boot.bin" + ;; + + *) + XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat" + XORRISO_EXCLUDE="isolinux/isolinux.bin" + ;; + esac + + XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table" + ;; + + *) + Echo_warning "Bootloader on your architecture not yet supported by live-build." + Echo_warning "This will produce a most likely not bootable image (Continuing in 5 seconds)." + sleep 5 + ;; +esac + +#if [ "${LB_DEBIAN_INSTALLER}" != "live" ] +#then +# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}" +#fi + +if [ "${LB_PRIMARY_BOOTLOADER}" = "grub-pc" ] +then + +cat > binary.sh << EOF +#!/bin/sh + +input_dir=/usr/lib/grub/i386-pc + +# build core.img +core_img=\$(mktemp) +grub-mkimage -d \${input_dir} -o \${core_img} -O i386-pc biosdisk iso9660 + +# build grub_eltorito image +cat \${input_dir}/cdboot.img \${core_img} > binary/boot/grub/grub_eltorito + +rm -f \${core_img} + +for file in \${input_dir}/*.mod \${input_dir}/efiemu??.o \ + \${input_dir}/command.lst \${input_dir}/moddep.lst \${input_dir}/fs.lst \ + \${input_dir}/handler.lst \${input_dir}/parttool.lst +do + if test -f "\$file" + then + cp -f "\$file" binary/boot/grub/i386-pc + fi +done +EOF + +else + echo "#!/bin/sh" > binary.sh +fi + +cat >> binary.sh << EOF + +xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary +EOF + +case "${LB_BUILD_WITH_CHROOT}" in + true) + # Moving image + mv binary.sh chroot + mv binary chroot + + Chroot chroot "sh binary.sh" + + # Move image + mv chroot/binary chroot/${IMAGE} ./ + rm -f chroot/binary.sh + ;; + + false) + sh binary.sh + rm -f binary.sh + ;; +esac + +# Saving cache +Save_cache cache/packages.binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .build/binary_iso diff --git a/system-build/scripts/build/binary_linux-image b/system-build/scripts/build/binary_linux-image new file mode 100755 index 0000000..34676ce --- /dev/null +++ b/system-build/scripts/build/binary_linux-image @@ -0,0 +1,85 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'install linux-image into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LB_LINUX_PACKAGES}" = "none" ] +then + exit 0 +fi + +Echo_message "Begin install linux-image..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_linux-image + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +case "${LB_INITRAMFS}" in + system-boot) + DESTDIR="binary/live" + ;; + + *) + DESTDIR="binary/boot" + ;; +esac + +case "${LB_ARCHITECTURES}" in + powerpc) + LINUX="vmlinux" + ;; + + *) + LINUX="vmlinuz" + ;; +esac + +Check_multiarchitectures + +# Creating directory +mkdir -p "${DESTDIR}" + +# Installing linux-image +cp chroot/boot/"${LINUX}"-* "${DESTDIR}" +cp chroot/boot/initrd.img-* "${DESTDIR}" + +case "${LB_INITRAMFS}" in + system-boot) + if ls chroot/usr/share/doc/*system-boot/parameters.txt > /dev/null 2>&1 + then + cp chroot/usr/share/doc/*system-boot/parameters.txt "${DESTDIR}"/parameters + fi + ;; +esac + +# Creating stage file +Create_stagefile .build/binary_linux-image diff --git a/system-build/scripts/build/binary_loadlin b/system-build/scripts/build/binary_loadlin new file mode 100755 index 0000000..1fed0a5 --- /dev/null +++ b/system-build/scripts/build/binary_loadlin @@ -0,0 +1,102 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'copy loadlin into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LB_LOADLIN}" != "true" ] || [ "${LB_BINARY_IMAGES}" = "netboot" ] +then + exit 0 +fi + +Echo_message "Begin copying loadlin..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_loadlin + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +case "${LB_ARCHITECTURES}" in + amd64|i386) + case "${LB_BUILD_WITH_CHROOT}" in + true) + # Checking depends + Check_package chroot /usr/lib/loadlin/loadlin.exe.gz loadlin + + # Restoring cache + Restore_cache cache/packages.binary + + # Installing depends + Install_package + + _PREFIX="chroot" + ;; + + false) + _PREFIX="" + ;; + esac + + # Copying loadlin + mkdir -p binary/tools + gunzip -c "${_PREFIX}/usr/lib/loadlin/loadlin.exe.gz" > binary/tools/loadlin.exe + gunzip -c "${_PREFIX}/usr/share/doc/loadlin/manual.txt.gz" > binary/tools/loadlin.txt + + case "${LB_BUILD_WITH_CHROOT}" in + true) + # Saving cache + Save_cache cache/packages.binary + + # Removing depends + Remove_package + ;; + esac + +cat > binary/install/install.bat << EOF +\tools\loadlin.exe vmlinuz initrd=initrd.gz +EOF + + if [ -e binary/install/gtk ] + then + +cat > binary/install/gtk/install.bat << EOF +\tools\loadlin.exe \install\vmlinuz initrd=initrd.gz vga=788 +EOF + + fi + + # Creating stage file + Create_stagefile .build/binary_loadlin + ;; + + *) + Echo_warning "loadlin inclusion is set to true but not compatible with your architecture, ignoring." + ;; +esac diff --git a/system-build/scripts/build/binary_loopback_cfg b/system-build/scripts/build/binary_loopback_cfg new file mode 100755 index 0000000..87c1d67 --- /dev/null +++ b/system-build/scripts/build/binary_loopback_cfg @@ -0,0 +1,341 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'installs loopback.cfg into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +# We avoid checking if we need to be running this bootloader +# on purpose. The reason: You will always want to have +# a loopback.cfg file +# TODO: Add an option to be able to disable this file creation +Echo_message "Begin installing loopback.cfg..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_loopback_cfg + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Check architecture +Check_architectures amd64 i386 +Check_crossarchitectures + +# Local functions +Grub_live_entry_commands () +{ + local KERNEL="${1}" + local INITRD="${2}" + local APPEND="${3}" + + LINUX_LIVE="${LINUX_LIVE}\nlinux\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}" + LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}" +} + +Grub_live_entry () +{ + local LABEL="${1}" + local KERNEL="${2}" + local INITRD="${3}" + local APPEND="${4}" + + LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {" + Grub_live_entry_commands "${KERNEL}" "${INITRD}" "${APPEND} findiso=\${iso_path}" + LINUX_LIVE="${LINUX_LIVE}\n}" +} + +Grub_live_autodetect_entry () +{ + local LABEL="${1}" + local AMD64_KERNEL="${2}" + local AMD64_INITRD="${3}" + local _486_KERNEL="${4}" + local _486_INITRD="${5}" + local APPEND="${6}" + + LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {" + LINUX_LIVE="${LINUX_LIVE}\nif cpuid -l ; then" + Grub_live_entry_commands "${AMD64_KERNEL}" "${AMD64_INITRD}" "${APPEND} findiso=\${iso_path}" + LINUX_LIVE="${LINUX_LIVE}\nelse" + Grub_live_entry_commands "${_486_KERNEL}" "${_486_INITRD}" "${APPEND} findiso=\${iso_path}" + LINUX_LIVE="${LINUX_LIVE}\nfi" + LINUX_LIVE="${LINUX_LIVE}\n}" +} + +if [ -e "config/bootloaders/grub-pc" ] +then + # Internal local copy + _SOURCE="config/bootloaders/grub-pc" +else + # Internal system copy + if [ -n "${LIVE_BUILD}" ] + then + _SOURCE="${LIVE_BUILD}/share/bootloaders/grub-pc" + else + _SOURCE="/usr/share/live/build/bootloaders/grub-pc" + fi +fi + +case "${LB_INITRAMFS}" in + system-boot) + INITFS="live" + ;; + + *) + INITFS="" + ;; +esac + +# Assembling image specifics +case "${LIVE_IMAGE_TYPE}" in + iso*) + _BOOTLOADER="isolinux" + + case "${LB_MODE}" in + progress-linux) + _TARGET="binary/boot" + ;; + + *) + _TARGET="binary/isolinux" + ;; + esac + ;; + + netboot) + _BOOTLOADER="pxelinux" + _TARGET="tftpboot" + ;; + + hdd*|*) + case ${LB_BINARY_FILESYSTEM} in + fat*|ntfs) + _BOOTLOADER=syslinux + + case "${LB_MODE}" in + progress-linux) + _TARGET="binary/boot" + ;; + + *) + _TARGET="binary/syslinux" + ;; + esac + ;; + + ext[234]|btrfs) + _BOOTLOADER=extlinux + _TARGET="binary/boot/extlinux" + ;; + *) + Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}" + exit 1 + ;; + esac + ;; +esac + +DESTDIR_LIVE="${_TARGET}" + +Check_multiarchitectures + +# Creating directory +mkdir -p "${DESTDIR_LIVE}" + +# Setting boot parameters +if [ "${LB_UNION_FILESYSTEM}" != "aufs" ] +then + LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}" +fi + +if [ -n "${LB_NET_COW_PATH}" ] +then + Echo_error "Net cow not yet supported on grub" + exit 1 +fi + +LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's| ||')" + +# Assembling kernel configuration +# If Bootloader is not syslinux that means +# binary_syslinux it's not going to rename kernel filenames in a later stage. +# We will use binary_grub2 algorithm which does not rename kernel filenames. + +FOUND_SYSLINUX="" +OLDIFS="$IFS" +IFS="," +for BOOTLOADER in ${LB_BOOTLOADERS} +do + + case ${BOOTLOADER} in + "syslinux" ) + FOUND_SYSLINUX="True" + break ;; + esac + +done +IFS="$OLDIFS" + +if [ -z ${FOUND_SYSLINUX} ] +then + + _AMD64_486_NUMBER="0" + + for _FLAVOUR in ${LB_LINUX_FLAVOURS} + do + if [ "${_FLAVOUR}" = "amd64" -o "${_FLAVOUR}" = "486" ] ; then + _AMD64_486_NUMBER="$((${_AMD64_486_NUMBER} + 1))" + fi + done + + if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then + # Default entries + AMD64_KERNEL="$(basename chroot/boot/vmlinuz-*amd64)" + AMD64_INITRD="initrd.img-$(echo ${AMD64_KERNEL} | sed -e 's|vmlinuz-||')" + _486_KERNEL="$(basename chroot/boot/vmlinuz-*486)" + _486_INITRD="initrd.img-$(echo ${_486_KERNEL} | sed -e 's|vmlinuz-||')" + + Grub_live_autodetect_entry "live (autodetect)" \ + "${INITFS}/${AMD64_KERNEL}" \ + "${INITFS}/${AMD64_INITRD}" \ + "${INITFS}/${_486_KERNEL}" \ + "${INITFS}/${_486_INITRD}" + fi + + # Default entries + DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')" + DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})" + DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')" + + Grub_live_entry "live" "${INITFS}/${DEFAULT_KERNEL}" "${INITFS}/${DEFAULT_INITRD}" + + if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ] + then + Grub_live_entry "live (fail-safe mode)" "${INITFS}/${DEFAULT_KERNEL}" "${INITFS}/${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}" + fi + + for KERNEL in chroot/boot/vmlinuz-* + do + VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')" + + Grub_live_entry "live, kernel ${VERSION}" "${INITFS}/$(basename ${KERNEL})" "${INITFS}/initrd.img-${VERSION}" + Grub_live_entry "live, kernel ${VERSION} (fail-safe mode)" "${INITFS}/$(basename ${KERNEL})" "${INITFS}/initrd.img-${VERSION}" "${LB_BOOTAPPEND_FAILSAFE}" + done +else # LB_BOOTLOADERS does not contain syslinux +# If one of the bootloader is syslinux that means +# binary_syslinux it's going to rename kernel filenames. +# We will use binary_syslinux algorithm but without renaming kernel filenames. +# That will ensure binary_syslinux will find the original kernel filenames. + #if [ -e "${_TARGET}/live.cfg.in" ] + #then + # This is all rather suboptimal.. needs prettifying at some point + _FLAVOURS="$(echo ${LB_LINUX_FLAVOURS} | wc -w)" + + case "${_FLAVOURS}" in + 1) + Grub_live_entry "live (${LB_LINUX_FLAVOURS})" "${INITFS}/vmlinuz" "${INITFS}/initrd.img" "${LB_BOOTAPPEND_LIVE}" + Grub_live_entry "live (${LB_LINUX_FLAVOURS}) (failsafe mode)" "${INITFS}/vmlinuz" "${INITFS}/initrd.img" "${LB_BOOTAPPEND_LIVE_FAILSAFE}" + ;; + + *) + _AMD64_486_NUMBER="0" + + for _FLAVOUR in ${LB_LINUX_FLAVOURS} + do + if [ "${_FLAVOUR}" = "amd64" -o "${_FLAVOUR}" = "486" ] ; then + _AMD64_486_NUMBER="$((${_AMD64_486_NUMBER} + 1))" + fi + done + + _NUMBER="0" + for _FLAVOUR in ${LB_LINUX_FLAVOURS} + do + _NUMBER="$((${_NUMBER} + 1))" + if [ "${_FLAVOUR}" = "amd64" ] ; then + AMD64_KERNEL="vmlinuz${_NUMBER}" + AMD64_INITRD="initrd${_NUMBER}.img" + fi + + if [ "${_FLAVOUR}" = "486" ] ; then + _486_KERNEL="vmlinuz${_NUMBER}" + _486_INITRD="initrd${_NUMBER}.img" + fi + done + + _NUMBER="0" + + for _FLAVOUR in ${LB_LINUX_FLAVOURS} + do + _NUMBER="$((${_NUMBER} + 1))" + + if [ "${_NUMBER}" -gt 1 ] + then + Grub_live_entry "live (${_FLAVOUR})" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE}" + Grub_live_entry "live (${_FLAVOUR}) (failsafe mode)" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE_FAILSAFE}" + + else + if [ "${_AMD64_486_NUMBER}" -ge 2 ] ; then + + Grub_live_autodetect_entry "live (autodetect)" \ + "${INITFS}/${AMD64_KERNEL}" \ + "${INITFS}/${AMD64_INITRD}" \ + "${INITFS}/${_486_KERNEL}" \ + "${INITFS}/${_486_INITRD}" + fi + + Grub_live_entry "live (${_FLAVOUR})" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE}" + Grub_live_entry "live (${_FLAVOUR}) (failsafe mode)" "${INITFS}/vmlinuz${_NUMBER}" "${INITFS}/initrd${_NUMBER}.img" "${LB_BOOTAPPEND_LIVE_FAILSAFE}" + fi + + done + + ;; + esac + #fi +fi +LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')" + +# Assembling memtest configuration +if [ -f "${DESTDIR_LIVE}"/memtest ] +then + MEMTEST="#\t \"Other\"\n" + MEMTEST="${MEMTEST}\nmenuentry\t\"${LB_MEMTEST}\" {\nlinux16\t${INITFS}/memtest\n}" + MEMTEST="$(/bin/echo ${MEMTEST} | sed -e 's|//|/|g')" +fi + +# Copying templates +mkdir -p binary/boot/grub +cp "${_SOURCE}"/grub.cfg binary/boot/grub/loopback.cfg + +sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL||" -e "s|MEMTEST|${MEMTEST}|" binary/boot/grub/loopback.cfg +sed -i -e "s#LB_BOOTAPPEND_INSTALL##" -e "s#LB_BOOTAPPEND_LIVE#${LB_BOOTAPPEND_LIVE}#" binary/boot/grub/loopback.cfg + +sed -i -e 's|\ $||g' binary/boot/grub/loopback.cfg + +# Creating stage file +Create_stagefile .build/binary_loopback_cfg diff --git a/system-build/scripts/build/binary_manifest b/system-build/scripts/build/binary_manifest new file mode 100755 index 0000000..55c6520 --- /dev/null +++ b/system-build/scripts/build/binary_manifest @@ -0,0 +1,68 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'create manifest')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LB_CHROOT_FILESYSTEM}" = "none" ] +then + exit 0 +fi + +Echo_message "Begin creating manifest..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_manifest + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +case "${LB_INITRAMFS}" in + system-boot) + INITFS="live" + SUFFIX="packages" + ;; + + *) + INITFS="boot" + SUFFIX="packages" + ;; +esac + +# Add filesystem.packages +cp chroot.packages.live "binary/${INITFS}/filesystem.${SUFFIX}" +echo "$(diff chroot.packages.live chroot.packages.install | awk '/^< / { print $2 }')" \ + > "binary/${INITFS}/filesystem.${SUFFIX}-remove" + +cp chroot.packages.live ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.packages + +cp chroot.files ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.files + +# Creating stage file +Create_stagefile .build/binary_manifest diff --git a/system-build/scripts/build/binary_memtest b/system-build/scripts/build/binary_memtest new file mode 100755 index 0000000..1ce4195 --- /dev/null +++ b/system-build/scripts/build/binary_memtest @@ -0,0 +1,120 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'installs a memtest into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LB_MEMTEST}" = "false" ] || [ "${LB_MEMTEST}" = "none" ] || [ "${LB_CHROOT_FILESYSTEM}" = "none" ] +then + exit 0 +fi + +Echo_message "Begin installing memtest..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_memtest + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +if [ "${LB_ARCHITECTURES}" != "amd64" ] && [ "${LB_ARCHITECTURES}" != "i386" ] +then + Echo_warning "skipping binary_memtest, foreign architecture." + exit 0 +fi + +if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] +then + + if [ -f chroot/usr/sbin/grub ] && [ ! -f chroot/boot/grub/menu.lst ] + then + GRUB="yes" + + mkdir -p chroot/boot/grub + touch chroot/boot/grub/menu.lst + fi +fi + +# Checking depends +case "${LB_MEMTEST}" in + memtest86) + Check_package chroot /boot/memtest86.bin memtest86 + ;; + + memtest86+) + Check_package chroot /boot/memtest86+.bin memtest86+ + ;; +esac + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +# Setting destination directory +case "${LB_INITRAMFS}" in + system-boot) + DESTDIR="binary/live" + ;; + + *) + DESTDIR="binary/boot" + ;; +esac + +Check_multiarchitectures + +# Creating directory +mkdir -p "${DESTDIR}" + +# Installing memtest +case "${LB_BUILD_WITH_CHROOT}" in + true) + cp chroot/boot/${LB_MEMTEST}.bin "${DESTDIR}"/memtest + ;; + + false) + cp /boot/${LB_MEMTEST}.bin "${DESTDIR}"/memtest + ;; +esac + +# Saving cache +Save_cache cache/packages.binary + +# Removing depends +Remove_package + +if [ "${GRUB}" ] +then + rm -rf chroot/boot/grub +fi + +# Creating stage file +Create_stagefile .build/binary_memtest diff --git a/system-build/scripts/build/binary_netboot b/system-build/scripts/build/binary_netboot new file mode 100755 index 0000000..d8cfe51 --- /dev/null +++ b/system-build/scripts/build/binary_netboot @@ -0,0 +1,113 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build netboot binary image')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if ! In_list netboot "${LIVE_IMAGE_TYPE}" +then + exit 0 +fi + +if [ "${LB_NET_TARBALL}" = "false" ] +then + exit 0 +fi + +Echo_message "Begin building binary netboot image..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_netboot + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Remove old binary +rm -f ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.gz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.bz2 ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.xz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar.xz + +# Creating image file +ROOT_DIR=$(basename ${LB_NET_ROOT_PATH}) + +if [ "${ROOT_DIR}" = "chroot" ] +then + mv chroot chroot.tmp +fi + +if [ "${ROOT_DIR}" != "binary" ] +then + mv binary ${ROOT_DIR} +fi + +mkdir binary.tmp +mv ${ROOT_DIR} tftpboot binary.tmp +cd binary.tmp + +# Moving kernel and initrd image arround +mkdir tftpboot/live +mv */live/vmlinuz* */live/initrd* tftpboot/live + +tar cf ../${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar * + +case "${LB_COMPRESSION}" in + bzip2) + bzip2 ${BZIP2_OPTIONS} ../${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar + ;; + + gzip) + gzip ${GZIP_OPTIONS} ../${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar + ;; + + lzip) + lzip ${LZIP_OPTIONS} ../${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar + ;; + + xz) + xz ${XZ_OPTIONS} ../${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar + ;; + + none) + ;; +esac + +mv * ../ +cd "${OLDPWD}" +rmdir binary.tmp + +if [ "${ROOT_DIR}" != "binary" ] +then + mv ${ROOT_DIR} binary +fi + +if [ "${ROOT_DIR}" = "chroot" ] +then + mv chroot.tmp chroot +fi + +# Creating stage file +Create_stagefile .build/binary_netboot diff --git a/system-build/scripts/build/binary_package-lists b/system-build/scripts/build/binary_package-lists new file mode 100755 index 0000000..fc47154 --- /dev/null +++ b/system-build/scripts/build/binary_package-lists @@ -0,0 +1,178 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'install local packages into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +Echo_message "Begin installing local package lists..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_package-lists + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +case "${LB_MODE}" in + progress-linux) + DISTS="installer/dists" + POOL="installer/pool" + ;; + + *) + DISTS="dists" + POOL="pool" + ;; +esac + +if ls config/package-lists/*.list > /dev/null 2>&1 || \ + ls config/package-lists/*.list.binary > /dev/null 2>&1 +then + # Check depends + Check_package host /usr/bin/apt-ftparchive apt-utils + + case "${LB_BUILD_WITH_CHROOT}" in + true) + # Restoring cache + Restore_cache cache/packages.chroot + + # Check depends + Check_package chroot /usr/bin/grep-aptavail dctrl-tools + + # Installing depends + Install_package + ;; + + false) + Check_package host /usr/bin/grep-aptavail dctrl-tools + ;; + esac + + if [ -e "${LIVE_BUILD}/share/bin/Packages" ] + then + cp "${LIVE_BUILD}/share/bin/Packages" chroot/bin + else + cp /usr/share/live/build/bin/Packages chroot/bin + fi + + mkdir -p chroot/binary.deb/archives/partial + mv chroot/var/lib/dpkg/status chroot/var/lib/dpkg/status.tmp + touch chroot/var/lib/dpkg/status + + for LIST in config/package-lists/*.list \ + config/package-lists/*.list.binary + do + if [ -e "${LIST}" ] + then + # Generate package list + Expand_packagelist "${LIST}" "config/package-lists" > chroot/root/"$(basename ${LIST})" + + # Downloading additional packages + Chroot chroot "xargs --no-run-if-empty --arg-file=/root/$(basename ${LIST}) apt-get ${APT_OPTIONS} -o Dir::Cache=/binary.deb --download-only install" + + # Remove package list + rm chroot/root/"$(basename ${LIST})" + fi + done + + for FILE in chroot/binary.deb/archives/*.deb + do + if [ ! -e ${FILE} ]; then + break # Do nothing if the package lists were empty... + fi + + SOURCE="$(dpkg -f ${FILE} Source | awk '{ print $1 }')" + SECTION="$(dpkg -f ${FILE} Section | awk '{ print $1 }')" + + if [ -z "${SOURCE}" ] + then + SOURCE="$(basename ${FILE} | awk -F_ '{ print $1 }')" + fi + + case "${SOURCE}" in + lib?*) + LETTER="$(echo ${SOURCE} | sed 's|\(....\).*|\1|')" + ;; + + *) + LETTER="$(echo ${SOURCE} | sed 's|\(.\).*|\1|')" + ;; + esac + + if echo "${SECTION}" | grep -qs contrib + then + SECTION="contrib" + elif echo "${SECTION}" | grep -qs non-free + then + SECTION="non-free" + else + SECTION="main" + fi + + # Install directory + mkdir -p binary/${POOL}/${SECTION}/"${LETTER}"/"${SOURCE}" + + # Move files + mv "${FILE}" binary/${POOL}/${SECTION}/"${LETTER}"/"${SOURCE}" + done + + cd binary + + for SECTION in ${POOL}/* + do + if [ ! -d "${SECTION}" ]; then + break # Do nothing if the package lists were empty... + fi + + SECTION="$(basename ${SECTION})" + + mkdir -p ${DISTS}/${LB_PARENT_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURES} + apt-ftparchive packages ${POOL}/${SECTION} > ${DISTS}/${LB_PARENT_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURES}/Packages + gzip -9 -c ${DISTS}/${LB_PARENT_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURES}/Packages > ${DISTS}/${LB_PARENT_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURES}/Packages.gz + done + + cd "${OLDPWD}" + + rm -f chroot/bin/Packages + + rm -rf chroot/binary.deb + mv chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status + + case "${LB_BUILD_WITH_CHROOT}" in + true) + # Removing depends + Remove_package + + # Saving cache + Save_cache cache/packages.chroot + ;; + esac + + # Creating stage file + Create_stagefile .build/binary_package-lists +fi diff --git a/system-build/scripts/build/binary_rootfs b/system-build/scripts/build/binary_rootfs new file mode 100755 index 0000000..f230d17 --- /dev/null +++ b/system-build/scripts/build/binary_rootfs @@ -0,0 +1,462 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build rootfs image')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +Echo_message "Begin building root filesystem image..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap .build/binary_chroot + +# Checking stage file +Check_stagefile .build/binary_rootfs + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +case "${LB_ARCHITECTURES}" in + amd64|i386) + LINUX="vmlinuz" + ;; + + powerpc) + LINUX="vmlinux" + ;; +esac + +case "${LB_INITRAMFS}" in + system-boot) + INITFS="live" + ;; + + *) + INITFS="boot" + ;; +esac + +# Creating directory +mkdir -p binary/${INITFS} + +for STAGE in ${LB_CACHE_STAGES} +do + if [ "${STAGE}" = "rootfs" ] && [ -d cache/binary_rootfs ] + then + # Removing old chroot + rm -rf binary/"${INITFS}"/filesystem.* + + # Restoring old cache + mkdir -p binary/"${INITFS}" + cp -a cache/binary_rootfs/filesystem.* binary/"${INITFS}" + + # Creating stage file + Create_stagefile .build/binary_rootfs + exit 0 + fi +done + +case "${LB_CHROOT_FILESYSTEM}" in + ext2|ext3|ext4) + # Checking depends + Check_package chroot /sbin/mkfs.${LB_CHROOT_FILESYSTEM} e2fsprogs + + # Restoring cache + Restore_cache cache/packages.binary + + # Installing depends + Install_package + + # Remove old image + if [ -f binary/${INITFS}/filesystem.${LB_CHROOT_FILESYSTEM} ] + then + rm -f binary/${INITFS}/filesystem.${LB_CHROOT_FILESYSTEM} + fi + + case "${LB_BUILD_WITH_CHROOT}" in + true) + DU_DIM="$(du -ms chroot/chroot | cut -f1)" + INODES="$(find chroot/chroot | wc -l)" + ;; + + false) + DU_DIM="$(du -ms chroot | cut -f1)" + INODES="$(find chroot | wc -l)" + ;; + esac + + REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_CHROOT_FILESYSTEM})" + REAL_INODES="$(Calculate_partition_size ${INODES} ${LB_CHROOT_FILESYSTEM})" + + case "${LB_BUILD_WITH_CHROOT}" in + true) + dd if=/dev/zero of=chroot/filesystem.${LB_CHROOT_FILESYSTEM} bs=1024k count=0 seek=${REAL_DIM} + + if ! Chroot chroot "test -s /etc/mtab" + then + Chroot chroot "ln -s /proc/mounts/mtab /etc/mtab" + FAKE_MTAB="true" + fi + + Chroot chroot "mkfs.${LB_CHROOT_FILESYSTEM} -F -b 1024 -N ${REAL_INODES} -m 0 filesystem.${LB_CHROOT_FILESYSTEM}" + + mkdir -p filesystem.tmp + mount -o loop chroot/filesystem.${LB_CHROOT_FILESYSTEM} filesystem.tmp + cp -a chroot/chroot/* filesystem.tmp + + if [ "${FAKE_MTAB}" = "true" ] + then + Chroot chroot "rm -f /etc/mtab" + fi + + umount filesystem.tmp + rmdir filesystem.tmp + + # Move image + mv chroot/filesystem.${LB_CHROOT_FILESYSTEM} binary/${INITFS} + + du -B 1 -s chroot/chroot | cut -f1 > binary/${INITFS}/filesystem.size + + if [ -e chroot/chroot.cache ] + then + rm -f .lock + mv chroot/chroot chroot.tmp + + lb chroot_archives binary remove ${@} + lb chroot_apt remove ${@} + lb chroot_hostname remove ${@} + lb chroot_resolv remove ${@} + lb chroot_hosts remove ${@} + lb chroot_sysv-rc remove ${@} + lb chroot_dpkg remove ${@} + lb chroot_debianchroot remove ${@} + lb chroot_sysfs remove ${@} + lb chroot_selinuxfs remove ${@} + lb chroot_proc remove ${@} + lb chroot_devpts remove ${@} + + rm -rf chroot + mv chroot.tmp chroot + + lb chroot_devpts install ${@} + lb chroot_proc install ${@} + lb chroot_selinuxfs install ${@} + lb chroot_sysfs install ${@} + lb chroot_debianchroot install ${@} + lb chroot_dpkg install ${@} + lb chroot_sysv-rc install ${@} + lb chroot_hosts install ${@} + lb chroot_resolv install ${@} + lb chroot_hostname install ${@} + lb chroot_apt install ${@} + lb chroot_archives binary install ${@} + + touch .lock + else + rm -rf chroot/chroot + + # Removing depends + Remove_package + fi + ;; + + false) + dd if=/dev/zero of=binary/${INITFS}/filesystem.${LB_CHROOT_FILESYSTEM} bs=1024k count=0 seek=${REAL_DIM} + mkfs.${LB_CHROOT_FILESYSTEM} -F -b 1024 -N ${REAL_INODES} -m 0 binary/${INITFS}/filesystem.${LB_CHROOT_FILESYSTEM} + + mkdir -p filesystem.tmp + mount -o loop binary/${INITFS}/filesystem.${LB_CHROOT_FILESYSTEM} filesystem.tmp + cp -a chroot/* filesystem.tmp + + umount filesystem.tmp + rmdir filesystem.tmp + ;; + esac + + # Saving cache + Save_cache cache/packages.binary + ;; + + jffs2) + # Checking depends + Check_package chroot /usr/sbin/mkfs.jffs2 mtd-tools + + # Restoring cache + Restore_cache cache/packages.binary + + # Installing depends + Install_package + + # Remove old jffs2 image + if [ -f binary/${INITFS}/filesystem.jffs2 ] + then + rm -f binary/${INITFS}/filesystem.jffs2 + fi + + if [ -n "${LB_JFFS2_ERASEBLOCK}" ] + then + JFFS2_OPTIONS="--eraseblock=${LB_JFFS2_ERASEBLOCK}" + fi + + case "${LB_BUILD_WITH_CHROOT}" in + true) + Chroot chroot "mkfs.jffs2 ${JFFS2_OPTIONS} --root=chroot --output filesystem.jffs2" + + # Move image + mv chroot/filesystem.jffs2 binary/${INITFS} + + if [ -e chroot/chroot.cache ] + then + rm -f .lock + mv chroot/chroot chroot.tmp + + lb chroot_archives binary remove ${@} + lb chroot_apt remove ${@} + lb chroot_hostname remove ${@} + lb chroot_resolv remove ${@} + lb chroot_hosts remove ${@} + lb chroot_sysv-rc remove ${@} + lb chroot_dpkg remove ${@} + lb chroot_debianchroot remove ${@} + lb chroot_sysfs remove ${@} + lb chroot_selinuxfs remove ${@} + lb chroot_proc remove ${@} + lb chroot_devpts remove ${@} + + rm -rf chroot + mv chroot.tmp chroot + + lb chroot_devpts install ${@} + lb chroot_proc install ${@} + lb chroot_selinuxfs install ${@} + lb chroot_sysfs install ${@} + lb chroot_debianchroot install ${@} + lb chroot_dpkg install ${@} + lb chroot_sysv-rc install ${@} + lb chroot_hosts install ${@} + lb chroot_resolv install ${@} + lb chroot_hostname install ${@} + lb chroot_apt install ${@} + lb chroot_archives binary install ${@} + + touch .lock + else + rm -rf chroot/chroot + + # Removing depends + Remove_package + fi + ;; + + false) + mkfs.jffs2 ${JFFS2_OPTIONS} --root=chroot --output binary/${INITFS}/filesystem.jffs2 + ;; + esac + + # Saving cache + Save_cache cache/packages.binary + ;; + + plain) + if [ -d binary/${INITFS}/filesystem.dir ] + then + rm -rf binary/${INITFS}/filesystem.dir + fi + + case "${LB_BUILD_WITH_CHROOT}" in + true) + mv chroot/chroot binary/${INITFS}/filesystem.dir + ;; + + false) + cp -a chroot binary/${INITFS}/filesystem.dir + ;; + esac + ;; + + squashfs) + # Checking depends + Check_package chroot /usr/share/doc/squashfs-tools squashfs-tools + + # Restoring cache + Restore_cache cache/packages.binary + + # Installing depends + Install_package + + Echo_message "Preparing squashfs image..." + Echo_message "This may take a while." + + # Remove old squashfs image + if [ -f binary/${INITFS}/filesystem.squashfs ] + then + rm -f binary/${INITFS}/filesystem.squashfs + fi + + # Remove stale squashfs image + rm -f chroot/filesystem.squashfs + + MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -no-progress" + + if [ "${_VERBOSE}" = "true" ] + then + MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -info" + fi + + if [ -f config/rootfs/squashfs.sort ] + then + MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -sort squashfs.sort" + + case "${LB_BUILD_WITH_CHROOT}" in + true) + cp config/rootfs/squashfs.sort chroot + ;; + + false) + cp config/rootfs/squashfs.sort . + ;; + esac + fi + + MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -comp xz" + + case "${LB_BUILD_WITH_CHROOT}" in + true) + if [ -e config/rootfs/excludes ] + then + cp config/rootfs/excludes chroot/excludes + + MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -wildcards -ef /excludes" + fi + + # Create image + Chroot chroot "mksquashfs chroot filesystem.squashfs ${MKSQUASHFS_OPTIONS}" + + rm -f chroot/chroot/excludes + + du -B 1 -s chroot/chroot | cut -f1 > binary/${INITFS}/filesystem.size + + # Move image + mv chroot/filesystem.squashfs binary/${INITFS} + rm -f chroot/squashfs.sort + + if [ -e chroot/chroot.cache ] + then + rm -f .lock + mv chroot/chroot chroot.tmp + + lb chroot_archives binary remove ${@} + lb chroot_apt remove ${@} + lb chroot_hostname remove ${@} + lb chroot_resolv remove ${@} + lb chroot_hosts remove ${@} + lb chroot_sysv-rc remove ${@} + lb chroot_dpkg remove ${@} + lb chroot_debianchroot remove ${@} + lb chroot_sysfs remove ${@} + lb chroot_selinuxfs remove ${@} + lb chroot_proc remove ${@} + lb chroot_devpts remove ${@} + + rm -rf chroot + mv chroot.tmp chroot + + lb chroot_devpts install ${@} + lb chroot_proc install ${@} + lb chroot_selinuxfs install ${@} + lb chroot_sysfs install ${@} + lb chroot_debianchroot install ${@} + lb chroot_dpkg install ${@} + lb chroot_sysv-rc install ${@} + lb chroot_hosts install ${@} + lb chroot_resolv install ${@} + lb chroot_hostname install ${@} + lb chroot_apt install ${@} + lb chroot_archives binary install ${@} + + touch .lock + else + rm -rf chroot/chroot + + # Removing depends + Remove_package + fi + + chmod 0644 binary/${INITFS}/filesystem.squashfs + ;; + + false) + if [ -e config/rootfs/excludes ] + then + MKSQUASHFS_OPTIONS="${MKSQUASHFS_OPTIONS} -wildcards -ef config/rootfs/excludes" + fi + + mksquashfs chroot binary/${INITFS}/filesystem.squashfs ${MKSQUASHFS_OPTIONS} + + du -B 1 -s chroot | cut -f1 > binary/${INITFS}/filesystem.size + ;; + esac + + # Saving cache + Save_cache cache/packages.binary + ;; + + none) + if [ -d binary ] + then + rm -rf binary + fi + + case "${LB_BUILD_WITH_CHROOT}" in + true) + mv chroot/chroot binary + ;; + + false) + Echo_message "This may take a while." + cp -a chroot binary + ;; + esac + ;; + +esac + +for STAGE in ${LB_CACHE_STAGES} +do + if [ "${STAGE}" = "rootfs" ] + then + rm -rf cache/binary_rootfs + + mkdir -p cache/binary_rootfs + + if [ "${LB_CHROOT_FILESYSTEM}" != "none" ] + then + cp -a binary/"${INITFS}"/filesystem.* cache/binary_rootfs + fi + fi +done + +# Creating stage file +Create_stagefile .build/binary_rootfs diff --git a/system-build/scripts/build/binary_syslinux b/system-build/scripts/build/binary_syslinux new file mode 100755 index 0000000..3224d21 --- /dev/null +++ b/system-build/scripts/build/binary_syslinux @@ -0,0 +1,349 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'installs syslinux into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +FOUND_MYSELF="" +OLDIFS="$IFS" +IFS="," +for BOOTLOADER in ${LB_BOOTLOADERS} +do + + case ${BOOTLOADER} in + "syslinux" ) + FOUND_MYSELF="True" + break ;; + esac + +done +IFS="$OLDIFS" + +if [ -z ${FOUND_MYSELF} ] ; then + exit 0 +fi + +Echo_message "Begin installing syslinux..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_syslinux + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Check architecture +Check_architectures amd64 i386 +Check_crossarchitectures + +case "${LB_INITRAMFS}" in + *) + _INITRAMFS="live" + ;; +esac + +# Assembling image specifics +case "${LIVE_IMAGE_TYPE}" in + iso*) + _BOOTLOADER="isolinux" + + case "${LB_MODE}" in + progress-linux) + _TARGET="binary/boot" + ;; + + *) + _TARGET="binary/isolinux" + ;; + esac + ;; + + netboot) + _BOOTLOADER="pxelinux" + _TARGET="tftpboot" + ;; + + hdd*|*) + case ${LB_BINARY_FILESYSTEM} in + fat*|ntfs) + _BOOTLOADER=syslinux + + case "${LB_MODE}" in + progress-linux) + _TARGET="binary/boot" + ;; + + *) + _TARGET="binary/syslinux" + ;; + esac + ;; + + ext[234]|btrfs) + _BOOTLOADER=extlinux + _TARGET="binary/boot/extlinux" + ;; + *) + Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}" + exit 1 + ;; + esac + ;; +esac + +if [ -e "config/bootloaders/${_BOOTLOADER}" ] +then + # Internal local copy + _SOURCE="config/bootloaders/${_BOOTLOADER}" +else + # Internal system copy + if [ -n "${LIVE_BUILD}" ] + then + _SOURCE="${LIVE_BUILD}/share/bootloaders/${_BOOTLOADER}" + else + _SOURCE="/usr/share/live/build/bootloaders/${_BOOTLOADER}" + fi +fi + +# Checking depends +case "${LB_BUILD_WITH_CHROOT}" in + true) + Check_package chroot /usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z]) ${_BOOTLOADER} + Check_package chroot /usr/lib/syslinux syslinux-common + + if ls "${_SOURCE}"/*.svg* > /dev/null 2>&1 + then + Check_package chroot /usr/bin/rsvg-convert librsvg2-bin + fi + ;; + + false) + if [ ! -e "/usr/share/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])" ] + then + Echo_error "/usr/share/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z])" + exit 1 + fi + + if [ ! -e /usr/lib/syslinux ] + then + # syslinux-common + Echo_error "/usr/lib/syslinux - no such directory" + exit 1 + fi + + if ls "${_SOURCE}"/*.svg* > /dev/null 2>&1 + then + if [ ! -e /usr/bin/rsvg-convert ] + then + # librsvg2-bin + Echo_error "/usr/bin/rsvg-convert - no such file" + exit 1 + fi + fi + ;; +esac + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +# Copying files +case "${LB_BUILD_WITH_CHROOT}" in + true) + mkdir -p ${_TARGET} + + # Copy in two steps since the theme can have absolute symlinks and would therefore not be dereferenced correctly + cp -a ${_SOURCE} chroot/root + Chroot chroot cp -aL /root/$(basename ${_SOURCE}) /root/$(basename ${_SOURCE}).tmp > /dev/null 2>&1 || true + cp -a chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET} + rm -rf chroot/root/$(basename ${_SOURCE}) chroot/root/$(basename ${_SOURCE}).tmp + ;; + + false) + mkdir -p ${_TARGET} + + cp -aL ${_SOURCE}/* ${_TARGET} > /dev/null 2>&1 || true + ;; +esac + +# Configuring files +if [ -e "${_TARGET}/live.cfg.in" ] +then + # This is all rather suboptimal.. needs prettifying at some point + _FLAVOURS="$(echo ${LB_LINUX_FLAVOURS} | wc -w)" + + case "${_FLAVOURS}" in + 1) + # If multiple initrd images are being generated (by DKMS packages, etc), + # we likely only want the latest version. + mv $(ls -r1 --sort=version binary/${_INITRAMFS}/vmlinuz-* | head -n 1) binary/${_INITRAMFS}/vmlinuz + mv $(ls -r1 --sort=version binary/${_INITRAMFS}/initrd.img-* | head -n 1) binary/${_INITRAMFS}/initrd.img + + sed -e "s|@FLAVOUR@|${LB_LINUX_FLAVOURS}|g" \ + -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz|g" \ + -e "s|@INITRD@|/${_INITRAMFS}/initrd.img|g" \ + "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg" + + rm -f "${_TARGET}/live.cfg.in" + ;; + + *) + _NUMBER="0" + + for _FLAVOUR in ${LB_LINUX_FLAVOURS} + do + _NUMBER="$((${_NUMBER} + 1))" + + mv binary/${_INITRAMFS}/vmlinuz-*-${_FLAVOUR} binary/${_INITRAMFS}/vmlinuz${_NUMBER} + mv binary/${_INITRAMFS}/initrd.img-*-${_FLAVOUR} binary/${_INITRAMFS}/initrd${_NUMBER}.img + + if [ "${_NUMBER}" -gt 1 ] + then + echo "" >> "${_TARGET}/live.cfg" + grep -v 'menu default' "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg" + else + cat "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg" + fi + + sed -i -e "s|@FLAVOUR@|${_FLAVOUR}|g" \ + -e "s|@LINUX@|/${_INITRAMFS}/vmlinuz${_NUMBER}|g" \ + -e "s|@INITRD@|/${_INITRAMFS}/initrd${_NUMBER}.img|g" \ + "${_TARGET}/live.cfg" + done + + rm -f "${_TARGET}/live.cfg.in" + ;; + esac +fi + +if [ -e chroot/etc/os-release ] +then + _VERSION="$(. chroot/etc/os-release && echo ${VERSION_ID})" +fi + +_VERSION="${_VERSION:-none}" + +_DISTRIBUTION="${LB_DISTRIBUTION}" +_ARCHITECTURE="${LB_ARCHITECTURES}" + +_DATE=$(date -R) +_YEAR="$(date +%Y)" +_MONTH="$(date +%m)" +_DAY="$(date +%d)" +_HOUR="$(date +%H)" +_MINUTE="$(date +%M)" +_SECOND="$(date +%S)" + +_LINUX_VERSIONS="$(for _LINUX in chroot/boot/vmlinuz-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|vmlinuz-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")" + +_SYSTEM_BUILD_VERSION="$(lb --version)" +_SYSTEM_BOOT_VERSION="$(chroot chroot apt-cache policy open-infrastructure-system-boot | awk '/Installed: / { print $2 }')" +_SYSTEM_CONFIG_VERSION="$(chroot chroot apt-cache policy open-infrastructure-system-config | awk '/Installed: / { print $2 }')" + +case "${LB_MODE}" in + progress-linux) + _PROJECT="Progress Linux" + ;; + + *) + _PROJECT="Debian GNU/Linux" + ;; +esac + +for _FILE in "${_TARGET}"/*.cfg ${_TARGET}/*.svg +do + if [ -e "${_FILE}" ] && [ ! -d "${_FILE}" ] + then + sed -i -e "s#@APPEND_LIVE@#${LB_BOOTAPPEND_LIVE}#g" \ + -e "s#@APPEND_LIVE_FAILSAFE@#${LB_BOOTAPPEND_LIVE_FAILSAFE}#g" \ + -e "s#@APPEND_INSTALL@#${LB_BOOTAPPEND_INSTALL}#g" \ + -e "s#@APPEND_INSTALL_FAILSAFE@#${LB_BOOTAPPEND_INSTALL_FAILSAFE}#g" \ + -e "s|@PROJECT@|${_PROJECT}|g" \ + -e "s|@DISTRIBUTION@|${_DISTRIBUTION}|g" \ + -e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \ + -e "s|@VERSION@|${_VERSION}|g" \ + -e "s|@ARCHITECTURE@|${_ARCHITECTURE}|g" \ + -e "s|@DATE@|${_DATE}|g" \ + -e "s|@YEAR@|${_YEAR}|g" \ + -e "s|@MONTH@|${_MONTH}|g" \ + -e "s|@DAY@|${_DAY}|g" \ + -e "s|@HOUR@|${_HOUR}|g" \ + -e "s|@MINUTE@|${_MINUTE}|g" \ + -e "s|@SECOND@|${_SECOND}|g" \ + -e "s|@LINUX_VERSIONS@|${_LINUX_VERSIONS}|g" \ + -e "s|@SYSTEM_BUILD_VERSION@|${_SYSTEM_BUILD_VERSION}|g" \ + -e "s|@SYSTEM_BOOT_VERSION@|${_SYSTEM_BOOT_VERSION}|g" \ + -e "s|@SYSTEM_CONFIG_VERSION@|${_SYSTEM_CONFIG_VERSION}|g" \ + "${_FILE}" + fi +done + +if [ -e "${_TARGET}/splash.svg" ] +then + case "${LB_BUILD_WITH_CHROOT}" in + true) + cp "${_TARGET}/splash.svg" chroot + Chroot chroot "rsvg-convert --format png --height 480 --width 640 splash.svg -o splash.png" + mv chroot/splash.png "${_TARGET}" + rm -f chroot/splash.svg + ;; + + false) + rsvg-convert --format png --height 480 --width 640 "${_TARGET}/splash.svg" -o "${_TARGET}/splash.png" + ;; + esac + + rm -f "${_TARGET}/splash.svg" +fi + +case "${LB_MODE}" in + progress-linux) + for _FILE in "${_TARGET}/isolinux.bin" "${_TARGET}/isolinux.cfg" "${_TARGET}/syslinux.cfg" + do + if [ -e "${_FILE}" ] + then + mv "${_FILE}" "${_TARGET}/$(echo ${_FILE} | sed -e 's|.*linux|boot|')" + fi + done + ;; +esac + +case "${LB_BUILD_WITH_CHROOT}" in + true) + # Saving cache + Save_cache cache/packages.binary + + # Removing depends + Remove_package + ;; +esac + +# Creating stage file +Create_stagefile .build/binary_syslinux diff --git a/system-build/scripts/build/binary_tar b/system-build/scripts/build/binary_tar new file mode 100755 index 0000000..2200586 --- /dev/null +++ b/system-build/scripts/build/binary_tar @@ -0,0 +1,73 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build binary tarball')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if ! In_list tar "${LIVE_IMAGE_TYPE}" +then + exit 0 +fi + +Echo_message "Begin building binary tarball..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_tar + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Remove old binary +rm -f ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.bz2 ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.gz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.lz ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar + +tar cf ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.tar binary + +case "${LB_COMPRESSION}" in + bzip2) + bzip2 ${BZIP2_OPTIONS} ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.tar + ;; + + gzip) + gzip ${GZIP_OPTIONS} ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.tar + ;; + + lzip) + lzip ${LZIP_OPTIONS} ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.tar + ;; + + xz) + xz ${XZ_OPTIONS} ${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar.tar + ;; + + none) + ;; +esac + +# Creating stage file +Create_stagefile .build/binary_tar diff --git a/system-build/scripts/build/binary_win32-loader b/system-build/scripts/build/binary_win32-loader new file mode 100755 index 0000000..b04103a --- /dev/null +++ b/system-build/scripts/build/binary_win32-loader @@ -0,0 +1,135 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'copy win32-loader into binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LB_WIN32_LOADER}" != "true" ] +then + exit 0 +fi + +Echo_message "Begin copying win32-loader..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_win32-loader + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +case "${LB_MODE}" in + progress-linux) + RUN_LABEL="Run Progress Linux" + ;; + + *) + RUN_LABEL="Run Debian GNU/Linux" + ;; +esac + +case "${LB_ARCHITECTURES}" in + amd64|i386) + if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] + then + # Checking depends + Check_package chroot /usr/share/win32/win32-loader.exe win32-loader + + # Restoring cache + Restore_cache cache/packages.binary + + # Installing depends + Install_package + + # Copying win32-loader + cp -r chroot/usr/share/win32/* binary + else + cp -r usr/share/win32/* binary + fi + + mv binary/win32-loader.exe binary/setup.exe + mv binary/win32-loader/g2ldr* binary + rmdir binary/win32-loader > /dev/null 2>&1 || true + +cat > binary/autorun.inf << EOF +[autorun] +open=setup.exe +icon=setup.exe,0 +label=${RUN_LABEL} + +[Content] +MusicFiles=false +PictureFiles=false +VideoFiles=false +EOF + + if [ "${LB_DEBIAN_INSTALLER}" != "false" ] + then + +cat > binary/win32-loader.ini << EOF +[installer] +kernel=linux +arch=${LB_ARCHITECTURES} +default_desktop=gnome +${LB_ARCHITECTURES}/linux=install/vmlinuz +${LB_ARCHITECTURES}/initrd=install/initrd.gz +EOF + + if [ -e binary/install/gtk ] + then + +cat >> binary/win32-loader.ini << EOF +${LB_ARCHITECTURES}/gtk/linux=install/vmlinuz +${LB_ARCHITECTURES}/gtk/initrd=install/gtk/initrd.gz +EOF + + fi + +cat >> binary/win32-loader.ini << EOF + +[grub] +g2ldr=g2ldr +g2ldr.mbr=g2ldr.mbr +EOF + + fi + + # Saving cache + Save_cache cache/packages.binary + + # Removing depends + Remove_package + ;; + + *) + Echo_warning "win32-loader inclusion is set to true but not compatible with your architecture, ignoring." + ;; +esac + +# Creating stage file +Create_stagefile .build/binary_win32-loader diff --git a/system-build/scripts/build/binary_zsync b/system-build/scripts/build/binary_zsync new file mode 100755 index 0000000..83fdb55 --- /dev/null +++ b/system-build/scripts/build/binary_zsync @@ -0,0 +1,130 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch> +## +## 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. + + +set -e + +# Including common functions +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build zsync control files')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source +Set_defaults + +if [ "${LIVE_IMAGE_TYPE}" != "iso" ] && [ "${LIVE_IMAGE_TYPE}" != "iso-hybrid" ] +then + exit 0 +fi + +if [ "${LB_ZSYNC}" != "true" ] +then + exit 0 +fi + +Echo_message "Begin building zsync control files..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/binary_zsync + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Checking depends +Check_package chroot /usr/bin/zsyncmake zsync + +# Restoring cache +Restore_cache cache/packages.binary + +# Installing depends +Install_package + +case "${LIVE_IMAGE_TYPE}" in + iso) + _IMAGES="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.iso" + ;; + + iso-hybrid) + _IMAGES="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso" + ;; + + hdd) + _IMAGES="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.img" + ;; + + net) + _IMAGES="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.netboot.tar*" + ;; + + tar) + _IMAGES="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.tar*" + ;; +esac + +for _IMAGE in ${_IMAGES} +do + if [ -e "${_IMAGE}" ] + then + case "${LB_BUILD_WITH_CHROOT}" in + true) + mv ${_IMAGE} chroot + Chroot chroot "zsyncmake -C -b 2048 -u ${_IMAGE} ${_IMAGE}" + mv chroot/${_IMAGE} chroot/${_IMAGE}.zsync ./ + ;; + + false) + zsyncmake -C -b 2048 -u "${_IMAGE}" "${_IMAGE}" + ;; + esac + + case "${LB_COMPRESSION}" in + bzip2) + bzip2 ${BZIP2_OPTIONS} ${_IMAGE}.zsync + ;; + + gzip) + gzip ${GZIP_OPTIONS} ${_IMAGE}.zsync + ;; + + lzip) + lzip ${LZIP_OPTIONS} ${_IMAGE}.zsync + ;; + + xz) + xz ${XZ_OPTIONS} ${_IMAGE}.zsync + ;; + + none) + ;; + esac + fi +done + +#CHECKSUMS + +# Saving cache +Save_cache cache/packages.binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .build/binary_zsync |