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
#!/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.
PROGRAM="live-build"
VERSION="$(if [ -e ${LIVE_BUILD}/VERSION ]; then cat ${LIVE_BUILD}/VERSION; else cat /usr/share/live/build/VERSION; fi)"
CONFIG_VERSION="$(echo ${VERSION} | awk -F- '{ print $1 }')"
# FIXME
LIVE_BUILD_VERSION="${CONFIG_VERSION}"
PATH="${PWD}/local/bin:${PATH}"
#!/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.
Get_conffiles ()
{
if [ -n "${LB_CONFIG}" ]
then
FILES="${LB_CONFIG}"
else
for FILE in ${@}
do
FILES="${FILES} ${FILE} ${FILE}.${LB_ARCHITECTURES} ${FILE}.${DISTRIBUTION}"
FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lb_||')"
FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lb_||').${ARCHITECTURE}"
FILES="${FILES} config/$(echo ${PROGRAM} | sed -e 's|^lb_||').${DISTRIBUTION}"
done
fi
echo ${FILES}
}
Read_conffiles ()
{
for CONFFILE in $(Get_conffiles "${@}")
do
if [ -f "${CONFFILE}" ]
then
if [ -r "${CONFFILE}" ]
then
Echo_debug "Reading configuration file %s" "${CONFFILE}"
. "${CONFFILE}"
else
Echo_warning "Failed to read configuration file %s" "${CONFFILE}"
fi
fi
done
}
Print_conffiles ()
{
for CONFFILE in $(Get_conffiles "${@}")
do
if [ -f "${CONFFILE}" ]
then
Echo_file "${CONFFILE}"
fi
done
}
#!/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.
Get_configuration ()
{
_CONFIGURATION_FILE="${1}"
_FIELD_NAME="${2}"
if [ -e "${_CONFIGURATION_FILE}" ]
then
_FIELD_BODY="$(grep ^${_FIELD_NAME}: ${_CONFIGURATION_FILE} | awk '{ $1=""; print $0 }' | sed -e 's|^ ||')"
fi
echo ${_FIELD_BODY}
}
Set_configuration ()
{
_CONFIGURATION_FILE="${1}"
_FIELD_NAME="${2}"
_FIELD_BODY="${3}"
if grep -qs "^${_FIELD_NAME}:" "${_CONFIGURATION_FILE}"
then
# Update configuration
sed -i -e "s|^${_FIELD_NAME}:.*$|${_FIELD_NAME}: ${_FIELD_BODY}|" "${_CONFIGURATION_FILE}"
else
# Append configuration
echo "${_FIELD_NAME}: ${_FIELD_BODY}" >> "${_CONFIGURATION_FILE}"
fi
}
#!/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.
Cursor_goto_position ()
{
__LINE="${1}"
__COLUMN="${2}"
#echo -e "[${__LINE};${__COLUMN};H\c"
printf "[${__LINE};${__COLUMN};H"
}
Cursor_save_position ()
{
#echo -e "\c"
printf ""
}
Cursor_restore_position ()
{
#echo -e "\c"
printf ""
}
Cursor_line_up ()
{
__LINES="${1}"
#echo -e "[${__LINES}A\c"
printf "[${__LINES}A"
}
Cursor_line_down ()
{
__LINES="${1}"
#echo -e "[${__LINES}B\c"
printf "[${__LINES}B"
}
Cursor_columns_forward ()
{
__COLUMNS="${1}"
#echo -e "[${__COLUMNS}C\c"
printf "[${__COLUMNS}C"
}
Cursor_columns_backward ()
{
__COLUMNS="${1}"
#echo -e "[${__COLUMNS}D\c"
printf "[${__COLUMNS}D"
}
Cursor_clear_screen ()
{
#echo -e "\c"
printf ""
}
Cursor_erase_EOL ()
{
#echo -e "\c"
printf ""
}
This diff is collapsed.
#!/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.
Echo ()
{
STRING="${1}"
shift
printf "${STRING}\n" "${@}"
}
Echo_debug ()
{
if [ "${_DEBUG}" = "true" ]
then
STRING="${1}"
shift
printf "D: ${STRING}\n" "${@}"
fi
}
Echo_debug_running ()
{
if [ "${_DEBUG}" = "true" ]
then
STRING="${1}"
shift
printf "D: ${STRING}" "${@}"
if [ "${_COLOR}" = "false" ]
then
printf "..."
else
printf "... ${YELLOW}${BLINK}running${NO_COLOR}"
fi
fi
}
Echo_error ()
{
STRING="${1}"
shift
if [ "${_COLOR}" = "false" ]
then
printf "E:"
else
printf "${RED}E${NO_COLOR}:"
fi
printf " ${STRING}\n" "${@}" >&2
}
Echo_message ()
{
if [ "${_QUIET}" != "true" ]
then
STRING="${1}"
shift
if [ "${_COLOR}" = "false" ]
then
printf "P:"
else
printf "${WHITE}P${NO_COLOR}:"
fi
printf " ${STRING}\n" "${@}"
fi
}
Echo_message_running ()
{
if [ "${_QUIET}" != "true" ]
then
STRING="${1}"
shift
if [ "${_COLOR}" = "false" ]
then
printf "P:"
else
printf "${WHITE}P${NO_COLOR}:"
fi
printf " ${STRING}" "${@}"
if [ "${_COLOR}" = "true" ]
then
printf "... ${YELLOW}${BLINK}running${NO_COLOR}"
else
printf "..."
fi
fi
}
Echo_verbose ()
{
if [ "${_VERBOSE}" = "true" ]
then
STRING="${1}"
shift
printf "I: ${STRING}\n" "${@}"
fi
}
Echo_verbose_running ()
{
if [ "${_VERBOSE}" != "true" ]
then
STRING="${1}"
shift
printf "I: ${STRING}" "${@}"
if [ "${_COLOR}" = "true" ]
then
printf "... ${YELLOW}${BLINK}running${NO_COLOR}"
else
printf "..."
fi
fi
}
Echo_warning ()
{
STRING="${1}"
shift
if [ "${_COLOR}" = "false" ]
then
printf "W:"
else
printf "${YELLOW}W${NO_COLOR}:"
fi
printf " ${STRING}\n" "${@}"
}
Echo_status ()
{
__RETURN="${?}"
if [ "${_COLOR}" = "false" ]
then
if [ "${__RETURN}" = "0" ]
then
printf " done.\n"
else
printf " failed.\n"
fi
else
Cursor_columns_backward 8
if [ "${__RETURN}" = "0" ]
then
printf " ${GREEN}done${NO_COLOR}. \n"
else
printf " ${RED}failed${NO_COLOR}.\n"
fi
fi
}
Echo_done ()
{
if [ "${_COLOR}" = "false" ]
then
printf " already done.\n"
else
Cursor_columns_backward 8
printf " ${GREEN}already done${NO_COLOR}.\n"
fi
}
Echo_file ()
{
while read LINE
do
echo "${1}: ${LINE}"
done < "${1}"
}
Echo_breakage ()
{
case "${LB_PARENT_DISTRIBUTION}" in
sid)
Echo_message "If the following stage fails, the most likely cause of the problem is with your mirror configuration, a caching proxy or the sid distribution."
;;
*)
Echo_message "If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy."
;;
esac
Echo_message "${@}"
}
#!/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.
Exit ()
{
VALUE="${?}"
if [ "${_DEBUG}" = "true" ]
then
# Dump variables
set | grep -e ^LB
fi
# Always exit true in case we are not able to unmount
# (e.g. due to running processes in chroot from user customizations)
Echo_message "Begin unmounting filesystems..."
if [ -e /proc/mounts ]
then
for DIRECTORY in $(awk -v dir="${PWD}/chroot/" '$2 ~ dir { print $2 }' /proc/mounts | sort -r)
do
umount ${DIRECTORY} > /dev/null 2>&1 || true
done
else
for DIRECTORY in /dev/shm /dev/pts /dev /proc /selinux /sys /root/config
do
umount -f chroot/${DIRECTORY} > /dev/null 2>&1 || true
done
fi
rm -f .build/chroot_devpts
rm -f .build/chroot_proc
rm -f .build/chroot_selinuxfs
rm -f .build/chroot_sysfs
Echo_message "Saving caches..."
# We can't really know at which part we're failing,
# but let's assume that if there's any binary stage file arround
# we are in binary stage.
if ls .build/binary* > /dev/null 2>&1
then
Save_cache cache/packages.binary
else
Save_cache cache/packages.chroot
fi
return ${VALUE}
}
Setup_cleanup ()
{
Echo_message "Setting up cleanup function"
trap 'Exit' EXIT HUP INT QUIT TERM
}
#!/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.
Help ()
{
Echo "%s - %s" "${PROGRAM}" "${DESCRIPTION}"
echo
Echo "Usage:"
echo
if [ -n "${USAGE}" ]
then
Echo "${USAGE}"
echo
fi
Echo " %s [-h|--help]" "${PROGRAM}"
Echo " %s [-u|--usage]" "${PROGRAM}"
Echo " %s [-v|--version]" "${PROGRAM}"
echo
if [ -n "${HELP}" ]
then
Echo "${HELP}"
echo
fi
Echo "Report bugs to the Live Systems project <http://live-systems.org/>."
exit 0
}
#!/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_lockfile ()
{
FILE="${1}"
if [ -z "${FILE}" ]
then
FILE=".build/lock"
fi
# Checking lock file
if [ -f "${FILE}" ]
then
Echo_error "${PROGRAM} locked"
exit 1
fi
}
Create_lockfile ()
{
FILE="${1}"
if [ -z "${FILE}" ]
then
FILE=".build/lock"
fi
DIRECTORY="$(dirname ${FILE})"
# Creating lock directory
mkdir -p "${DIRECTORY}"
# Creating lock trap
trap 'ret=${?}; '"rm -f \"${FILE}\";"' exit ${ret}' EXIT HUP INT QUIT TERM
# Creating lock file
touch "${FILE}"
}
#!/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.
Lodetach ()
{
DEVICE="${1}"
ATTEMPT="${2:-1}"
if [ "${ATTEMPT}" -gt 3 ]
then
Echo_error "Failed to detach loop device '${DEVICE}'."
exit 1
fi
# Changes to block devices result in uevents which trigger rules which in
# turn access the loop device (ex. udisks-part-id, blkid) which can cause
# a race condition. We call 'udevadm settle' to help avoid this.
if [ -x "$(which udevadm 2>/dev/null)" ]
then
udevadm settle
fi
# Loop back devices aren't the most reliable when it comes to writes.
# We sleep and sync for good measure - better than build failure.
sync
sleep 1
${LB_LOSETUP} -d "${DEVICE}" || Lodetach "${DEVICE}" "$(expr ${ATTEMPT} + 1)"
}
Losetup ()
{
DEVICE="${1}"
FILE="${2}"
PARTITION="${3:-1}"
${LB_LOSETUP} --read-only "${DEVICE}" "${FILE}"
FDISK_OUT="$(${LB_FDISK} -l -u ${DEVICE} 2>&1)"
Lodetach "${DEVICE}"
LOOPDEVICE="$(echo ${DEVICE}p${PARTITION})"
if [ "${PARTITION}" = "0" ]
then
Echo_message "Mounting %s with offset 0" "${DEVICE}"
${LB_LOSETUP} "${DEVICE}" "${FILE}"
else
SECTORS="$(echo "$FDISK_OUT" | sed -ne "s|^$LOOPDEVICE[ *]*\([0-9]*\).*|\1|p")"
OFFSET="$(expr ${SECTORS} '*' 512)"
Echo_message "Mounting %s with offset %s" "${DEVICE}" "${OFFSET}"
${LB_LOSETUP} -o "${OFFSET}" "${DEVICE}" "${FILE}"
fi
}
Calculate_partition_size ()
{
ORIGINAL_SIZE="${1}"
FILESYSTEM="${2}"
case "${FILESYSTEM}" in
ext2|ext3|ext4)
PERCENT="6"
;;
*)
PERCENT="3"
;;
esac
echo $(expr ${ORIGINAL_SIZE} + ${ORIGINAL_SIZE} \* ${PERCENT} / 100 + 1)
}
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##