413 lines
11 KiB
Bash
Executable File
413 lines
11 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# lh_binary_debian-installer(1) - install debian-installer into binary
|
|
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
|
|
#
|
|
# live-helper 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
|
|
LH_BASE="${LH_BASE:-/usr/share/live-helper}"
|
|
|
|
for FUNCTION in "${LH_BASE}"/functions/*.sh
|
|
do
|
|
. "${FUNCTION}"
|
|
done
|
|
|
|
# Setting static variables
|
|
DESCRIPTION="install debian-installer into binary"
|
|
HELP=""
|
|
USAGE="${PROGRAM} [--force]"
|
|
|
|
Arguments "${@}"
|
|
|
|
# Reading configuration files
|
|
Read_conffile config/common
|
|
Read_conffile config/bootstrap
|
|
Read_conffile config/chroot
|
|
Read_conffile config/binary
|
|
Read_conffile config/source
|
|
Set_defaults
|
|
|
|
# Setting remote d-i directories
|
|
case "${LIVE_DEBIAN_INSTALLER}" in
|
|
netinst)
|
|
DI="netboot/debian-installer/i386"
|
|
DI_GTK="netboot/gtk/debian-installer/i386"
|
|
DI_KERNEL="linux"
|
|
;;
|
|
|
|
cdrom|enabled)
|
|
DI="cdrom"
|
|
DI_GTK="${DI}/gtk"
|
|
DI_KERNEL="vmlinuz"
|
|
;;
|
|
|
|
disabled)
|
|
exit 0
|
|
;;
|
|
|
|
*)
|
|
Echo_error "debian-installer flavor ${LIVE_DEBIAN_INSTALLER} not supported."
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
Echo_message "Begin installing debian-installer..."
|
|
|
|
# Requiring stage file
|
|
Require_stagefile .stage/bootstrap
|
|
|
|
# Checking stage file
|
|
Check_stagefile .stage/binary_debian-installer
|
|
|
|
# Checking lock file
|
|
Check_lockfile .lock
|
|
|
|
# Creating lock file
|
|
Create_lockfile .lock
|
|
|
|
# Setting destination directory
|
|
case "${LIVE_BINARY_IMAGES}" in
|
|
iso)
|
|
DESTDIR="binary/install"
|
|
;;
|
|
|
|
net)
|
|
DESTDIR="tftpboot"
|
|
DI="netboot"
|
|
|
|
Echo_error "Not supported yet (FIXME)"
|
|
exit 1
|
|
;;
|
|
|
|
tar|usb-hdd)
|
|
DESTDIR="binary/install"
|
|
|
|
# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
|
|
if [ "${LIVE_DISTRIBUTION}" = "etch" ] && [ "${LIVE_BOOTLOADER}" = "syslinux" ]
|
|
then
|
|
DESTDIR="binary"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# Temporary check for broken syslinux
|
|
if [ "${LIVE_BINARY_IMAGES}" = "iso" ]
|
|
then
|
|
# Assemble multi-arch
|
|
if [ -n "${MULTIARCH}" ]
|
|
then
|
|
case "${LIVE_ARCHITECTURE}" in
|
|
amd64)
|
|
DESTDIR="${DESTDIR}.amd"
|
|
;;
|
|
|
|
i386)
|
|
DESTDIR="${DESTDIR}.386"
|
|
;;
|
|
|
|
powerpc)
|
|
DESTDIR="${DESTDIR}.ppc"
|
|
;;
|
|
esac
|
|
fi
|
|
fi
|
|
|
|
VMLINUZ_DI="vmlinuz"
|
|
INITRD_DI="initrd.gz"
|
|
DESTDIR_DI="${DESTDIR}"
|
|
|
|
VMLINUZ_GI="gtk/vmlinuz"
|
|
INITRD_GI="gtk/initrd.gz"
|
|
DESTDIR_GI="${DESTDIR}/gtk"
|
|
|
|
# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
|
|
if [ "${LIVE_DISTRIBUTION}" = "etch" ]
|
|
then
|
|
if [ "${LIVE_BINARY_IMAGES}" = "tar" ] || [ "${LIVE_BINARY_IMAGES}" = "usb-hdd" ]
|
|
then
|
|
VMLINUZ_DI="vmlinuz.di"
|
|
INITRD_DI="initrddi.gz"
|
|
DESTDIR_DI="${DESTDIR}"
|
|
|
|
VMLINUZ_GI="vmlinuz.gi"
|
|
INITRD_GI="initrdgi.gz"
|
|
DESTDIR_GI="${DESTDIR}"
|
|
fi
|
|
fi
|
|
|
|
# Downloading debian-installer
|
|
mkdir -p "${DESTDIR_DI}"
|
|
|
|
if [ "${LIVE_DISTRIBUTION}" = "sid" ] # FIXME arch
|
|
then
|
|
case "${LIVE_ARCHITECTURE}" in
|
|
amd64)
|
|
wget --no-clobber -O "${DESTDIR}"/"${VMLINUZ_DI}" http://people.debian.org/~aba/d-i/images/daily/${DI}/${DI_KERNEL}
|
|
wget --no-clobber -O "${DESTDIR}"/"${INITRD_DI}" http://people.debian.org/~aba/d-i/images/daily/${DI}/initrd.gz
|
|
;;
|
|
|
|
i386)
|
|
wget --no-clobber -O "${DESTDIR}"/"${VMLINUZ_DI}" http://people.debian.org/~joeyh/d-i/images/daily/${DI}/${DI_KERNEL}
|
|
wget --no-clobber -O "${DESTDIR}"/"${INITRD_DI}" http://people.debian.org/~joeyh/d-i/images/daily/${DI}/initrd.gz
|
|
;;
|
|
esac
|
|
else
|
|
wget --no-clobber -O "${DESTDIR}"/"${VMLINUZ_DI}" "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DI}"/"${DI_KERNEL}"
|
|
wget --no-clobber -O "${DESTDIR}"/"${INITRD_DI}" "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DI}"/initrd.gz
|
|
fi
|
|
|
|
# Downloading graphical-installer
|
|
if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] || [ "${LIVE_ARCHITECTURE}" = "powerpc" ]
|
|
then
|
|
mkdir -p "${DESTDIR_GI}"
|
|
|
|
if [ "${LIVE_DISTRIBUTION}" = "sid" ] # FIXME arch
|
|
then
|
|
case "${LIVE_ARCHITECTURE}" in
|
|
amd64)
|
|
wget --no-clobber -O "${DESTDIR}"/"${VMLINUZ_GI}" http://people.debian.org/~aba/d-i/images/daily/${DI_GTK}/${DI_KERNEL}
|
|
wget --no-clobber -O "${DESTDIR}"/"${INITRD_GI}" http://people.debian.org/~aba/d-i/images/daily/${DI_GTK}/initrd.gz
|
|
;;
|
|
|
|
i386)
|
|
wget --no-clobber -O "${DESTDIR}"/"${VMLINUZ_GI}" http://people.debian.org/~joeyh/d-i/images/daily/${DI_GTK}/${DI_KERNEL}
|
|
wget --no-clobber -O "${DESTDIR}"/"${INITRD_GI}" http://people.debian.org/~joeyh/d-i/images/daily/${DI_GTK}/initrd.gz
|
|
;;
|
|
esac
|
|
else
|
|
wget --no-clobber -O "${DESTDIR}"/"${VMLINUZ_GI}" "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DI_GTK}"/"${DI_KERNEL}"
|
|
wget --no-clobber -O "${DESTDIR}"/"${INITRD_GI}" "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DI_GTK}"/initrd.gz
|
|
fi
|
|
fi
|
|
|
|
if [ "${LIVE_DEBIAN_INSTALLER}" != "netinst" ]; then
|
|
# Downloading additional packages
|
|
mkdir -p chroot/binary.deb/archives/partial
|
|
mv chroot/var/lib/dpkg/status chroot/var/lib/dpkg/status.tmp
|
|
touch chroot/var/lib/dpkg/status
|
|
|
|
case "${LIVE_ARCHITECTURE}" in
|
|
amd64)
|
|
DI_PACKAGES="linux-image-2.6-amd64 lilo grub"
|
|
;;
|
|
|
|
i386)
|
|
DI_PACKAGES="linux-image-2.6-486 linux-image-2.6-686 elilo lilo grub"
|
|
;;
|
|
|
|
powerpc)
|
|
DI_PACKAGES="linux-image-2.6-powerpc linux-image-2.6-powerpc64 linux-image-2.6-powerpc-smp linux-image-2.6-prep yaboot" # FIXME bootloader?
|
|
;;
|
|
esac
|
|
|
|
DI_PACKAGES="${DI_PACKAGES} cryptsetup lvm2"
|
|
|
|
Chroot "apt-get -o Dir::Cache=/binary.deb --download-only install --yes ${DI_PACKAGES}"
|
|
mv chroot/binary.deb ./
|
|
mv chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
|
|
fi
|
|
|
|
# Including base debian packages
|
|
if [ -d cache/packages_bootstrap ]
|
|
then
|
|
for FILE in cache/packages_bootstrap/*.deb binary.deb/archives/*.deb
|
|
do
|
|
SOURCE="`dpkg -f ${FILE} Source | awk '{ print $1 }'`"
|
|
|
|
if [ -z "${SOURCE}" ]
|
|
then
|
|
SOURCE="`basename ${FILE} | awk -F_ '{ print $1 }'`"
|
|
fi
|
|
|
|
case "${SOURCE}" in
|
|
lib?*)
|
|
LETTER="`echo ${SOURCE} | sed 's/\(....\).*/\1/'`"
|
|
;;
|
|
|
|
*)
|
|
LETTER="`echo ${SOURCE} | sed 's/\(.\).*/\1/'`"
|
|
;;
|
|
esac
|
|
|
|
# Install directory
|
|
mkdir -p binary/pool/main/"${LETTER}"/"${SOURCE}"
|
|
|
|
# Move files
|
|
cp "${FILE}" binary/pool/main/"${LETTER}"/"${SOURCE}"
|
|
done
|
|
fi
|
|
|
|
# Including local debs
|
|
if ls ../config/binary_local-debs/* &> /dev/null
|
|
then
|
|
for FILE in ../config/binary_local-debs/*.deb
|
|
do
|
|
SOURCE="`dpkg -f ${FILE} Source | awk '{ print $1 }'`"
|
|
|
|
if [ -z "${SOURCE}" ]
|
|
then
|
|
SOURCE="`basename ${FILE} | awk -F_ '{ print $1 }'`"
|
|
fi
|
|
|
|
case "${SOURCE}" in
|
|
lib?*)
|
|
LETTER="`echo ${SOURCE} | sed 's/\(....\).*/\1/'`"
|
|
;;
|
|
|
|
*)
|
|
LETTER="`echo ${SOURCE} | sed 's/\(.\).*/\1/'`"
|
|
;;
|
|
esac
|
|
|
|
# Install directory
|
|
mkdir -p binary/pool/main/"${LETTER}"/"${SOURCE}"
|
|
|
|
# Move files
|
|
cp "${FILE}" binary/pool/main/"${LETTER}"/"${SOURCE}"
|
|
done
|
|
fi
|
|
|
|
# Generating deb indices
|
|
mkdir -p binary/dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}
|
|
|
|
cd binary
|
|
apt-ftparchive packages pool/main > dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}/Packages
|
|
gzip -9 -c dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}/Packages > dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}/Packages.gz
|
|
#apt-ftparchive sources pool/main > dists/${LIVE_DISTRIBUTION}/main/source/Sources
|
|
#gzip -9 -c dists/${LIVE_DISTRIBUTION}/main/source/Sources > dists/${LIVE_DISTRIBUTION}/main/source/Sources
|
|
cd "${OLDPWD}"
|
|
|
|
# Fetching release
|
|
wget "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/binary-"${LIVE_ARCHITECTURE}"/Release -O binary/dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}/Release
|
|
|
|
#cat > binary/dists/${LIVE_DISTRIBUTION}/main/source/Release << EOF
|
|
#Archive: stable
|
|
#Version: 4.0r0
|
|
#Component: main
|
|
#Origin: Debian
|
|
#Label: Debian
|
|
#Architecture: source
|
|
#EOF
|
|
|
|
mkdir binary.udeb
|
|
cd binary.udeb
|
|
|
|
# Downloading udeb indices
|
|
wget "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/debian-installer/binary-"${LIVE_ARCHITECTURE}"/Packages.gz
|
|
gunzip -c Packages.gz > Packages
|
|
|
|
# Sorting udebs
|
|
UDEBS="`awk '/Filename: / { print $2 }' Packages`"
|
|
|
|
# Downloading udebs
|
|
for UDEB in ${UDEBS}
|
|
do
|
|
if [ -f ../cache/packages_debian-installer.udeb/"`basename ${UDEB}`" ]
|
|
then
|
|
# Copying cached udebs
|
|
cp -l ../cache/packages_debian-installer.udeb/"`basename ${UDEB}`" ./
|
|
else
|
|
# Downloading udebs
|
|
wget "${LIVE_MIRROR_BOOTSTRAP}"/${UDEB}
|
|
fi
|
|
done
|
|
|
|
# Caching udebs
|
|
rm -rf ../cache/packages_debian-installer.udeb
|
|
mkdir -p ../cache/packages_debian-installer.udeb
|
|
cp -l *.udeb ../cache/packages_debian-installer.udeb
|
|
|
|
# Including local udebs
|
|
if ls ../config/binary_local-udebs/* &> /dev/null
|
|
then
|
|
for FILE in ../config/binary_local-udebs/*.udeb
|
|
do
|
|
SOURCE="`dpkg -f ${FILE} Source | awk '{ print $1 }'`"
|
|
|
|
if [ -z "${SOURCE}" ]
|
|
then
|
|
SOURCE="`basename ${FILE} | awk -F_ '{ print $1 }'`"
|
|
fi
|
|
|
|
case "${SOURCE}" in
|
|
lib?*)
|
|
LETTER="`echo ${SOURCE} | sed 's/\(....\).*/\1/'`"
|
|
;;
|
|
|
|
*)
|
|
LETTER="`echo ${SOURCE} | sed 's/\(.\).*/\1/'`"
|
|
;;
|
|
esac
|
|
|
|
# Install directory
|
|
mkdir -p pool/main/"${LETTER}"/"${SOURCE}"
|
|
|
|
# Copy files
|
|
cp "${FILE}" pool/main/"${LETTER}"/"${SOURCE}"
|
|
|
|
# Prefere local udebs over downloaded udebs
|
|
rm -f "`basename ${FILE} | awk -F_ '{ print $1 }'`"_*.udeb
|
|
done
|
|
fi
|
|
|
|
# Excluding udebs
|
|
grep -v "^#" ${LH_BASE:-/usr/share/live-helper}/data/debian-cd/"${LIVE_DISTRIBUTION}"/udeb_exclude > exclude
|
|
grep -v "^#" ${LH_BASE:-/usr/share/live-helper}/data/debian-cd/"${LIVE_DISTRIBUTION}"/exclude-udebs > exclude
|
|
grep -v "^#" ${LH_BASE:-/usr/share/live-helper}/data/debian-cd/"${LIVE_DISTRIBUTION}"/exclude-udebs-${LIVE_ARCHITECTURE} >> exclude
|
|
|
|
for EXCLUDE in `cat exclude`
|
|
do
|
|
rm -f "${EXCLUDE}"_*.udeb
|
|
done
|
|
|
|
# Moving udebs
|
|
for UDEB in ${UDEBS}
|
|
do
|
|
if [ -f "`basename ${UDEB}`" ]
|
|
then
|
|
mkdir -p `dirname ${UDEB}`
|
|
mv "`basename ${UDEB}`" "`dirname ${UDEB}`"
|
|
fi
|
|
done
|
|
|
|
# Creating udeb indices
|
|
mkdir -p dists/"${LIVE_DISTRIBUTION}"/main/debian-installer/binary-"${LIVE_ARCHITECTURE}"
|
|
apt-ftparchive packages pool/main > dists/"${LIVE_DISTRIBUTION}"/main/debian-installer/binary-"${LIVE_ARCHITECTURE}"/Packages
|
|
gzip -9 -c dists/${LIVE_DISTRIBUTION}/main/debian-installer/binary-${LIVE_ARCHITECTURE}/Packages > dists/${LIVE_DISTRIBUTION}/main/debian-installer/binary-${LIVE_ARCHITECTURE}/Packages.gz
|
|
|
|
rm -f Packages* exclude
|
|
find . | cpio -dmpu "${OLDPWD}"/binary
|
|
cd "${OLDPWD}"
|
|
|
|
rm -rf binary.udeb
|
|
rm -rf binary.deb
|
|
|
|
# Generating release file
|
|
apt-ftparchive \
|
|
-o APT::FTPArchive::Release::Origin="Debian" \
|
|
-o APT::FTPArchive::Release::Label="Debian" \
|
|
-o APT::FTPArchive::Release::Suite="${LIVE_DISTRIBUTION}" \
|
|
-o APT::FTPArchive::Release::Version="4.0" \
|
|
-o APT::FTPArchive::Release::Codename="${LIVE_DISTRIBUTION}" \
|
|
-o APT::FTPArchive::Release::Date="`date -R`" \
|
|
-o APT::FTPArchive::Release::Architectures="${LIVE_ARCHITECTURE}" \
|
|
-o APT::FTPArchive::Release::Components="main" \
|
|
-o APT::FTPArchive::Release::Description="Last updated: `date -R`" \
|
|
release binary/dists/${LIVE_DISTRIBUTION} > binary/dists/${LIVE_DISTRIBUTION}/Release
|
|
|
|
# Creating dist symlinks
|
|
for DISTRIBUTION in frozen stable testing unstable
|
|
do
|
|
ln -s ${LIVE_DISTRIBUTION} binary/dists/${DISTRIBUTION}
|
|
done
|
|
|
|
ln -s . binary/debian
|
|
|
|
# Creating stage file
|
|
Create_stagefile .stage/binary_debian-installer
|