#!/bin/sh ## live-build(7) - System Build Scripts ## Copyright (C) 2006-2015 Daniel Baumann ## ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. ## This is free software, and you are welcome to redistribute it ## under certain conditions; see COPYING for details. 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 'manage /etc/apt/sources.list')" HELP="" USAGE="${PROGRAM} [--force]" _PASS="${1:-binary}" if [ -n "${1}" ] then shift fi Arguments "${@}" # Reading configuration files Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults # Requiring stage file Require_stagefile .build/config .build/bootstrap case "${LB_DERIVATIVE}" in true) _PARENT_FILE="sources.list.d/debian.list" ;; false) _PARENT_FILE="sources.list" ;; esac Echo_message "Configuring file /etc/apt/sources.list" # Checking stage file Check_stagefile .build/chroot_archives # Checking lock file Check_lockfile .lock # Creating lock file Create_lockfile .lock # Restoring cache Restore_cache cache/packages.chroot # Configure custom sources.list if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/' then Chroot_bind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')" fi cat > chroot/etc/apt/${_PARENT_FILE} << EOF deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS} EOF if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} fi if [ "${LB_DERIVATIVE}" = "true" ] then rm -f chroot/etc/apt/sources.list.d/${LB_MODE}.list _DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||')" echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list fi fi if [ "${LB_SECURITY}" = "true" ] then case "${LB_MODE}" in debian|progress-linux) case "${LB_PARENT_DISTRIBUTION}" in sid) ;; *) echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} fi ;; esac if [ "${LB_MODE}" = progress-linux ] then echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list fi else if [ "${LB_DERIVATIVE}" = "true" ] then echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list fi fi fi ;; ubuntu) echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}-security ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} fi ;; esac fi if [ "${LB_UPDATES}" = "true" ] then echo "deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} fi if [ "${LB_DERIVATIVE}" = "true" ] then echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list fi fi fi if [ "${LB_BACKPORTS}" = "true" ] then case "${LB_MODE}" in debian) if [ "${LB_PARENT_DISTRIBUTION}" != "sid" ] then echo "deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE} fi fi ;; esac if [ "${LB_DERIVATIVE}" = "true" ] then echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ] then echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list fi fi fi # Adding local apt sources (chroot) for FILE in config/archives/*.list config/archives/*.list.chroot do if [ -e "${FILE}" ] then sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION}|g" \ -e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \ -e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \ -e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \ "${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)" if [ "${_PASS}" != "source" ] && [ "${LB_APT_SOURCE_ARCHIVES}" = "false" ] then # Strip out source archives sed "/^deb-src /d" "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)" fi fi done # Adding local apt configuration (chroot) for FILE in config/archives/*.conf config/archives/*.conf.chroot do if [ -e "${FILE}" ] then cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot) fi done # Adding local apt preferences (chroot) for FILE in config/archives/*.pref config/archives/*.pref.chroot do if [ -e "${FILE}" ] then cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot) fi done # Check local archive keys if Find_files config/archives/*.key || \ Find_files config/archives/*.key.chroot then for FILE in config/archives/*.key \ config/archives/*.key.chroot do if [ -e "${FILE}" ] then cp ${FILE} chroot/root Chroot chroot "apt-key add /root/$(basename ${FILE})" rm -f chroot/root/$(basename ${FILE}) fi done fi # Check local keyring packages if Find_files config/archives/*.deb then for PACKAGE in config/archives/*.deb do cp ${PACKAGE} chroot/root Chroot chroot "dpkg -i /root/$(basename ${PACKAGE})" rm -f chroot/root/$(basename ${PACKAGE}) done fi # Installing aptitude if [ "${LB_APT}" = "aptitude" ] && [ ! -x chroot/usr/bin/aptitude ] then Chroot chroot "apt-get ${APT_OPTIONS} update" Chroot chroot "apt-get ${APT_OPTIONS} install aptitude" fi # Rebuild apt indices from scratch. # Due to the fact that apt doesn't understand # pinning on the fly, we need to manually remove # the cached indices and rebuild them again. rm -rf chroot/var/cache/apt/*.bin Apt chroot update # Installing keyring packages if [ -n "${LB_KEYRING_PACKAGES}" ] then Apt chroot "install ${LB_KEYRING_PACKAGES}" fi rm -rf chroot/var/cache/apt/*.bin Apt chroot update Apt chroot "upgrade" Apt chroot "dist-upgrade" # Saving cache Save_cache cache/packages.chroot # Creating stage file Create_stagefile .build/bootstrap_archives