2007-09-23 08:04:52 +00:00
#!/bin/sh
2010-09-02 11:12:37 +00:00
## live-build(7) - System Build Scripts
2020-03-11 09:07:21 -01:00
## Copyright (C) 2016-2020 The Debian Live team
2015-01-04 18:05:39 -01:00
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
2010-09-02 11:12:37 +00:00
##
2012-07-29 23:59:00 +00:00
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
2010-09-02 11:12:37 +00:00
## 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
2012-08-27 13:52:29 +00:00
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
2007-09-23 08:04:52 +00:00
2007-09-23 08:05:11 +00:00
# Setting static variables
2015-02-05 02:30:47 -01:00
DESCRIPTION="Install debian-installer into binary"
2007-09-23 08:04:52 +00:00
USAGE="${PROGRAM} [--force]"
2015-02-05 02:30:47 -01:00
# Processing arguments and configuration files
Init_config_data "${@}"
2007-09-23 08:04:52 +00:00
2020-03-28 09:26:07 -01:00
if ! In_list "${LB_DEBIAN_INSTALLER}" cdrom netinst netboot businesscard live; then
if [ "${LB_DEBIAN_INSTALLER}" = "none" ]; then
Echo_message "No installer wanted, skipping..."
fi
exit 0
2007-09-23 12:05:14 +00:00
fi
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
2020-03-15 12:05:44 -01:00
Require_stagefiles config bootstrap
2007-09-23 08:04:52 +00:00
# Checking stage file
2020-03-13 16:11:53 -01:00
Check_stagefile
2007-09-23 08:04:52 +00:00
2020-03-13 15:19:59 -01:00
# Acquire lock file
2015-02-05 02:30:47 -01:00
Acquire_lockfile
2007-09-23 08:04:52 +00:00
2022-05-02 17:52:57 +00:00
# Set d-i image type
case "${LB_DEBIAN_INSTALLER}" in
businesscard|netboot|netinst)
DI_IMAGE_TYPE="netboot"
;;
*)
case "${LB_IMAGE_TYPE}" in
netboot)
DI_IMAGE_TYPE="netboot"
;;
*)
DI_IMAGE_TYPE="cdrom"
;;
esac
;;
esac
2008-04-16 05:19:10 +00:00
# Checking depends
2015-01-04 16:22:03 -01:00
Check_package host /usr/bin/wget wget
2015-01-04 16:08:09 -01:00
Check_package chroot /usr/bin/apt-ftparchive apt-utils
2008-04-16 05:19:10 +00:00
# Restoring cache
2015-01-06 02:46:37 -01:00
Restore_package_cache binary
2008-04-16 05:19:10 +00:00
# Installing depends
2020-05-05 15:42:44 +00:00
Install_packages
2008-04-16 05:19:10 +00:00
2020-03-28 09:26:07 -01:00
if [ "${_DEBUG}" = "true" ]
then
WGET_OPTIONS="${WGET_OPTIONS} --verbose"
elif [ "${_QUIET}" = "true" ]
then
WGET_OPTIONS="${WGET_OPTIONS} --quiet"
else
WGET_OPTIONS="${WGET_OPTIONS} --no-verbose"
fi
2007-09-23 08:04:52 +00:00
# Setting destination directory
2020-04-06 17:46:47 +00:00
case "${LB_IMAGE_TYPE}" in
2012-07-18 17:11:55 +00:00
netboot)
2020-04-01 09:58:47 +00:00
DESTDIR="tftpboot/debian-install/${LB_ARCHITECTURE}"
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
2009-08-04 23:16:57 +00:00
# Set architecture-specific variables
2020-04-01 09:58:47 +00:00
case "${LB_ARCHITECTURE}" in
2011-07-21 15:57:15 +00:00
armel)
2014-12-10 05:58:02 -01:00
DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
2011-07-21 15:57:15 +00:00
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)
2020-04-01 09:58:47 +00:00
DI_REMOTE_BASE="${LB_ARCHITECTURE}/cdrom"
2008-07-04 21:25:47 +00:00
;;
netboot)
2020-04-01 09:58:47 +00:00
DI_REMOTE_BASE="${LB_ARCHITECTURE}/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
2009-08-04 23:16:57 +00:00
*)
case "${DI_IMAGE_TYPE}" in
netboot)
2020-04-01 09:58:47 +00:00
DI_REMOTE_BASE="netboot/debian-installer/${LB_ARCHITECTURE}"
DI_REMOTE_BASE_GTK="netboot/gtk/debian-installer/${LB_ARCHITECTURE}"
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
2008-01-15 01:43:42 -01:00
Install_file() {
2020-02-20 05:58:11 -01:00
local FILE="${1}"
2008-03-22 17:05:42 -01:00
2020-03-15 20:45:14 -01:00
Echo_debug "Installing file %s" "${FILE}"
2012-04-26 18:29:37 +00:00
local ARCHIVE_AREA
ARCHIVE_AREA="$(dpkg -I ${FILE} | awk '/^.*Section: / { print $2 }')"
if echo "${ARCHIVE_AREA}" | grep -qs '/'
then
ARCHIVE_AREA="$(echo ${ARCHIVE_AREA} | awk -F/ '{ print $1 }')"
else
ARCHIVE_AREA="main"
fi
2020-02-20 05:58:11 -01:00
local TARGET="${2}/${ARCHIVE_AREA}"
2008-01-15 01:43:42 -01:00
2020-02-20 05:58:11 -01:00
local SOURCE
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
2020-02-20 05:58:11 -01:00
local LETTER
2008-01-15 01:43:42 -01:00
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
2021-01-01 15:51:02 -01:00
cp -a "${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.
2013-08-07 16:13:37 +00:00
_LB_CACHE_DIR="$(pwd)/cache/installer_debian-installer"
2008-07-24 04:48:47 +00:00
2022-05-02 17:52:57 +00:00
Prepare_installer_cache() {
local SRC_FILENAME="${1}"
local DEST_FILENAME="${_LB_CACHE_DIR}/$(echo "${URL}/${SRC_FILENAME}" | sed 's|/|_|g')"
mkdir -p $(dirname ${DEST_FILENAME})
cp -a chroot/debian-installer/build/dest/${SRC_FILENAME} ${DEST_FILENAME}
}
2008-07-24 03:42:59 +00:00
Download_file () {
2020-02-20 05:58:11 -01:00
local _LB_TARGET="${1}"
local _LB_URL="${2}"
2008-07-24 03:42:59 +00:00
2020-03-15 20:45:14 -01:00
Echo_debug "Downloading file \`%s\` from \`%s\`" "${_LB_TARGET}" "${_LB_URL}"
2020-02-20 05:58:11 -01:00
local _LB_CACHE_FILE
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
2020-03-15 20:45:14 -01:00
Echo_debug "Not cached, downloading fresh..."
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
2020-03-15 20:45:14 -01:00
else
Echo_debug "Using copy from cache..."
2008-07-24 04:48:47 +00:00
fi
2020-03-15 20:22:53 -01:00
# Use hardlink if same device
2015-08-10 19:45:00 +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
2021-01-01 15:51:02 -01:00
cp -a -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"
2020-02-11 16:36:54 -01:00
# Debian Installer daily builds
2020-04-01 09:58:47 +00:00
DAILY_DI_URL="https://d-i.debian.org/daily-images/${LB_ARCHITECTURE}/daily"
2020-02-11 16:36:54 -01:00
2011-09-28 05:09:05 +00:00
case "${LB_DERIVATIVE}" in
2020-10-08 17:55:57 +00:00
true)
2011-09-28 05:09:05 +00:00
if [ "${LB_DEBIAN_INSTALLER_DISTRIBUTION}" = "daily" ]
then
2020-10-08 17:55:57 +00:00
# FIXME: variable name should be decoupled from derivatives
LB_DEBIAN_INSTALLER_DISTRIBUTION="sid"
2008-08-10 06:02:33 +00:00
2020-02-11 16:36:54 -01:00
URL="${DAILY_DI_URL}"
2011-09-28 05:09:05 +00:00
else
2020-04-01 09:58:47 +00:00
URL="${LB_MIRROR_DEBIAN_INSTALLER}/dists/${LB_DEBIAN_INSTALLER_DISTRIBUTION}/main/installer-${LB_ARCHITECTURE}/current/images"
2011-09-28 05:09:05 +00:00
fi
;;
2020-10-08 17:55:57 +00:00
false)
2022-05-02 17:52:57 +00:00
if [ "${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}" = "git" -a "${DI_IMAGE_TYPE}" = "cdrom" ]
then
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="${LB_PARENT_DISTRIBUTION_CHROOT}"
URL="${LB_PARENT_MIRROR_CHROOT}/snapshot-build_${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}_${LB_ARCHITECTURE}"
2023-01-08 15:29:57 -01:00
if [ ! -f "${_LB_CACHE_DIR}/$(echo "${URL}/${DI_REMOTE_BASE}/${INITRD_DI}" | sed 's|/|_|g')" ]
then
# Packages that are needed for rebuilding the debian installer
Check_package chroot /lib/module linux-image-generic
Check_package chroot /usr/bin/git git
Check_package chroot /usr/bin/mk-build-deps devscripts
Check_package chroot /usr/bin/equivs-build equivs
Check_package chroot /usr/bin/gcc gcc
Install_packages
2024-08-01 18:05:21 +00:00
# Set architecture-specific variables
case "${LB_ARCHITECTURE}" in
arm64)
TARGETS="build_cdrom_gtk build_cdrom_grub"
;;
*)
TARGETS="build_cdrom_gtk build_cdrom_isolinux"
;;
esac
2023-01-08 15:29:57 -01:00
# These variables do not need to be passed inside the chroot, they can be resolved earlier:
# SOURCE_DATE_EPOCH, _QUIET, LB_PARENT_MIRROR_CHROOT, LB_PARENT_DISTRIBUTION_CHROOT
2024-10-31 15:59:15 -01:00
# TARGETS, http_proxy
2023-01-08 15:29:57 -01:00
cat << EOF > chroot/buildit.sh
2022-05-02 17:52:57 +00:00
#!/bin/sh
# Get the version of the git repo that matches SOURCE_DATE_EPOCH
2022-11-13 10:19:00 -01:00
set -e
2022-05-02 17:52:57 +00:00
DEBIAN_INSTALLER=/debian-installer
mkdir -p \${DEBIAN_INSTALLER}
git clone https://salsa.debian.org/installer-team/debian-installer.git \${DEBIAN_INSTALLER} --single-branch --no-tags --quiet
cd \${DEBIAN_INSTALLER}
git checkout \$(git rev-list -n 1 --min-age=${SOURCE_DATE_EPOCH} HEAD) --quiet
if [ "${_QUIET}" != "true" ]
then
echo "P: using debian-installer from git version \$(git log -n 1 --pretty=format:%H_%aI)"
fi
2023-07-08 06:01:19 +00:00
# Install the build-dependencies, but remove explicit kernel versions,
# because the current kernel version will be used
sed -i '/linux-image-/d' debian/control
2022-05-02 17:52:57 +00:00
mk-build-deps
find -maxdepth 1 -name *.deb | xargs apt-get --yes install
2023-12-31 10:42:41 -01:00
# In kernels since 6.6.8 only a versioned vmlinuz is created
# For older kernels, modify the Makefile to use an existing vmlinuz, if present
# The patch only matches when debian-installer!43 (https://salsa.debian.org/installer-team/debian-installer/-/merge_requests/43) is not merged yet
sed -i -e '/^\\tVMLINUXZ=/s|VMLINUXZ=|if [ ! -e \$(TREE)/boot/vmlinuz ]; then \\\\\\n\\tVMLINUXZ=|' build/Makefile
2024-01-01 09:43:53 -01:00
sed -i -e '/^\\t\\tmv -v \$\$VMLINUXZ/s|; \\\\|; \\\\\\n\\tfi \\\\|' build/Makefile
2023-12-31 10:42:41 -01:00
2022-05-02 17:52:57 +00:00
# Build the installer
cd build
if [ "${_QUIET}" != "true" ]
then
echo "P: building the debian-installer"
fi
# LINUX_KERNEL_ABI -> use the version of the kernel that matches the current kernel, independent of the version in the git repo (config/common)
# Output of dpkg-query:
# ii linux-image-5.17.0-1-amd64
# un linux-image-5.17.0-1-amd64-unsigned
# ii linux-image-amd64
# un linux-image-generic
2023-12-27 13:47:55 -01:00
# Or without the extra version number:
# ii linux-image-6.6.8-amd64
# un linux-image-6.6.8-amd64-unsigned
# ii linux-image-amd64
# un linux-image-generic
2022-05-02 17:52:57 +00:00
# -> extract the 5.17.0-1 for LINUX_KERNEL_ABI
2023-06-20 06:17:14 +00:00
# If there is more than one entry, take the largest (i.e. most recent)
2022-05-02 17:52:57 +00:00
# MIRROR -> our snapshot URL, with disabled expiration
# TARGETS -> only these targets are required
# USE_UDEBS_FROM -> use the same distribution as the chroot
2023-12-27 10:01:06 -01:00
# ROOTCMD -> Workaround for #1058994. Fakeroot is not present in the chroot (and not required)
2023-12-27 13:47:55 -01:00
export LINUX_KERNEL_ABI=\$(dpkg-query --showformat "\\\${db:Status-Abbrev} \\\${Package}\n" --show linux-image-* | awk '\$1=="ii" { c = split(\$2, a, "-"); if (c>3) { if (a[4] ~ /^[0-9]+/) { print a[3] "-" a[4] } else { print a[3] } } }' | sort | tail -1)
2024-10-31 15:59:15 -01:00
http_proxy=${http_proxy} MIRROR="[check-valid-until=no] ${LB_PARENT_MIRROR_CHROOT}" TARGETS="${TARGETS}" USE_UDEBS_FROM=${LB_PARENT_DISTRIBUTION_CHROOT} ROOTCMD=" " bash ./daily-build build-only
2022-05-02 17:52:57 +00:00
EOF
2023-01-08 15:29:57 -01:00
Chroot chroot "sh buildit.sh"
# Place the files in the cache. Download_file will use the cache instead of downloading
Prepare_installer_cache cdrom/"${VMLINUZ_DI}"
Prepare_installer_cache cdrom/"${INITRD_DI}"
Prepare_installer_cache cdrom/"${VMLINUZ_GI}"
Prepare_installer_cache cdrom/"${INITRD_GI}"
rm -rf chroot/debian-installer
rm -f chroot/buildit.sh
else
Echo_debug "Not rebuilding the installer, using copy from cache..."
fi
2022-05-02 17:52:57 +00:00
elif [ "${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}" = "daily" ]
2011-09-28 05:09:05 +00:00
then
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="sid"
2020-02-11 16:36:54 -01:00
URL="${DAILY_DI_URL}"
2011-09-28 05:09:05 +00:00
else
2020-04-01 09:58:47 +00:00
URL="${LB_PARENT_MIRROR_DEBIAN_INSTALLER}/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/installer-${LB_ARCHITECTURE}/current/images"
2011-09-28 05:09:05 +00:00
fi
esac
2007-09-23 08:05:14 +00:00
2007-09-23 08:05:12 +00:00
mkdir -p "${DESTDIR_DI}"
2015-01-04 16:58:35 -01:00
# Downloading debian-installer
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
2015-01-04 16:58:35 -01:00
# Downloading graphical-installer
2020-02-25 02:53:19 -01:00
DOWNLOAD_GTK_INSTALLER=false
2015-01-04 16:58:35 -01:00
if [ "${LB_DEBIAN_INSTALLER_GUI}" = "true" ]
then
2020-04-01 09:58:47 +00:00
case "${LB_ARCHITECTURE}" in
2024-03-05 14:57:25 -01:00
amd64|i386|arm64)
2020-02-25 02:53:19 -01:00
DOWNLOAD_GTK_INSTALLER=true
2015-01-04 16:58:35 -01:00
;;
2009-09-02 05:39:13 +00:00
2015-01-04 16:58:35 -01:00
powerpc)
if [ "${LB_DEBIAN_INSTALLER}" = "netboot" ]
then
2020-02-25 02:53:19 -01:00
DOWNLOAD_GTK_INSTALLER=true
2015-01-04 16:58:35 -01:00
fi
;;
esac
fi
2008-07-04 21:28:20 +00:00
2020-02-25 02:53:19 -01:00
if $DOWNLOAD_GTK_INSTALLER; then
2015-01-04 16:58:35 -01:00
mkdir -p "${DESTDIR_GI}"
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-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
2012-04-26 18:29:37 +00:00
2020-04-01 09:58:47 +00:00
case "${LB_ARCHITECTURE}" in
2007-09-23 08:05:13 +00:00
amd64)
2024-06-20 20:36:30 +00:00
DI_REQ_PACKAGES="grub-pc grub-common libfuse3-3" # BIOS
# Starting in trixie, the t64-packages have a 64-bit timestamp
if [ $(Check_package_available "libefiboot1t64") -eq 1 ]
then
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} libefiboot1t64"
else
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} libefiboot1"
fi
if [ $(Check_package_available "libefivar1t64") -eq 1 ]
then
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} libefivar1t64"
else
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} libefivar1"
fi
if [ $(Check_package_available "libfuse2t64") -eq 1 ]
then
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} libfuse2t64"
else
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} libfuse2"
fi
2023-01-14 18:13:32 -01:00
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} grub-efi-amd64 efibootmgr grub-efi-amd64-signed shim-signed" # UEFI (required for d-i, includes suggested packages)
2024-08-28 20:43:06 +00:00
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} efibootmgr grub-efi grub-efi-amd64 grub-efi-amd64-bin grub-efi-amd64-signed grub2-common mokutil shim-helpers-amd64-signed shim-signed shim-signed-common shim-unsigned cryptsetup cryptsetup-initramfs keyutils" # UEFI (required by Calamares)
# grub-efi-amd64-unsigned was introduced in trixie
if [ $(Check_package_available "grub-efi-amd64-unsigned") -eq 1 ]
then
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} grub-efi-amd64-unsigned"
fi
2020-03-15 21:18:01 -01:00
DI_PACKAGES="linux-image-amd64"
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)
2021-01-24 20:00:09 -01:00
DI_REQ_PACKAGES="grub-pc"
2020-03-15 21:18:01 -01:00
DI_PACKAGES="linux-image-686-pae"
2007-09-23 08:05:13 +00:00
;;
2007-09-23 08:04:52 +00:00
2024-03-08 18:06:53 -01:00
arm64)
DI_REQ_PACKAGES="grub-efi-arm64 efibootmgr grub-efi-arm64-signed shim-signed" # UEFI (required for d-i, includes suggested packages)
2024-11-30 19:27:45 -01:00
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} grub-efi grub-efi-arm64-bin grub2-common mokutil shim-helpers-arm64-signed shim-signed-common shim-unsigned" # UEFI (required by Calamares)
# grub-efi-arm64-unsigned was introduced in trixie
if [ $(Check_package_available "grub-efi-arm64-unsigned") -eq 1 ]
then
DI_REQ_PACKAGES="${DI_REQ_PACKAGES} grub-efi-arm64-unsigned"
fi
2024-03-08 18:06:53 -01:00
DI_PACKAGES="linux-image-arm64"
;;
2007-09-23 08:05:13 +00:00
powerpc)
2008-08-11 00:13:45 +00:00
DI_REQ_PACKAGES="yaboot"
2020-03-15 21:18:01 -01:00
DI_PACKAGES="linux-image-powerpc linux-image-powerpc64 linux-image-powerpc-smp"
2007-09-23 08:05:13 +00:00
;;
esac
2013-08-26 16:57:48 +00:00
DI_PACKAGES="${DI_PACKAGES} busybox cryptsetup mdadm lvm2 xfsprogs jfsutils"
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"
2010-09-20 19:49:27 +00:00
;;
esac
2020-02-11 16:44:31 -01:00
2020-03-15 20:45:14 -01:00
Echo_debug "DI_REQ_PACKAGES: %s" "${DI_REQ_PACKAGES}"
Echo_debug "DI_PACKAGES: %s" "${DI_PACKAGES}"
2024-05-26 20:32:54 +00:00
# The file is generated by Firmware_List_From_Contents, ensure a fresh copy
FIRMWARE_DETAILS_FILE="installer_firmware_details.txt"
rm -f ${FIRMWARE_DETAILS_FILE}
2012-04-26 17:52:15 +00:00
# Include firmware packages
if [ "${LB_FIRMWARE_BINARY}" = "true" ]
then
# Get all firmware packages names
2012-06-04 08:41:57 +00:00
mkdir -p cache/contents.binary
FIRMWARE_PACKAGES=""
2012-04-26 17:52:15 +00:00
2023-03-14 18:28:00 -01:00
# Manually add firmware-linux meta package if available
2024-06-20 20:36:30 +00:00
if [ $(Check_package_available "firmware-linux") -eq 1 ]
2023-03-14 18:28:00 -01:00
then
2024-06-20 20:36:30 +00:00
FIRMWARE_PACKAGES="${FIRMWARE_PACKAGES} firmware-linux"
2012-11-22 15:07:35 -01:00
fi
2020-02-11 17:08:43 -01:00
Firmware_List_From_Contents "${LB_PARENT_MIRROR_CHROOT}" "${LB_PARENT_DISTRIBUTION_CHROOT}" "${LB_PARENT_ARCHIVE_AREAS}"
2012-11-02 09:50:44 -01:00
if [ "${LB_DERIVATIVE}" = "true" ]
2012-04-26 17:52:15 +00:00
then
2020-02-11 20:00:14 -01:00
# Avoid downloading things twice if distributions are identical
DERIVATIVE_ARCHIVE_AREAS=""
if [ "${LB_DISTRIBUTION_CHROOT}" != "${LB_PARENT_DISTRIBUTION_CHROOT}" ]
then
DERIVATIVE_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS}"
else
for _ARCHIVE_AREA in ${LB_ARCHIVE_AREAS}
do
2020-04-01 09:04:19 +00:00
if ! In_list ${_ARCHIVE_AREA} ${LB_PARENT_ARCHIVE_AREAS}
2020-02-11 20:00:14 -01:00
then
DERIVATIVE_ARCHIVE_AREAS="${DERIVATIVE_ARCHIVE_AREAS} ${DERIVATIVE_ARCHIVE_AREAS}"
fi
done
fi
2012-06-04 08:41:57 +00:00
2020-02-11 20:00:14 -01:00
if [ ! -z "${DERIVATIVE_ARCHIVE_AREAS}" ]
then
Firmware_List_From_Contents "${LB_MIRROR_CHROOT}" "${LB_DISTRIBUTION_CHROOT}" "${DERIVATIVE_ARCHIVE_AREAS}"
fi
2012-04-26 17:52:15 +00:00
fi
# Drop section and keep package names only
for _PACKAGE in ${FIRMWARE_PACKAGES}
do
DI_FIRMWARE_PACKAGES="${DI_FIRMWARE_PACKAGES} $(echo ${_PACKAGE} | awk -F/ '{ print $NF }')"
done
2020-03-15 20:03:04 -01:00
FIRMWARE_PACKAGES=""
2012-04-26 17:52:15 +00:00
fi
2020-03-15 20:45:14 -01:00
Echo_debug "DI_FIRMWARE_PACKAGES: %s" "${DI_FIRMWARE_PACKAGES}"
2008-08-11 00:13:45 +00:00
# Set apt command prefix
2021-01-17 13:06:11 -01:00
_LB_APT_COMMAND="apt-get ${APT_OPTIONS} -o Dir::Cache=/binary.deb -o Dir::State::status=/dev/null -o APT::Install-Recommends=false -o Debug::NoLocking=true --download-only"
2008-08-11 00:13:45 +00:00
2023-01-14 18:13:32 -01:00
# Download .debs of the required packages
Chroot chroot ${_LB_APT_COMMAND} install ${DI_PACKAGES}
# The required packages or firmware packages might conflict, so download each individually
for _PACKAGE in ${DI_FIRMWARE_PACKAGES} ${DI_REQ_PACKAGES}
do
Chroot chroot ${_LB_APT_COMMAND} install ${_PACKAGE}
done
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.
#
2012-04-26 18:29:37 +00:00
# However, we need to force various packages' inclusion in binary/pool as
2008-08-11 00:13:45 +00:00
# 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
2020-03-15 20:22:53 -01:00
# Drop the packages already installed that d-i doesn't explicitly need
2013-01-20 06:53:43 -01:00
_REMAINING_PACKAGES="$(echo ${DI_FIRMWARE_PACKAGES} ${DI_REQ_PACKAGES} | sed -e 's# #|#g')"
2019-12-19 14:53:30 -01:00
_REMAINING_PACKAGES="$(Chroot_package_list chroot | grep -E -v "^(${_REMAINING_PACKAGES})\$")"
2013-01-20 06:53:43 -01:00
2020-03-15 20:45:14 -01:00
Echo_debug "'live' installer mode, dropping following unneeded debs: %s" "${_REMAINING_PACKAGES}"
2013-01-20 06:53:43 -01:00
for _PACKAGE in ${_REMAINING_PACKAGES}
do
2014-04-25 18:59:43 +00:00
rm -f chroot/binary.deb/archives/${_PACKAGE}_*.deb
2013-01-20 06:53:43 -01:00
done
2013-05-06 12:48:46 +00:00
fi
2013-01-20 06:53:43 -01:00
2007-09-23 08:05:13 +00:00
mv chroot/binary.deb ./
2008-04-17 08:42:34 +00:00
2020-03-15 20:22:53 -01:00
for _ARCHIVE_AREA in ${LB_PARENT_ARCHIVE_AREAS} ${LB_ARCHIVE_AREAS}; do
2012-04-26 22:20:40 +00:00
mkdir -p binary/pool/${_ARCHIVE_AREA}
done
2020-03-15 20:45:14 -01:00
Echo_debug "Installing binary debs"
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
2012-04-26 18:29:37 +00:00
Install_file "${FILE}" "binary/pool"
2008-01-15 18:47:50 -01:00
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
2012-06-04 08:52:28 +00:00
if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
2008-08-10 22:02:01 +00:00
then
2020-03-15 20:45:14 -01:00
Echo_debug "Installing bootstrap debs"
2012-06-04 08:52:28 +00:00
for FILE in cache/packages.bootstrap/*.deb
2008-08-10 22:02:01 +00:00
do
2012-04-26 18:29:37 +00:00
Install_file "${FILE}" "binary/pool"
2008-08-10 22:02:01 +00:00
done
else
2012-06-04 08:52:28 +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
2020-03-15 20:45:14 -01:00
Echo_debug "Including local debs"
2008-03-22 00:24:32 -01:00
# Including local debs
2020-04-01 09:58:47 +00:00
if Find_files config/packages.binary/*_"${LB_ARCHITECTURE}".deb || Find_files config/packages/*_"${LB_ARCHITECTURE}".deb
2008-03-22 00:24:32 -01:00
then
2020-04-01 09:58:47 +00:00
for FILE in config/packages.binary/*_"${LB_ARCHITECTURE}".deb config/packages/*_"${LB_ARCHITECTURE}".deb
2008-03-22 00:24:32 -01:00
do
2011-09-07 15:33:53 +00:00
if [ -e "${FILE}" ]
then
2012-04-26 18:29:37 +00:00
Install_file "${FILE}" "binary/pool"
2011-09-07 15:33:53 +00:00
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
2012-04-26 18:29:37 +00:00
Install_file "${FILE}" "binary/pool"
2011-09-07 15:33:53 +00:00
fi
2008-03-22 00:24:32 -01:00
done
fi
2007-09-23 08:05:13 +00:00
2024-11-24 14:17:15 -01:00
# The path to the package pool when running inside the live environment
case "${LB_INITRAMFS}" in
live-boot)
PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT="/run/live/medium"
;;
dracut-live)
PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT="/run/initramfs/live"
;;
*)
PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT=""
;;
esac
2008-03-22 00:24:32 -01:00
# Generating deb indices
2020-03-15 20:45:14 -01:00
Echo_debug "Generating deb indices"
2020-03-15 21:46:37 -01:00
for _ARCHIVE_AREA in $(cd binary/pool && ls); do
2020-04-01 09:58:47 +00:00
INDICE_DIR="dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/${_ARCHIVE_AREA}/binary-${LB_ARCHITECTURE}"
2020-03-15 21:46:37 -01:00
mkdir -p "binary/${INDICE_DIR}"
2007-09-23 08:04:52 +00:00
2012-04-26 19:43:57 +00:00
mv binary chroot/root
2020-03-15 21:37:15 -01:00
cat > chroot/binary.sh << EOF
#!/bin/sh
cd /root/binary
apt-ftparchive packages "pool/${_ARCHIVE_AREA}" > "${INDICE_DIR}/Packages"
EOF
2012-04-26 19:43:57 +00:00
Chroot chroot "sh binary.sh"
rm -f chroot/binary.sh
mv chroot/root/binary ./
2009-01-26 11:59:24 -01:00
2020-10-08 20:17:42 +00:00
touch "binary/${INDICE_DIR}/Packages" -d@${SOURCE_DATE_EPOCH}
2024-11-24 14:17:15 -01:00
if [ -n "${PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT}" ]
then
# Make the pool available without 'apt-get update'
VAR_LIB_APT_LISTS_FILENAME=$(echo "${PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT}/${INDICE_DIR}/Packages" | sed 's|/|_|g')
cp -a "binary/${INDICE_DIR}/Packages" "chroot/chroot/var/lib/apt/lists/${VAR_LIB_APT_LISTS_FILENAME}"
fi
2020-03-15 21:46:37 -01:00
gzip -9 -c "binary/${INDICE_DIR}/Packages" > "binary/${INDICE_DIR}/Packages.gz"
2007-09-23 08:05:12 +00:00
2012-04-26 19:43:57 +00:00
# Fetching release
2020-03-15 21:46:37 -01:00
Download_file "binary/${INDICE_DIR}/Release" "${LB_PARENT_MIRROR_CHROOT}/${INDICE_DIR}/Release"
2012-04-26 19:43:57 +00:00
done
2007-09-23 08:04:52 +00:00
2012-05-31 09:37:22 +00:00
# Symlink firmware packages to /firmware
2020-03-15 20:45:14 -01:00
Echo_debug "Symlinking firmware packages"
2012-05-31 09:37:22 +00:00
if [ -n "${DI_FIRMWARE_PACKAGES}" ]
then
mkdir -p binary/firmware
cd binary/firmware
for _PACKAGE in ${DI_FIRMWARE_PACKAGES}
do
for _FILE in $(find ../pool -name "${_PACKAGE}_*.deb")
do
2013-01-02 08:22:20 -01:00
ln -sf ${_FILE} ./
2024-05-26 20:32:54 +00:00
if [ -e ../../${FIRMWARE_DETAILS_FILE} ]
then
# Create Contents-firmware similar to tools/make-firmware-image from debian-cd
# This file is used by check-missing-firmware.sh from hw-detect
# Note: the second argument is replaced by the filename of the package
sed --silent -e "s/ [^ ]*\/${_PACKAGE}/ "$(basename ${_FILE})"/p" ../../${FIRMWARE_DETAILS_FILE} >> Contents-firmware
fi
2012-05-31 09:37:22 +00:00
done
done
cd "${OLDPWD}"
fi
2024-05-26 20:32:54 +00:00
# No longer needed
rm -f ${FIRMWARE_DETAILS_FILE}
2011-02-14 13:49:18 -01:00
# Udeb handling
2019-12-19 17:07:59 -01:00
mkdir -p binary.udeb/pool-udeb/main
2008-03-22 00:24:32 -01:00
cd binary.udeb
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Downloading udeb indices
2020-03-15 20:45:14 -01:00
Echo_debug "Downloading udeb indices"
2020-04-01 09:58:47 +00:00
Download_file Packages.gz "${LB_PARENT_MIRROR_CHROOT}"/dists/"${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LB_ARCHITECTURE}"/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
2020-04-01 09:58:47 +00:00
Download_file Packages.derivative.gz "${LB_MIRROR_CHROOT}"/dists/"${LB_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LB_ARCHITECTURE}"/Packages.gz
2011-02-14 13:49:18 -01:00
gunzip -c Packages.derivative.gz > Packages.derivative
fi
2020-03-15 20:45:14 -01:00
Echo_debug "Extracting udeb package list"
2020-02-13 03:43:46 -01:00
UDEBS="$(awk '/Filename: / { print $2 }' Packages)"
2020-02-13 03:55:14 -01:00
UDEBS_DERIVED=""
2020-02-13 03:43:46 -01:00
2020-02-20 07:37:49 -01:00
if [ "${LB_DERIVATIVE}" = "true" ]
2011-02-14 13:49:18 -01:00
then
2020-02-13 03:55:14 -01:00
UDEBS_DERIVED="$(awk '/Filename: / { print $2 }' Packages.derivative)"
2020-02-13 03:43:46 -01:00
2020-03-15 20:45:14 -01:00
Echo_debug "Derivative mode, filtering replaced packages from parent list"
Echo_debug "Parent (orig): %s" "${UDEBS}"
Echo_debug "Derived: %s" "${UDEBS_DERIVED}"
2020-02-13 03:43:46 -01:00
# Filter parent packages to exclude those replaced by derivative
# We need to compare package names from lists of paths and filenames that include versions
_UDEBS_FILTERED=""
_UDEBS_DERIVED_NAMES=""
2020-02-13 03:55:14 -01:00
for _UDEB in ${UDEBS_DERIVED}
2020-02-13 03:43:46 -01:00
do
_UDEBS_DERIVED_NAMES="${_UDEBS_DERIVED_NAMES} $(basename ${_UDEB} | awk -F_ '{ print $1 }')"
done
for _UDEB in ${UDEBS}
do
2020-04-01 09:04:19 +00:00
if ! In_list "$(basename ${_UDEB} | awk -F_ '{ print $1 }')" ${_UDEBS_DERIVED_NAMES}
2020-02-13 03:43:46 -01:00
then
_UDEBS_FILTERED="${_UDEBS_FILTERED} ${_UDEB}"
fi
done
2020-02-13 03:55:14 -01:00
UDEBS="${_UDEBS_FILTERED}"
2020-02-13 03:43:46 -01:00
_UDEBS_FILTERED=""
2020-02-13 03:55:14 -01:00
_UDEBS_DERIVED_NAMES=""
2020-03-15 20:45:14 -01:00
Echo_debug "Parent (filtered): %s" "${UDEBS}"
2020-02-13 03:43:46 -01:00
fi
2011-02-15 09:02:12 -01:00
2020-02-12 17:48:39 -01:00
# Downloading udeb packages
2012-02-04 13:54:37 -01:00
Echo_message "Downloading udebs..."
2020-03-15 21:46:37 -01:00
UDEB_CACHE_DIR="../cache/packages.installer_debian-installer.udeb"
2008-03-22 00:24:32 -01:00
for UDEB in ${UDEBS}
do
2020-02-13 02:26:53 -01:00
_UDEB_FILENAME="$(basename ${UDEB})"
2020-02-13 03:43:46 -01:00
# Copy from cache if available, otherwise download
2020-03-15 21:46:37 -01:00
if [ -f "${UDEB_CACHE_DIR}/${_UDEB_FILENAME}" ]; then
2020-03-15 20:45:14 -01:00
Echo_debug "Copying %s from cache" "${UDEB}"
2021-01-01 15:51:02 -01:00
cp -a "${UDEB_CACHE_DIR}/${_UDEB_FILENAME}" ./
2020-02-13 03:43:46 -01:00
else
2020-03-15 20:45:14 -01:00
Echo_debug "Downloading %s" "${UDEB}"
2020-02-13 03:55:14 -01:00
wget ${WGET_OPTIONS} "${LB_PARENT_MIRROR_CHROOT}/${UDEB}"
2008-03-22 00:24:32 -01:00
fi
done
2020-02-13 03:55:14 -01:00
if [ "${LB_DERIVATIVE}" = "true" ]
then
2020-03-15 20:45:14 -01:00
Echo_debug "Moving on to derivative set"
2020-02-13 03:55:14 -01:00
for UDEB in ${UDEBS_DERIVED}
do
_UDEB_FILENAME="$(basename ${UDEB})"
# Copy from cache if available, otherwise download
2020-03-15 21:46:37 -01:00
if [ -f "${UDEB_CACHE_DIR}/${_UDEB_FILENAME}" ]; then
2020-03-15 20:45:14 -01:00
Echo_debug "Copying %s from cache" "${UDEB}"
2021-01-01 15:51:02 -01:00
cp -a "${UDEB_CACHE_DIR}/${_UDEB_FILENAME}" ./
2020-02-13 03:55:14 -01:00
else
2020-03-15 20:45:14 -01:00
Echo_debug "Downloading %s" "${UDEB}"
2020-02-13 03:55:14 -01:00
wget ${WGET_OPTIONS} "${LB_MIRROR_CHROOT}/${UDEB}"
fi
done
fi
2008-03-22 00:24:32 -01:00
# Caching udebs
2020-03-15 20:45:14 -01:00
Echo_debug "Refreshing udeb cache"
2020-03-15 21:46:37 -01:00
rm -rf "${UDEB_CACHE_DIR}"
mkdir -p "${UDEB_CACHE_DIR}"
2021-01-01 15:51:02 -01:00
cp -a *.udeb "${UDEB_CACHE_DIR}"
2008-03-22 00:24:32 -01:00
2020-03-15 20:45:14 -01:00
Echo_debug "Including local udebs"
2008-03-22 00:24:32 -01:00
# Including local udebs
2020-04-01 09:58:47 +00:00
if Find_files ../config/packages.binary/*_"${LB_ARCHITECTURE}".udeb || Find_files ../config/packages/*_"${LB_ARCHITECTURE}".udeb
2007-09-23 08:05:13 +00:00
then
2020-04-01 09:58:47 +00:00
for FILE in ../config/packages.binary/*_"${LB_ARCHITECTURE}".udeb ../config/packages/*_"${LB_ARCHITECTURE}".udeb
2008-03-22 00:24:32 -01:00
do
2011-09-07 15:33:53 +00:00
if [ -e "${FILE}" ]
then
2019-12-19 17:07:59 -01:00
Install_file "${FILE}" "pool-udeb"
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
2019-12-19 17:07:59 -01:00
Install_file "${FILE}" "pool-udeb"
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
2020-03-15 20:45:14 -01:00
Echo_debug "Generating exclude list"
2008-03-22 00:24:32 -01:00
# Excluding udebs
2023-01-08 15:27:35 -01:00
# If the same file exists in multiple locations, take the version from the first
LOCATIONS="/usr/share/live/build/data/debian-cd"
if [ -n "${LIVE_BUILD}" ]
then
LOCATIONS="${LIVE_BUILD}/data/debian-cd ${LOCATIONS}"
fi
for LOCATION in ${LOCATIONS}
2012-07-19 17:37:26 +00:00
do
2023-01-08 15:27:35 -01:00
if [ -e "${LOCATION}/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}" ] && [ ! -e exclude ]
2012-07-19 17:37:26 +00:00
then
grep -v "^#" "${LOCATION}/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/udeb_exclude" > exclude || true
2020-02-10 14:48:49 -01:00
grep -v "^#" "${LOCATION}/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/exclude-udebs" >> exclude || true
2020-04-01 09:58:47 +00:00
grep -v "^#" "${LOCATION}/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/exclude-udebs-${LB_ARCHITECTURE}" >> exclude || true
2012-07-19 17:37:26 +00:00
fi
done
2007-09-23 08:05:12 +00:00
2008-03-22 00:24:32 -01:00
# Local exclude file
2012-10-22 18:30:41 +00:00
if [ -e ../config/debian-installer/udeb_exclude ]
2008-03-22 00:24:32 -01:00
then
2012-10-22 18:30:41 +00:00
cat ../config/debian-installer/udeb_exclude >> exclude
2008-03-22 00:24:32 -01:00
fi
2007-09-23 08:05:12 +00:00
2023-01-14 18:12:07 -01:00
if [ -e exclude ]
then
# 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
if [ "${LB_DEBIAN_INSTALLER}" = "live" ]; then
sed -i -e 's|live-installer||' exclude
fi
2009-06-30 14:45:36 +00:00
2023-01-14 18:12:07 -01:00
# Remove all udebs to be excluded from inclusion
Echo_debug "Removing excluded udebs"
while read EXCLUDE; do
rm -f ${EXCLUDE}_*.udeb
done < exclude
else
Echo_message "No udeb-exclusion list used"
fi
2007-09-23 08:05:12 +00:00
2020-02-12 17:48:39 -01:00
# Sort udebs into alphabetised pool structure
2020-03-15 20:45:14 -01:00
Echo_debug "Organising into pool structure"
2020-03-15 19:19:15 -01:00
for UDEB in ${UDEBS} ${UDEBS_DERIVED}; do
2020-02-13 03:43:46 -01:00
_UDEB_FILENAME="$(basename ${UDEB})"
2020-03-15 19:37:55 -01:00
if [ -f "${_UDEB_FILENAME}" ]; then
Install_file "${_UDEB_FILENAME}" "pool-udeb"
rm "${_UDEB_FILENAME}"
fi
2008-03-22 00:24:32 -01:00
done
2007-09-23 12:05:11 +00:00
2008-03-22 00:24:32 -01:00
# Creating udeb indices
2020-03-15 20:45:14 -01:00
Echo_debug "Generating udeb indices"
2020-04-01 09:58:47 +00:00
UDEB_INDICE_DIR="dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LB_ARCHITECTURE}"
2020-03-15 21:46:37 -01:00
mkdir -p "${UDEB_INDICE_DIR}"
2020-02-12 17:48:39 -01:00
2009-01-26 11:59:24 -01:00
cd "${OLDPWD}"
mv binary.udeb chroot/root
2020-03-15 21:37:15 -01:00
cat > chroot/binary.sh << EOF
#!/bin/sh
cd /root/binary.udeb
apt-ftparchive packages "pool-udeb/main" > "${UDEB_INDICE_DIR}/Packages"
EOF
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
2020-10-08 20:17:42 +00:00
touch "${UDEB_INDICE_DIR}/Packages" -d@${SOURCE_DATE_EPOCH}
2020-03-15 21:46:37 -01:00
gzip -9 -c "${UDEB_INDICE_DIR}/Packages" > "${UDEB_INDICE_DIR}/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
2020-03-15 20:45:14 -01:00
Echo_debug "Generating release file"
2009-01-26 11:59:24 -01:00
mv binary chroot/root
2015-08-10 19:31:17 +00:00
if [ -e chroot/etc/os-release ]
then
_VERSION="$(. chroot/etc/os-release && echo ${VERSION_ID})"
fi
2015-06-24 16:15:22 +00:00
if [ -n "${_VERSION}" ]; then
_LB_APT_VERSION_OPT='-o APT::FTPArchive::Release::Version="'"${_VERSION}"'"'
fi
2010-09-26 20:36:55 +00:00
2019-12-19 16:18:44 -01:00
case "${LB_PARENT_DISTRIBUTION_BINARY}" in
2010-09-26 21:00:52 +00:00
sid)
_SUITE="unstable"
;;
*)
2019-12-19 16:18:44 -01:00
_SUITE="${LB_PARENT_DISTRIBUTION_BINARY}"
2010-09-26 21:00:52 +00:00
;;
esac
2009-01-26 11:59:24 -01:00
cat > chroot/binary.sh << EOF
2020-02-22 13:36:58 -01:00
#!/bin/sh
2009-01-26 11:59:24 -01:00
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}" \
2015-06-24 16:15:22 +00:00
${_LB_APT_VERSION_OPT} \
2019-12-19 16:18:44 -01:00
-o APT::FTPArchive::Release::Codename="${LB_PARENT_DISTRIBUTION_BINARY}" \
2024-11-24 14:15:08 -01:00
-o APT::FTPArchive::Release::Date="$(date -R --utc -d@${SOURCE_DATE_EPOCH})" \
2020-04-01 09:58:47 +00:00
-o APT::FTPArchive::Release::Architectures="${LB_ARCHITECTURE}" \
2014-12-10 07:19:07 -01:00
-o APT::FTPArchive::Release::Components="${LB_PARENT_ARCHIVE_AREAS}" \
2024-11-24 14:15:08 -01:00
-o APT::FTPArchive::Release::Description="Last updated: $(date -R --utc -d@${SOURCE_DATE_EPOCH})" \
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
2024-11-24 14:17:15 -01:00
if [ -n "${PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT}" ]
then
# Add to sources.list with the path that is used inside the live environment
# Add in the first line, to give it precedence over the online versions of the same package
echo "deb [trusted=yes] file:${PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT} ${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" > sources.list
cat chroot/chroot/etc/apt/sources.list >> sources.list
cp sources.list chroot/chroot/etc/apt/sources.list
VAR_LIB_APT_LISTS_FILENAME=$(echo "${PATH_TO_POOL_INSIDE_LIVE_ENVIRONMENT}/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/Release" | sed 's|/|_|g')
cp -a binary/dists/${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}/Release chroot/chroot/var/lib/apt/lists/${VAR_LIB_APT_LISTS_FILENAME}
fi
2023-01-14 20:37:14 -01:00
2020-03-15 20:45:14 -01:00
Echo_debug "Creating distribution directories/symlinks"
2019-12-19 16:18:44 -01:00
DISTRIBUTIONS="stable testing unstable"
2010-11-13 13:45:36 -01:00
2019-12-19 16:18:44 -01:00
if [ "${LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION}" != "${LB_PARENT_DISTRIBUTION_BINARY}" ]
2010-11-13 13:45:36 -01:00
then
2019-12-19 16:18:44 -01:00
DISTRIBUTIONS="${DISTRIBUTIONS} ${LB_PARENT_DISTRIBUTION_BINARY}"
2010-11-13 13:45:36 -01:00
fi
2020-04-06 17:46:47 +00:00
case "${LB_IMAGE_TYPE}" in
2011-09-13 07:10:28 +00:00
hdd)
2010-11-13 13:45:36 -01:00
case "${LB_BINARY_FILESYSTEM}" in
2012-07-18 20:27:30 +00:00
fat*|ntfs)
2010-11-13 13:45:36 -01:00
# 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
2008-02-29 11:27:56 -01:00
fi
2008-04-17 08:42:34 +00:00
Repack_initrd()
{
2020-02-20 05:58:11 -01:00
local TARGET_INITRD="${1}"
local INCLUDE_PATH="${2}"
local REPACK_TMPDIR="unpacked-initrd"
2008-04-17 08:42:34 +00:00
2020-03-15 20:45:14 -01:00
Echo_debug "Repacking initrd \`%s\`" "${TARGET_INITRD}"
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
2020-02-20 05:58:11 -01:00
local _FILE
2013-06-20 09:21:32 +00:00
for _FILE in ../config/preseed/*.cfg ../config/preseed/*.cfg.installer
do
if [ -e "${_FILE}" ]
then
cp "${_FILE}" .
fi
done
2008-12-02 14:56:02 -01:00
else
# New way, include target directory content in the initrd
2020-02-20 05:58:11 -01:00
local REPACK_TMPDIR_ABS="${PWD}"
2008-12-02 14:56:02 -01:00
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}
}
2020-03-15 20:45:14 -01:00
Echo_debug "Repacking initrds where necessary"
2008-03-22 17:13:03 -01:00
# Preseed d-i by repacking the initrd in certain situations
2013-06-20 09:21:32 +00:00
if [ "${DI_IMAGE_TYPE}" = "netboot" ] && ( ls config/preseed/*.cfg > /dev/null 2>&1 || ls config/preseed/*.cfg.installer > /dev/null 2>&1 )
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
2013-06-24 12:27:48 +00:00
# Include content of config/includes.installer if exists and not empty
if [ -d config/includes.installer ] && [ -n "$(ls -A config/includes.installer)" ]
2008-12-02 14:56:02 -01:00
then
2013-06-24 12:27:48 +00:00
Repack_initrd "${DESTDIR}"/"${INITRD_DI}" config/includes.installer
2008-12-02 14:56:02 -01:00
if [ -e "${DESTDIR}"/"${INITRD_GI}" ]
then
2013-06-24 12:27:48 +00:00
Repack_initrd "${DESTDIR}"/"${INITRD_GI}" config/includes.installer
2008-12-02 14:56:02 -01:00
fi
fi
2008-04-16 05:19:10 +00:00
# Saving cache
2015-01-06 02:46:37 -01:00
Save_package_cache binary
2008-04-16 05:19:10 +00:00
# Removing depends
2020-05-05 15:45:57 +00:00
Remove_packages
2008-04-16 05:19:10 +00:00
2007-09-23 08:04:52 +00:00
# Creating stage file
2020-03-13 16:11:53 -01:00
Create_stagefile