Unverified Commit 2c6ba6d8 authored by Daniel Baumann's avatar Daniel Baumann
Browse files

Adding upstream version 20160501.


Signed-off-by: default avatarDaniel Baumann <mail@daniel-baumann.ch>
parent 1a192735
squeeze
\ No newline at end of file
#!/bin/sh
set -e
lb build noauto "${@}" 2>&1 | tee build.log
#!/bin/sh
set -e
lb clean noauto "${@}"
rm -f config/binary config/bootstrap config/chroot config/common config/source
rm -f build.log
#!/bin/sh
set -e
lb config noauto \
"${@}"
binary/
binary*.iso
binary*.img
binary*.tar*
binary*.contents
binary*.packages
binary*.zsync
.build/
build.log
cache/
chroot/
chroot.packages.*
config/binary
config/bootstrap
config/chroot
config/common
config/source
config/control
source/
source*.iso
source*.img
source*.tar*
source*.contents
source*.packages
source*.zsync
#!/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
# Removing unused packages
for PACKAGE in apt-utils aptitude man-db manpages info wget
do
if ! apt-get remove --purge --yes "${PACKAGE}"
then
echo "WARNING: ${PACKAGE} isn't installed"
fi
done
apt-get autoremove --yes || true
# Removing unused files
find . -name *~ -print0 | xargs -0 rm -f
rm -rf /var/cache/man/*
# Truncating logs
for FILE in $(find /var/log/ -type f)
do
: > ${FILE}
done
#!/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
# WARNING: Using this hook will result in a stripped system, means,
# it may very well be possible that other packages are depending
# on certain files that get removed here.
# Therefore, this hooks is merely an inspiration for what could be
# removed and not a generic nor recommendet solution to get the
# image filesize down. In any event, using this hook can lead to
# unforseen bugs and breakages in other packages and you should
# be prepared to find and fix it for your own images.
# Removing unused packages
for PACKAGE in apt-utils aptitude man-db manpages info wget dselect
do
if ! apt-get remove --purge --yes "${PACKAGE}"
then
echo "WARNING: ${PACKAGE} isn't installed"
fi
done
apt-get autoremove --yes || true
# Removing unused files
find . -name *~ -print0 | xargs -0 rm -f
rm -rf /usr/include/*
#rm -rf /usr/share/groff/*
rm -rf /usr/share/doc/*
rm -rf /usr/share/locale/*
rm -rf /usr/share/man/*
rm -rf /usr/share/i18n/*
rm -rf /usr/share/info/*
rm -rf /usr/share/lintian/*
rm -rf /usr/share/linda/*
rm -rf /usr/share/zoneinfo/*
rm -rf /var/cache/man/*
# Truncating logs
for FILE in $(find /var/log/ -type f)
do
: > ${FILE}
done
#!/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 'utility to build live systems')"
HELP="FIXME"
USAGE="FIXME"
case "${1}" in
-h|--help)
if [ -x "$(which man 2>/dev/null)" ]
then
man lb
exit 0
else
${0} --usage
exit 0
fi
;;
""|-u|--usage)
Usage
;;
-v|--version)
echo "${VERSION}"
exit 0
;;
*)
COMMAND="${1}"
shift
ENV=""
if [ "${COMMAND}" != "config" ]
then
# Checking user account
if [ "$(id -u)" -ne "0" ]
then
Echo_error "need root privileges"
exit 1
fi
fi
for _FILE in config/environment config/environment.binary
do
if [ -e "${_FILE}" ]
then
ENV="${ENV} $(grep -v '^#' ${_FILE})"
fi
done
if [ -x "${LIVE_BUILD}/scripts/build/${COMMAND}" ]
then
# User has live-build copied locally in the system
SCRIPT="${LIVE_BUILD}/scripts/build/${COMMAND}"
elif [ -x "local/live-build/scripts/build/${COMMAND}" ]
then
# User has live-build copied locally in the config
SCRIPT="local/live-build/scripts/build/${COMMAND}"
elif [ -x /usr/lib/live/build/${COMMAND} ]
then
# User has live-build installed in the system
SCRIPT=/usr/lib/live/build/"${COMMAND}"
elif [ -x "$(which ${COMMAND} 2>/dev/null)" ]
then
# User has live-build commands in path
SCRIPT="${COMMAND}"
else
Echo_error "no such script: ${COMMAND}"
exit 1
fi
Echo "[%s] %s" "$(date +'%F %T')" "lb ${COMMAND} $(echo ${@})"
${ENV} exec "${SCRIPT}" "${@}"
;;
esac
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
## The complete text of the GNU General Public License
## can be found in /usr/share/common-licenses/GPL-3 file.
set -e
if [ -x "$(which man 2>/dev/null)" ]
then
man live-build
else
cat << EOF
live-build contains the scripts to build a live system from a configuration
directory.
An introduction to live-build can be found in the live-build(7) manpage.
EOF
fi
#!/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.
Find_files ()
{
(ls "${@}" | grep -qs .) > /dev/null 2>&1
}
In_list ()
{
NEEDLES="${1}"
shift
for ITEM in ${@}
do
for NEEDLE in ${NEEDLES}
do
if [ "${NEEDLE}" = "${ITEM}" ]
then
return 0
fi
done
done
return 1
}
Truncate ()
{
for FILE in ${@}
do
if [ ! -L ${FILE} ]
then
: > ${FILE}
fi
done
}
#!/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.
Check_architectures ()
{
ARCHITECTURES="${@}"
VALID="false"
for ARCHITECTURE in ${ARCHITECTURES}
do
if [ "$(echo ${LB_ARCHITECTURES} | grep ${ARCHITECTURE})" ]
then
VALID="true"
break
fi
done
if [ "${ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ]
then
VALID="true"
if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ]
then
Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURES} was not found"
VALID="false"
fi
if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ]
then
Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable"
VALID="false"
fi
fi
if [ "${VALID}" = "false" ]
then
Echo_warning "skipping %s, foreign architecture(s)." "${0}"
exit 0
fi
}
Check_crossarchitectures ()
{
if [ -x /usr/bin/dpkg ]
then
HOST="$(dpkg --print-architecture)"
else
HOST="$(uname -m)"
fi
case "${HOST}" in
amd64|i386|x86_64)
CROSS="amd64 i386"
;;
powerpc|ppc64)
CROSS="powerpc ppc64"
;;
*)
CROSS="${HOST}"
;;
esac
if [ "${LB_ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ]
then
if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ]
then
Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURES} was not found"
exit 0
fi
if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ]
then
Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable"
exit 0
fi
return
fi
Check_architectures "${CROSS}"
}
Check_multiarchitectures ()
{
if [ "$(echo ${LB_ARCHITECTURES} | wc -w)" -gt "1" ]
then
# First, only support multiarch on iso
case "${LIVE_IMAGE_TYPE}" in
iso*)
# Assemble multi-arch
case "${LB_CURRENT_ARCHITECTURE}" in
amd64)
DESTDIR="${DESTDIR}.amd"
DESTDIR_LIVE="${DESTDIR_LIVE}.amd"
DESTDIR_INSTALL="${DESTDIR_INSTALL}.amd"
;;
i386)
DESTDIR="${DESTDIR}.386"
DESTDIR_LIVE="${DESTDIR_LIVE}.386"
DESTDIR_INSTALL="${DESTDIR_INSTALL}.386"
;;
powerpc)
DESTDIR="${DESTDIR}.ppc"
DESTDIR_LIVE="${DESTDIR_LIVE}.ppc"
DESTDIR_INSTALL="${DESTDIR_INSTALL}.ppc"
;;
esac
;;
esac
fi
}
#!/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.
Arguments ()
{
ARGUMENTS="$(getopt --longoptions breakpoints,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options c:huv --shell sh -- "${@}")"
if [ "${?}" != "0" ]
then
Echo_error "terminating" >&2
exit 1
fi
eval set -- "${ARGUMENTS}"
while true
do
case "${1}" in
--breakpoints)
_BREAKPOINTS="true"
shift
;;
-c|--conffile)
_CONFFILE="${2}"
shift 2
;;
--debug)
_DEBUG="true"
shift
;;
--force)
_FORCE="true"
shift
;;
-h|--help)
Man
shift
;;
--quiet)
_QUIET="true"
shift
;;
-u|--usage)
Usage
shift
;;
--verbose)
_VERBOSE="true"
shift
;;
-v|--version)
echo "${VERSION}"
exit 0
;;
--)
shift
break
;;
*)
Echo_error "internal error %s" "${0}"
exit 1
;;
esac
done
}
#!/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.
Breakpoint ()
{
NAME="${1}"
if [ "${_BREAKPOINTS}" = "true" ]
then
Echo_message "Waiting at %s" "${NAME}"
read WAIT
fi
}
#!/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.
Restore_cache ()
{
DIRECTORY="${1}"
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
then
if [ -e "${DIRECTORY}" ]
then
# Restore old cache
if [ "$(stat --printf %d ${DIRECTORY}/)" = "$(stat --printf %d chroot/var/cache/apt/archives/)" ]
then
# with hardlinks
find "${DIRECTORY}" -name "*.deb" | xargs cp -fl -t chroot/var/cache/apt/archives
else
# without hardlinks
find "${DIRECTORY}" -name "*.deb" | xargs cp -t chroot/var/cache/apt/archives
fi
fi
fi
}
Save_cache ()
{
DIRECTORY="${1}"
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
then
# Cleaning current cache
# In case of interrupted or incomplete builds, this may return an error,
# but we still do want to save the cache.
Chroot chroot "apt-get autoclean" || true
if ls chroot/var/cache/apt/archives/*.deb > /dev/null 2>&1
then
# Creating cache directory
mkdir -p "${DIRECTORY}"
# Saving new cache
for PACKAGE in chroot/var/cache/apt/archives/*.deb
do
if [ -e "${DIRECTORY}"/"$(basename ${PACKAGE})" ]
then
rm -f "${PACKAGE}"
else
mv "${PACKAGE}" "${DIRECTORY}"
fi
done
fi
else
# Purging current cache
rm -f chroot/var/cache/apt/archives/*.deb
fi
}
#!/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.
Chroot ()