2007-09-23 08:04:52 +00:00
#!/bin/sh
2010-09-02 11:12:37 +00:00
## live-build(7) - System Build Scripts
2011-01-11 12:49:49 -01:00
## Copyright (C) 2006-2011 Daniel Baumann <daniel@debian.org>
2010-09-02 11:12:37 +00:00
##
## live-build 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.
2007-09-23 08:04:52 +00:00
set -e
2007-09-23 08:05:11 +00:00
# Including common functions
2010-09-07 13:11:20 +00:00
. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
2007-09-23 08:04:52 +00:00
2007-09-23 08:05:11 +00:00
# Setting static variables
2009-01-15 01:37:42 -01:00
DESCRIPTION="$(Echo 'install debian-installer into binary')"
2007-09-23 08:04:52 +00:00
HELP=""
USAGE="${PROGRAM} [--force]"
Arguments "${@}"
# Reading configuration files
2008-10-28 14:26:17 -01:00
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
2007-09-23 08:04:52 +00:00
Set_defaults
2010-09-07 13:11:20 +00:00
if [ "${LB_BINARY_IMAGES}" = "virtual-hdd" ]
2009-02-25 07:51:28 -01:00
then
exit 0
fi
2009-12-13 19:17:45 -01:00
if [ "${_DEBUG}" = "true" ]
2008-08-10 22:00:03 +00:00
then
WGET_OPTIONS="${WGET_OPTIONS} --verbose"
2009-12-13 19:17:45 -01:00
elif [ "${_QUIET}" = "true" ]
2007-09-23 12:05:14 +00:00
then
WGET_OPTIONS="${WGET_OPTIONS} --quiet"
2008-08-10 22:00:03 +00:00
else
WGET_OPTIONS="${WGET_OPTIONS} --no-verbose"
2007-09-23 12:05:14 +00:00
fi
2008-03-22 00:30:55 -01:00
# Check d-i configuration
2010-09-07 13:11:20 +00:00
case "${LB_DEBIAN_INSTALLER}" in
2009-12-13 19:17:45 -01:00
true|cdrom|netinst|netboot|businesscard|live)
2007-09-23 08:05:15 +00:00
;;
2009-12-13 19:17:45 -01:00
false)
2007-09-23 08:05:21 +00:00
exit 0
;;
2007-09-23 08:05:13 +00:00
*)
2010-09-07 13:11:20 +00:00
Echo_error "debian-installer flavour %s not supported." "${LB_DEBIAN_INSTALLER}"
2007-09-23 08:05:13 +00:00
exit 1
;;
esac
2007-09-23 08:04:52 +00:00
2007-09-23 08:05:11 +00:00
Echo_message "Begin installing debian-installer..."
2007-09-23 08:04:52 +00:00
# Requiring stage file
2008-10-14 19:32:50 +00:00
Require_stagefile .stage/config .stage/bootstrap
2007-09-23 08:04:52 +00:00
# Checking stage file
Check_stagefile .stage/binary_debian-installer
# Checking lock file
Check_lockfile .lock
# Creating lock file
Create_lockfile .lock
2008-04-16 05:19:10 +00:00
# Checking depends
Check_package chroot/usr/bin/wget wget
2008-06-15 01:55:33 +00:00
Check_package chroot/usr/bin/apt-ftparchive apt-utils
2008-04-16 05:19:10 +00:00
# Restoring cache
Restore_cache cache/packages_binary
# Installing depends
Install_package
2007-09-23 08:04:52 +00:00
# Setting destination directory
2010-09-07 13:11:20 +00:00
case "${LB_BINARY_IMAGES}" in
2007-09-23 08:04:52 +00:00
net)
2010-12-05 12:27:08 -01:00
DESTDIR="tftpboot/debian-install/${LB_ARCHITECTURES}"
2007-09-23 08:04:52 +00:00
;;
2011-09-13 07:10:28 +00:00
hdd*|tar)
2007-09-23 08:05:12 +00:00
DESTDIR="binary/install"
2007-09-23 08:04:52 +00:00
;;
2009-07-15 12:17:35 +00:00
*)
DESTDIR="binary/install"
;;
2007-09-23 08:04:52 +00:00
esac
2008-06-14 16:22:57 +00:00
# Set d-i image type
2010-09-07 13:11:20 +00:00
case "${LB_DEBIAN_INSTALLER}" in
2008-06-14 16:22:57 +00:00
businesscard|netboot|netinst)
2008-06-14 15:41:58 +00:00
DI_IMAGE_TYPE="netboot"
2008-03-22 17:09:46 -01:00
;;
*)
2010-09-07 13:11:20 +00:00
case "${LB_BINARY_IMAGES}" in
2008-08-11 00:27:32 +00:00
net)
DI_IMAGE_TYPE="netboot"
2008-03-22 17:09:46 -01:00
;;
2008-06-14 16:22:57 +00:00
2008-03-22 17:09:46 -01:00
*)
2008-08-11 00:27:32 +00:00
DI_IMAGE_TYPE="cdrom"
2008-03-22 17:09:46 -01:00
;;
esac
;;
esac
2009-08-04 23:16:57 +00:00
# Set architecture-specific variables
2010-12-05 12:27:08 -01:00
case "${LB_ARCHITECTURES}" in
2011-07-21 15:57:15 +00:00
armel)
DEFAULT_FLAVOUR="$(echo ${LH_LINUX_FLAVOURS} | awk '{ print $1 }')"
case "${DI_IMAGE_TYPE}" in
cdrom)
DI_REMOTE_BASE="${DEFAULT_FLAVOUR}/cdrom"
;;
netboot)
DI_REMOTE_BASE="${DEFAULT_FLAVOUR}/netboot"
;;
esac
DI_REMOTE_KERNEL="vmlinuz"
DI_REMOTE_BASE_GTK="${DI_REMOTE_BASE}/gtk"
;;
2008-06-14 16:27:42 +00:00
powerpc)
2008-07-04 21:25:47 +00:00
case "${DI_IMAGE_TYPE}" in
cdrom)
2010-12-05 12:27:08 -01:00
DI_REMOTE_BASE="${LB_ARCHITECTURES}/cdrom"
2008-07-04 21:25:47 +00:00
;;
netboot)
2010-12-05 12:27:08 -01:00
DI_REMOTE_BASE="${LB_ARCHITECTURES}/netboot"
2008-07-04 21:25:47 +00:00
;;
esac
DI_REMOTE_KERNEL="vmlinux"
DI_REMOTE_BASE_GTK="${DI_REMOTE_BASE}/gtk"
2008-06-14 16:27:42 +00:00
;;
2008-07-04 21:25:47 +00:00
2008-06-15 03:47:23 +00:00
sparc)
2010-09-07 13:11:20 +00:00
DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
2008-06-15 03:47:23 +00:00
DI_REMOTE_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
DI_REMOTE_BASE_GTK="none"
2009-11-16 10:40:43 -01:00
DI_REMOTE_BASE="cdrom"
2008-06-15 03:47:23 +00:00
;;
2009-08-04 23:16:57 +00:00
*)
case "${DI_IMAGE_TYPE}" in
netboot)
2010-12-05 12:27:08 -01:00
DI_REMOTE_BASE="netboot/debian-installer/${LB_ARCHITECTURES}"
DI_REMOTE_BASE_GTK="netboot/gtk/debian-installer/${LB_ARCHITECTURES}"
2009-08-04 23:16:57 +00:00
DI_REMOTE_KERNEL="linux"
;;
cdrom)
DI_REMOTE_BASE="cdrom"
DI_REMOTE_BASE_GTK="cdrom/gtk"
DI_REMOTE_KERNEL="vmlinuz"
;;
esac
;;
2008-06-14 16:27:42 +00:00
esac
2010-12-05 12:27:08 -01:00
Check_multiarchitectures
2007-09-23 08:04:52 +00:00
2008-01-15 01:43:42 -01:00
Install_file() {
2008-03-22 17:05:42 -01:00
local FILE
FILE="${1}"
local TARGET
TARGET="${2}"
2008-01-15 01:43:42 -01:00
SOURCE="$(dpkg -f ${FILE} Source | awk '{ print $1 }')"
if [ -z "${SOURCE}" ]
then
SOURCE="$(basename ${FILE} | awk -F_ '{ print $1 }')"
fi
case "${SOURCE}" in
lib?*)
2008-01-15 06:25:29 -01:00
LETTER="$(echo ${SOURCE} | sed 's|\(....\).*|\1|')"
2008-01-15 01:43:42 -01:00
;;
*)
2008-01-15 06:25:29 -01:00
LETTER="$(echo ${SOURCE} | sed 's|\(.\).*|\1|')"
2008-01-15 01:43:42 -01:00
;;
esac
# Install directory
2008-01-15 18:42:28 -01:00
mkdir -p "${TARGET}"/"${LETTER}"/"${SOURCE}"
2008-01-15 01:43:42 -01:00
# Move files
2008-01-15 18:42:28 -01:00
cp "${FILE}" "${TARGET}"/"${LETTER}"/"${SOURCE}"
2008-01-15 01:43:42 -01:00
}
2008-07-24 04:48:47 +00:00
# Set absolute directory for caching; we require it when we call Download_file
# from a non-standard cwd.
2010-09-07 13:11:20 +00:00
_LB_CACHE_DIR="$(pwd)/cache/binary_debian-installer"
2008-07-24 04:48:47 +00:00
2008-07-24 03:42:59 +00:00
Download_file () {
2010-09-07 13:11:20 +00:00
local _LB_TARGET
_LB_TARGET="${1}"
2008-07-24 03:42:59 +00:00
2010-09-07 13:11:20 +00:00
local _LB_URL
_LB_URL="${2}"
2008-07-24 03:42:59 +00:00
2010-09-07 13:11:20 +00:00
_LB_CACHE_FILE="${_LB_CACHE_DIR}/$(echo "${_LB_URL}" | sed 's|/|_|g')"
2008-07-24 04:48:47 +00:00
2010-09-07 13:11:20 +00:00
if [ ! -f "${_LB_CACHE_FILE}" ]
2008-07-24 04:48:47 +00:00
then
2010-09-07 13:11:20 +00:00
mkdir -p ${_LB_CACHE_DIR}
if ! wget ${WGET_OPTIONS} -O "${_LB_CACHE_FILE}" "${_LB_URL}"
2008-07-25 23:27:29 +00:00
then
2010-09-07 13:11:20 +00:00
rm -f "${_LB_CACHE_FILE}"
2008-07-25 23:27:29 +00:00
2010-09-07 13:11:20 +00:00
Echo_error "Could not download file: %s" "${_LB_URL}"
2008-07-25 23:27:29 +00:00
exit 1
fi
2008-07-24 04:48:47 +00:00
fi
2010-09-07 13:11:20 +00:00
if [ "$(stat --printf %d "${_LB_CACHE_DIR}")" = "$(stat --printf %d ./)" ]
2008-08-07 19:08:04 +00:00
then
CP_OPTIONS="-l"
fi
2010-09-07 13:11:20 +00:00
cp -f ${CP_OPTIONS} -- "${_LB_CACHE_FILE}" "${_LB_TARGET}"
2008-07-24 03:42:59 +00:00
}
2008-06-14 16:30:32 +00:00
VMLINUZ_DI="vmlinuz"
INITRD_DI="initrd.gz"
DESTDIR_DI="${DESTDIR}"
VMLINUZ_GI="gtk/vmlinuz"
INITRD_GI="gtk/initrd.gz"
DESTDIR_GI="${DESTDIR}/gtk"
2011-09-28 05:09:05 +00:00
case "${LB_DERIVATIVE}" in
false)
if [ "${LB_DEBIAN_INSTALLER_DISTRIBUTION}" = "daily" ]
then
# FIXME: variable name should be decupled from derivatves
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="sid"
2008-08-10 06:02:33 +00:00
2011-09-28 05:09:05 +00:00
# Debian Installer daily builds
URL="http://d-i.debian.org/daily-images/${LB_ARCHITECTURES}/daily/"
else
URL="${LB_MIRROR_DEBIAN_INSTALLER}/dists/${LB_DEBIAN_INSTALLER_DISTRIBUTION}/main/installer-${LB_ARCHITECTURES}/current/images/"
fi
;;
true)
if [ "${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}" = "daily" ]
then
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="sid"
# Debian Installer daily builds
URL="http://d-i.debian.org/daily-images/${LB_ARCHITECTURES}/daily/"
else
URL="${LB_PARENT_MIRROR_DEBIAN_INSTALLER}/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/installer-${LB_ARCHITECTURES}/current/images/"
fi
2011-10-30 07:49:41 -01:00
if [ "${LB_MODE}" = "progress" ]
then
# FIXME: normal derivatives probably don't rebuild d-i,
# but progress does.
URL="${LB_MIRROR_DEBIAN_INSTALLER}/dists/${LB_DEBIAN_INSTALLER_DISTRIBUTION}/main/installer-${LB_ARCHITECTURES}/current/images/"
fi
2011-09-28 05:09:05 +00:00
;;
esac
2007-09-23 08:05:14 +00:00
2007-09-23 08:05:12 +00:00
mkdir -p "${DESTDIR_DI}"
2010-12-05 12:27:08 -01:00
if [ "${LB_ARCHITECTURES}" = "sparc" ] && [ "${DI_IMAGE_TYPE}" = "netboot" ]
2008-06-15 03:47:23 +00:00
then
# There are no prepared kernel/initrd pairs for sparc netboot so we
# must unpack them from a mini.iso
2009-11-16 10:40:43 -01:00
Download_file mini.iso ${URL}/mini.iso
2008-06-15 03:47:23 +00:00
mkdir mini.tmp
2010-09-07 13:11:20 +00:00
${LB_ROOT_COMMAND} mount -o loop -t iso9660 mini.iso mini.tmp
2008-06-15 03:47:23 +00:00
cp mini.tmp/boot/vmlinuz-${DEFAULT_FLAVOUR} "${DESTDIR}"/"${VMLINUZ_DI}"
cp mini.tmp/boot/initrd.gz "${DESTDIR}"/"${INITRD_DI}"
2010-09-07 13:11:20 +00:00
${LB_ROOT_COMMAND} umount mini.tmp
2008-06-15 03:47:23 +00:00
rm -rf mini.tmp mini.iso
else
# Downloading debian-installer
2008-07-24 03:42:59 +00:00
Download_file "${DESTDIR}"/"${VMLINUZ_DI}" ${URL}/${DI_REMOTE_BASE}/${DI_REMOTE_KERNEL}
Download_file "${DESTDIR}"/"${INITRD_DI}" ${URL}/${DI_REMOTE_BASE}/initrd.gz
2008-06-15 03:47:23 +00:00
# Downloading graphical-installer
2008-07-04 21:28:20 +00:00
DOWNLOAD_GTK_INSTALLER=0
2010-09-07 13:11:20 +00:00
if [ "${LB_DEBIAN_INSTALLER_GUI}" = "true" ]
2009-09-02 05:39:13 +00:00
then
2010-12-05 12:27:08 -01:00
case "${LB_ARCHITECTURES}" in
2009-12-09 19:54:41 -01:00
amd64|i386)
2008-07-04 21:28:20 +00:00
DOWNLOAD_GTK_INSTALLER=1
2009-09-02 05:39:13 +00:00
;;
powerpc)
2010-09-07 13:11:20 +00:00
if [ "${LB_DEBIAN_INSTALLER}" = "netboot" ]
2009-09-02 05:39:13 +00:00
then
DOWNLOAD_GTK_INSTALLER=1
fi
;;
esac
fi
2008-07-04 21:28:20 +00:00
if [ ${DOWNLOAD_GTK_INSTALLER} -eq 1 ]
then
mkdir -p "${DESTDIR_GI}"
2008-07-24 03:42:59 +00:00
Download_file "${DESTDIR}"/"${VMLINUZ_GI}" ${URL}/${DI_REMOTE_BASE_GTK}/${DI_REMOTE_KERNEL}
Download_file "${DESTDIR}"/"${INITRD_GI}" ${URL}/${DI_REMOTE_BASE_GTK}/initrd.gz
2008-07-04 21:28:20 +00:00
fi
2008-06-15 03:47:23 +00:00
fi
2007-09-23 08:04:52 +00:00
2008-03-22 00:24:32 -01:00
# Only download additional packages if appropriate
2008-06-14 15:41:58 +00:00
if [ "${DI_IMAGE_TYPE}" != "netboot" ]
2008-03-22 00:24:32 -01:00
then
2007-09-23 08:05:13 +00:00
# Downloading additional packages
mkdir -p chroot/binary.deb/archives/partial
2008-08-10 22:03:11 +00:00
mkdir -p binary/pool/main
2007-09-23 08:05:13 +00:00
mv chroot/var/lib/dpkg/status chroot/var/lib/dpkg/status.tmp
touch chroot/var/lib/dpkg/status
2007-09-23 08:04:52 +00:00
2010-12-05 12:27:08 -01:00
case "${LB_ARCHITECTURES}" in
2007-09-23 08:05:13 +00:00
amd64)
2011-07-25 15:13:32 +00:00
DI_REQ_PACKAGES="lilo grub grub-pc"
2009-12-14 06:39:19 -01:00
2010-09-07 13:11:20 +00:00
case "${LB_MODE}" in
2011-07-19 08:51:20 +00:00
ubuntu|kubuntu)
2010-12-13 21:29:07 -01:00
DI_PACKAGES="${DI_REQ_PACKAGES} linux-generic"
2009-12-14 06:39:19 -01:00
;;
*)
DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-amd64"
;;
esac
2007-09-23 08:05:13 +00:00
;;
2007-09-23 08:04:52 +00:00
2009-12-09 19:54:41 -01:00
i386)
2011-07-25 15:13:32 +00:00
DI_REQ_PACKAGES="elilo lilo grub grub-pc"
2009-12-14 06:39:19 -01:00
2010-09-07 13:11:20 +00:00
case "${LB_MODE}" in
2011-07-19 08:51:20 +00:00
ubuntu|kubuntu)
2010-12-13 21:29:07 -01:00
DI_PACKAGES="${DI_REQ_PACKAGES} linux-generic"
2009-12-14 06:39:19 -01:00
;;
*)
DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-486 linux-image-2.6-686"
;;
esac
2007-09-23 08:05:13 +00:00
;;
2007-09-23 08:04:52 +00:00
2008-06-15 03:47:23 +00:00
sparc)
2008-08-17 04:58:43 +00:00
DI_REQ_PACKAGES="silo"
2010-12-13 21:29:07 -01:00
case "${LB_MODE}" in
2011-07-19 08:51:20 +00:00
ubuntu|kubuntu)
2010-12-13 21:29:07 -01:00
DI_PACKAGES="${DI_REQ_PACKAGES} linux-sparc64"
;;
*)
DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-sparc64 linux-image-2.6-sparc64-smp"
;;
esac
2008-06-15 03:47:23 +00:00
;;
2007-09-23 08:05:13 +00:00
powerpc)
2008-08-11 00:13:45 +00:00
DI_REQ_PACKAGES="yaboot"
2010-12-13 21:29:07 -01:00
case "${LB_MODE}" in
2011-07-19 08:51:20 +00:00
ubuntu|kubuntu)
2010-12-13 21:29:07 -01:00
DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-powerpc linux-image-powerpc64-smp"
;;
*)
DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-powerpc linux-image-2.6-powerpc64 linux-image-2.6-powerpc-smp"
;;
esac
2007-09-23 08:05:13 +00:00
;;
esac
2011-07-24 07:19:39 +00:00
DI_PACKAGES="${DI_PACKAGES} busybox cryptsetup mdadm lvm2"
2007-09-23 08:04:52 +00:00
2010-09-20 19:49:27 +00:00
case "${LB_MODE}" in
debian)
2010-09-26 10:38:38 +00:00
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} console-setup keyboard-configuration kbd"
DI_PACKAGES="${DI_PACKAGES} console-setup keyboard-configuration kbd"
2010-09-20 19:49:27 +00:00
;;
esac
2008-08-11 00:13:45 +00:00
# Set apt command prefix
2010-09-07 13:11:20 +00:00
_LB_APT_COMMAND="apt-get ${APT_OPTIONS} -o Dir::Cache=/binary.deb -o APT::Install-Recommends=false --download-only"
2008-08-11 00:13:45 +00:00
2010-09-07 13:11:20 +00:00
if [ "${LB_DEBIAN_INSTALLER}" = "live" ]
2008-08-11 00:13:45 +00:00
then
# We don't want to duplicate .debs of packages in binary/pool that are already
# installed to target/ via live-installer.
#
# However, we need to force various packages' inclusion in binary/pool/main as
# d-i does not support (for example) re-installing grub from target/ - the grub
2008-08-17 04:58:43 +00:00
# .debs must actually exist.
2008-08-11 00:13:45 +00:00
# Modify dpkg status to show the required packages are not installed.
cp chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
for PACKAGE in ${DI_REQ_PACKAGES}
do
awk -v f=0 '
f == 1 { print "Status: purge ok not-installed"; f=0; next }
/Package: '"${PACKAGE}"'/ { f=1; }
{ print }
' chroot/var/lib/dpkg/status > chroot/var/lib/dpkg/status.awk
mv chroot/var/lib/dpkg/status.awk chroot/var/lib/dpkg/status
done
# Download .deb's that we just marked as "purged" which caused broken dependencies
2010-09-07 13:11:20 +00:00
Chroot chroot ${_LB_APT_COMMAND} -f dist-upgrade
2008-08-11 00:13:45 +00:00
# Revert dpkg status file
mv chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
# Download .debs of the required packages
2010-09-07 13:11:20 +00:00
Chroot chroot ${_LB_APT_COMMAND} install ${DI_REQ_PACKAGES}
2010-11-22 18:40:07 -01:00
Chroot chroot ${_LB_APT_COMMAND} install ${DI_PACKAGES}
2008-08-11 00:13:45 +00:00
else
# Download .debs of the required packages
2010-09-07 13:11:20 +00:00
Chroot chroot ${_LB_APT_COMMAND} install ${DI_PACKAGES}
2008-08-11 00:13:45 +00:00
# Revert dpkg status file
mv chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
fi
2007-09-23 08:05:13 +00:00
mv chroot/binary.deb ./
2008-04-17 08:42:34 +00:00
2008-08-09 01:20:56 +00:00
if Find_files binary.deb/archives/*.deb
2008-01-15 18:47:50 -01:00
then
for FILE in binary.deb/archives/*.deb
do
Install_file "${FILE}" "binary/pool/main"
done
fi
2007-09-23 08:04:52 +00:00
2010-09-07 13:11:20 +00:00
if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
2008-03-22 00:24:32 -01:00
then
2008-08-10 22:02:01 +00:00
# Including base debian packages
2010-04-02 15:48:03 +00:00
if ls cache/packages_bootstrap/*.deb > /dev/null 2>&1
2008-08-10 22:02:01 +00:00
then
for FILE in cache/packages_bootstrap/*.deb
do
Install_file "${FILE}" "binary/pool/main"
done
else
2010-04-02 15:48:03 +00:00
Echo_error "Could not find packages in cache/packages_bootstrap."
2010-09-07 13:11:20 +00:00
Echo_error "You selected values of LB_CACHE, LB_CACHE_PACKAGES, LB_CACHE_STAGES and LB_DEBIAN_INSTALLER which will result in 'bootstrap' packages not being cached - these are required when integrating the Debian Installer."
2008-08-10 22:02:01 +00:00
exit 1
fi
2008-03-22 00:24:32 -01:00
fi
2007-09-23 08:04:52 +00:00
2008-03-22 00:24:32 -01:00
# Including local debs
2011-09-14 19:44:04 +00:00
if Find_files config/packages.binary/*_"${LB_ARCHITECTURES}".deb || Find_files config/packages/*_"${LB_ARCHITECTURES}".deb
2008-03-22 00:24:32 -01:00
then
2011-09-07 15:33:53 +00:00
for FILE in config/packages.binary/*_"${LB_ARCHITECTURES}".deb config/packages/*_"${LB_ARCHITECTURES}".deb
2008-03-22 00:24:32 -01:00
do
2011-09-07 15:33:53 +00:00
if [ -e "${FILE}" ]
then
Install_file "${FILE}" "binary/pool/main"
fi
2008-03-22 00:24:32 -01:00
done
fi
2008-01-15 01:41:10 -01:00
2011-09-14 19:44:04 +00:00
if Find_files config/packages.binary/*_all.deb || Find_files config/packages/*_all.deb
2008-03-22 00:24:32 -01:00
then
2011-09-07 15:33:53 +00:00
for FILE in config/packages.binary/*_all.deb config/packages/*_all.deb
2008-03-22 00:24:32 -01:00
do
2011-09-07 15:33:53 +00:00
if [ -e "${FILE}" ]
then
Install_file "${FILE}" "binary/pool/main"
fi
2008-03-22 00:24:32 -01:00
done
fi
2007-09-23 08:05:13 +00:00
2008-03-22 00:24:32 -01:00
# Generating deb indices
2011-02-14 10:29:25 -01:00
mkdir -p binary/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LB_ARCHITECTURES}
2007-09-23 08:04:52 +00:00
2009-01-26 11:59:24 -01:00
mv binary chroot/root
2011-02-14 10:29:25 -01:00
echo "cd /root/binary && apt-ftparchive packages pool/main > dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LB_ARCHITECTURES}/Packages" > chroot/binary.sh
2009-01-26 11:59:24 -01:00
Chroot chroot "sh binary.sh"
rm -f chroot/binary.sh
mv chroot/root/binary ./
2011-02-14 10:29:25 -01:00
gzip -9 -c binary/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LB_ARCHITECTURES}/Packages > binary/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LB_ARCHITECTURES}/Packages.gz
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Fetching release
2011-02-14 11:11:26 -01:00
Download_file binary/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LB_ARCHITECTURES}/Release "${LB_PARENT_MIRROR_CHROOT}"/dists/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/main/binary-"${LB_ARCHITECTURES}"/Release
2007-09-23 08:04:52 +00:00
2011-02-14 13:49:18 -01:00
# Udeb handling
2008-03-22 00:24:32 -01:00
mkdir binary.udeb
cd binary.udeb
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Downloading udeb indices
2011-02-14 11:11:26 -01:00
Download_file Packages.gz "${LB_PARENT_MIRROR_CHROOT}"/dists/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LB_ARCHITECTURES}"/Packages.gz
2008-03-22 00:24:32 -01:00
gunzip -c Packages.gz > Packages
2007-09-23 08:05:12 +00:00
2011-02-14 13:49:18 -01:00
if [ "${LB_DERIVATIVE}" = "true" ]
then
Download_file Packages.derivative.gz "${LB_MIRROR_CHROOT}"/dists/"${LB_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LB_ARCHITECTURES}"/Packages.gz
gunzip -c Packages.derivative.gz > Packages.derivative
fi
2008-03-22 00:24:32 -01:00
# Sorting udebs
2011-02-14 13:49:18 -01:00
if [ "${LB_DERIVATIVE}" = true ]
then
2011-02-15 09:02:12 -01:00
UDEBS="$(awk '/Filename: / { print $2 }' Packages.derivative)"
2011-02-14 13:49:18 -01:00
fi
2011-02-15 09:02:12 -01:00
UDEBS="${UDEBS} $(awk '/Filename: / { print $2 }' Packages)"
2008-03-22 00:24:32 -01:00
# Downloading udebs
for UDEB in ${UDEBS}
do
if [ -f ../cache/packages_debian-installer.udeb/"$(basename ${UDEB})" ]
then
# Copying cached udebs
cp ../cache/packages_debian-installer.udeb/"$(basename ${UDEB})" ./
else
# Downloading udebs
2011-02-15 09:02:12 -01:00
if ! ls "$(basename ${UDEB} | awk -F_ '{ print $1 }')"_* > /dev/null 2>&1
then
wget ${WGET_OPTIONS} "${LB_MIRROR_CHROOT}"/${UDEB} || wget ${WGET_OPTIONS} "${LB_PARENT_MIRROR_CHROOT}"/${UDEB}
fi
2008-03-22 00:24:32 -01:00
fi
done
# Caching udebs
rm -rf ../cache/packages_debian-installer.udeb
mkdir -p ../cache/packages_debian-installer.udeb
cp *.udeb ../cache/packages_debian-installer.udeb
# Including local udebs
2011-09-07 15:33:53 +00:00
if Find_files ../config/packages.binary/*_"${LB_ARCHITECTURES}".udeb || Find_files ../config/packages/*_"${LB_ARCHITECTURES}".udeb
2007-09-23 08:05:13 +00:00
then
2011-09-07 15:33:53 +00:00
for FILE in ../config/packages.binary/*_"${LB_ARCHITECTURES}".udeb ../config/packages/*_"${LB_ARCHITECTURES}".udeb
2008-03-22 00:24:32 -01:00
do
2011-09-07 15:33:53 +00:00
if [ -e "${FILE}" ]
then
Install_file "${FILE}" "pool/main"
2008-03-22 00:24:32 -01:00
2011-09-07 15:33:53 +00:00
# Prefer local udebs over downloaded udebs
rm -f "$(basename ${FILE} | awk -F_ '{ print $1 }')"_*.udeb
fi
2008-03-22 00:24:32 -01:00
done
2007-09-23 08:05:13 +00:00
fi
2008-04-17 08:42:34 +00:00
2011-09-07 15:33:53 +00:00
if Find_files ../config/packages.binary/*_all.udeb || Find_files ../config/packages/*_all.udeb
2008-03-22 00:24:32 -01:00
then
2011-09-07 15:33:53 +00:00
for FILE in ../config/packages.binary/*_all.udeb ../config/packages/*_all.udeb
2008-03-22 00:24:32 -01:00
do
2011-09-07 15:33:53 +00:00
if [ -e "${FILE}" ]
then
Install_file "${FILE}" "pool/main"
2007-09-23 08:05:12 +00:00
2011-09-07 15:33:53 +00:00
# Prefer local udebs over downloaded udebs
rm -f "$(basename ${FILE} | awk -F_ '{ print $1 }')"_*.udeb
fi
2008-03-22 00:24:32 -01:00
done
fi
2007-09-23 08:05:13 +00:00
2008-03-22 00:24:32 -01:00
# Excluding udebs
2011-02-14 10:29:25 -01:00
grep -v "^#" "${LB_BASE}"/data/debian-cd/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/udeb_exclude > exclude || true
grep -v "^#" "${LB_BASE}"/data/debian-cd/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/exclude-udebs >> exclude || true
grep -v "^#" "${LB_BASE}"/data/debian-cd/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/exclude-udebs-${LB_ARCHITECTURES} >> exclude || true
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Local exclude file
if [ -e ../config/binary_debian-installer/udeb_exclude ]
then
cat ../config/binary_debian-installer/udeb_exclude >> exclude
fi
2007-09-23 08:05:12 +00:00
2009-06-30 14:45:36 +00:00
# Excluding udebs from excludes because we want them to be in the image on purpose
sed -i -e 's|di-utils-exit-installer||' exclude # used for live-installer-launcher
2008-08-17 06:06:13 +00:00
while read EXCLUDE
2008-03-22 00:24:32 -01:00
do
2010-09-07 13:11:20 +00:00
if [ "${LB_DEBIAN_INSTALLER}" = "live" ] && [ "${EXCLUDE}" = "live-installer" ]
2008-06-13 14:52:16 +00:00
then
continue
fi
2008-08-17 06:06:13 +00:00
rm -f ${EXCLUDE}_*.udeb
done < exclude
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Enable live-installer
2010-09-07 13:11:20 +00:00
if [ "${LB_DEBIAN_INSTALLER}" = "live" ]
2008-03-22 00:24:32 -01:00
then
# Remove local udebs
rm -f pool/main/b/base-installer/bootstrap-base_*.udeb
2007-09-23 12:05:14 +00:00
2008-03-22 00:24:32 -01:00
# Remove d-i udebs
rm -f bootstrap-base_*.udeb
fi
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Moving udebs
for UDEB in ${UDEBS}
do
if [ -f "$(basename ${UDEB})" ]
then
mkdir -p $(dirname ${UDEB})
mv "$(basename ${UDEB})" "$(dirname ${UDEB})"
fi
done
2007-09-23 12:05:11 +00:00
2008-03-22 00:24:32 -01:00
# Creating udeb indices
2011-02-14 10:29:25 -01:00
mkdir -p dists/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LB_ARCHITECTURES}"
2009-01-26 11:59:24 -01:00
cd "${OLDPWD}"
mv binary.udeb chroot/root
2011-02-14 10:29:25 -01:00
echo "cd /root/binary.udeb && apt-ftparchive packages pool/main > dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LB_ARCHITECTURES}/Packages" > chroot/binary.sh
2009-01-26 11:59:24 -01:00
Chroot chroot "sh binary.sh"
rm -f chroot/binary.sh
mv chroot/root/binary.udeb ./
cd binary.udeb
2011-02-14 10:29:25 -01:00
gzip -9 -c dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LB_ARCHITECTURES}/Packages > dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LB_ARCHITECTURES}/Packages.gz
2008-03-22 00:24:32 -01:00
rm -f Packages* exclude
find . | cpio -dmpu "${OLDPWD}"/binary
cd "${OLDPWD}"
rm -rf binary.udeb
rm -rf binary.deb
# Generating release file
2009-01-26 11:59:24 -01:00
mv binary chroot/root
2011-01-07 19:56:33 -01:00
eval _VERSION="$`echo RELEASE_${LB_PARENT_DISTRIBUTION}`"
2010-09-26 20:36:55 +00:00
2011-01-07 19:56:33 -01:00
case "${LB_PARENT_DISTRIBUTION}" in
2010-09-26 21:00:52 +00:00
sid)
_SUITE="unstable"
;;
*)
2011-01-07 19:56:33 -01:00
_SUITE="${LB_PARENT_DISTRIBUTION}"
2010-09-26 21:00:52 +00:00
;;
esac
2009-01-26 11:59:24 -01:00
cat > chroot/binary.sh << EOF
cd /root/binary && apt-ftparchive \
-o APT::FTPArchive::Release::Origin="Debian" \
-o APT::FTPArchive::Release::Label="Debian" \
2010-09-26 21:00:52 +00:00
-o APT::FTPArchive::Release::Suite="${_SUITE}" \
2010-09-26 20:36:55 +00:00
-o APT::FTPArchive::Release::Version="${_VERSION}" \
2011-01-07 19:56:33 -01:00
-o APT::FTPArchive::Release::Codename="${LB_PARENT_DISTRIBUTION}" \
2009-01-26 11:59:24 -01:00
-o APT::FTPArchive::Release::Date="$(date -R)" \
2010-12-05 12:27:08 -01:00
-o APT::FTPArchive::Release::Architectures="${LB_ARCHITECTURES}" \
2009-01-26 11:59:24 -01:00
-o APT::FTPArchive::Release::Components="main" \
-o APT::FTPArchive::Release::Description="Last updated: $(date -R)" \
2011-02-14 10:29:25 -01:00
release dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} > dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/Release
2009-01-26 11:59:24 -01:00
EOF
Chroot chroot "sh binary.sh"
rm -f chroot/binary.sh
mv chroot/root/binary ./
2008-03-22 00:24:32 -01:00
2010-11-13 13:45:36 -01:00
DISTRIBUTIONS="frozen stable testing unstable"
2011-02-14 10:29:25 -01:00
if [ "${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}" != "${LB_PARENT_DISTRIBUTION}" ]
2010-11-13 13:45:36 -01:00
then
2011-01-07 19:56:33 -01:00
DISTRIBUTIONS="${DISTRIBUTIONS} ${LB_PARENT_DISTRIBUTION}"
2010-11-13 13:45:36 -01:00
fi
case "${LB_BINARY_IMAGES}" in
2011-09-13 07:10:28 +00:00
hdd)
2010-11-13 13:45:36 -01:00
case "${LB_BINARY_FILESYSTEM}" in
fat*)
# Creating dist directories
for DISTRIBUTION in ${DISTRIBUTIONS}
do
2011-02-14 10:29:25 -01:00
cp -a binary/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} binary/dists/${DISTRIBUTION}
2010-11-13 13:45:36 -01:00
done
;;
esac
2010-02-18 15:12:59 -01:00
;;
*)
2010-11-02 09:41:51 -01:00
# Creating dist symlinks
2010-11-13 13:45:36 -01:00
for DISTRIBUTION in ${DISTRIBUTIONS}
2010-11-02 09:41:51 -01:00
do
2011-02-14 10:29:25 -01:00
ln -s ${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} binary/dists/${DISTRIBUTION}
2010-11-02 09:41:51 -01:00
done
2010-02-18 15:12:59 -01:00
ln -s . binary/debian
;;
esac
2007-09-23 08:04:52 +00:00
2008-03-22 00:24:32 -01:00
# Including preseeding files
2008-08-16 09:12:27 +00:00
if Find_files config/binary_debian-installer/*.cfg
2008-03-22 00:24:32 -01:00
then
2008-08-12 20:00:20 +00:00
cp config/binary_debian-installer/*.cfg binary/install
2008-03-22 00:24:32 -01:00
fi
2008-02-29 11:27:56 -01:00
fi
2008-04-17 08:42:34 +00:00
Repack_initrd()
{
2008-03-22 17:13:03 -01:00
local TARGET_INITRD
2008-12-02 14:56:02 -01:00
local INCLUDE_PATH
2008-03-22 17:13:03 -01:00
TARGET_INITRD="${1}"
2008-12-02 14:56:02 -01:00
INCLUDE_PATH="${2}"
2008-03-22 17:13:03 -01:00
REPACK_TMPDIR="unpacked-initrd"
2008-04-17 08:42:34 +00:00
2008-12-02 14:56:02 -01:00
if [ -d "${INCLUDE_PATH}" ]
then
INCLUDE_PATH=$(readlink -f ${INCLUDE_PATH})
fi
2008-03-22 17:13:03 -01:00
# cpio does not have a "extract to directory", so we must change directory
mkdir -p ${REPACK_TMPDIR}
cd ${REPACK_TMPDIR}
gzip -d < ../${TARGET_INITRD} | cpio -i --make-directories --no-absolute-filenames
2008-12-02 14:56:02 -01:00
if [ ! -d "${INCLUDE_PATH}" ]
then
# Invoked the old way, just copy the preseeds
cp ../config/binary_debian-installer/*.cfg .
else
# New way, include target directory content in the initrd
REPACK_TMPDIR_ABS="${PWD}"
cd "${INCLUDE_PATH}"
find -print0 | cpio -pumd0 --no-preserve-owner "${REPACK_TMPDIR_ABS}/"
cd "${OLDPWD}"
fi
find -print0 | cpio -H newc -o0 | gzip -9 > ../${TARGET_INITRD}
2008-03-22 17:13:03 -01:00
cd ..
rm -rf ${REPACK_TMPDIR}
}
# Preseed d-i by repacking the initrd in certain situations
2008-06-14 15:41:58 +00:00
if [ "${DI_IMAGE_TYPE}" = "netboot" ] && [ -e config/binary_debian-installer/preseed.cfg ]
2008-03-22 17:13:03 -01:00
then
2008-04-17 08:42:34 +00:00
Repack_initrd "${DESTDIR}"/"${INITRD_DI}"
2008-03-22 17:13:03 -01:00
if [ -e "${DESTDIR}"/"${INITRD_GI}" ]
then
2008-04-17 08:42:34 +00:00
Repack_initrd "${DESTDIR}"/"${INITRD_GI}"
2008-03-22 17:13:03 -01:00
fi
fi
2008-12-02 14:56:02 -01:00
# Include content of config/binary_debian-installer-includes if exists and not empty
if [ -d config/binary_debian-installer-includes ] && [ -n "$(ls -A config/binary_debian-installer-includes)" ]
then
Repack_initrd "${DESTDIR}"/"${INITRD_DI}" config/binary_debian-installer-includes
if [ -e "${DESTDIR}"/"${INITRD_GI}" ]
then
Repack_initrd "${DESTDIR}"/"${INITRD_GI}" config/binary_debian-installer-includes
fi
fi
2008-04-16 05:19:10 +00:00
# Saving cache
Save_cache cache/packages_binary
# Removing depends
Remove_package
2007-09-23 08:04:52 +00:00
# Creating stage file
Create_stagefile .stage/binary_debian-installer