2007-09-23 08:04:46 +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:46 +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:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Setting static variables
|
2015-02-05 02:30:47 -01:00
|
|
|
DESCRIPTION="Execute hacks in chroot"
|
2007-09-23 08:04:48 +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:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
Echo_message "Begin executing hacks..."
|
2007-09-23 08:04:49 +00:00
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Requiring stage file
|
2020-03-15 12:05:44 -01:00
|
|
|
Require_stagefiles config bootstrap
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
# Checking stage file
|
2020-03-13 16:11:53 -01:00
|
|
|
Check_stagefile
|
2007-09-23 08:04:46 +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:46 +00:00
|
|
|
|
2020-04-06 17:46:47 +00:00
|
|
|
case "${LB_IMAGE_TYPE}" in
|
2012-07-18 17:11:55 +00:00
|
|
|
netboot)
|
2012-06-27 12:34:10 +00:00
|
|
|
if [ ! -f chroot/sbin/mount.cifs ]
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
2012-06-27 12:34:10 +00:00
|
|
|
Apt chroot install cifs-utils
|
2007-09-23 08:04:48 +00:00
|
|
|
fi
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:04:47 +00:00
|
|
|
if [ ! -d chroot/etc/initramfs-tools ]
|
2007-09-23 08:04:46 +00:00
|
|
|
then
|
2007-09-23 08:04:47 +00:00
|
|
|
mkdir chroot/etc/initramfs-tools
|
2007-09-23 08:04:46 +00:00
|
|
|
fi
|
2012-04-05 08:24:40 +00:00
|
|
|
|
|
|
|
# Configuring initramfs for NFS
|
|
|
|
if ! grep -qs "BOOT=nfs" chroot/etc/initramfs-tools/initramfs.conf
|
|
|
|
then
|
|
|
|
echo "BOOT=nfs" >> chroot/etc/initramfs-tools/initramfs.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -qs "NFSROOT=auto" chroot/etc/initramfs-tools/initramfs.conf
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
2012-04-05 08:24:40 +00:00
|
|
|
echo "NFSROOT=auto" >> chroot/etc/initramfs-tools/initramfs.conf
|
2007-09-23 08:04:48 +00:00
|
|
|
fi
|
2022-01-25 09:02:05 -01:00
|
|
|
# initrd.img must be regenerated with the settings above
|
|
|
|
rm -f chroot/initrd.img_has_already_been_regenerated
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2009-05-18 15:01:43 +00:00
|
|
|
# Update initramfs (always, because of udev rules in initrd)
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_INITRAMFS}" in
|
2011-01-02 08:32:58 -01:00
|
|
|
live-boot)
|
2024-06-25 09:35:35 +00:00
|
|
|
if [ ! -e chroot/initrd.img_has_already_been_regenerated ]; then
|
|
|
|
Chroot chroot "${UPDATE_INITRAMFS_OPTIONS} update-initramfs -k all -t -u"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
dracut-live)
|
|
|
|
# Enable the live module (with a unique name)
|
|
|
|
echo "add_dracutmodules+=\" dmsquash-live \"" > chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf
|
|
|
|
# This ensures that dracut uses the same filename as initramfs-tools
|
|
|
|
Chroot chroot dpkg-reconfigure dracut
|
|
|
|
rm -f chroot/etc/dracut.conf.d/20-live-module-${SOURCE_DATE_EPOCH}.conf
|
2010-09-04 10:52:01 +00:00
|
|
|
;;
|
2010-05-21 05:19:15 +00:00
|
|
|
esac
|
2024-06-25 09:35:35 +00:00
|
|
|
rm -f chroot/vmlinuz.old
|
|
|
|
rm -f chroot/initrd.img.old
|
2022-01-25 09:02:05 -01:00
|
|
|
rm -f chroot/initrd.img_has_already_been_regenerated
|
2009-05-18 15:01:43 +00:00
|
|
|
|
2011-06-13 18:38:44 +00:00
|
|
|
# We probably ought to use COMPRESS= in a temporary file in
|
|
|
|
# /etc/initramfs-tools/conf.d/ instead, but it's hard to pass options that
|
|
|
|
# way.
|
|
|
|
case "${LB_INITRAMFS_COMPRESSION}" in
|
|
|
|
gzip)
|
|
|
|
;;
|
|
|
|
|
|
|
|
bzip2)
|
|
|
|
for INITRAMFS in $(find chroot/boot -name 'initrd*'); do
|
|
|
|
zcat "${INITRAMFS}" | bzip2 -c ${BZIP2_OPTIONS} > "${INITRAMFS}.new"
|
|
|
|
mv "${INITRAMFS}.new" "${INITRAMFS}"
|
2014-04-25 19:28:12 +00:00
|
|
|
echo "$(sha1sum ${INITRAMFS} | awk '{ print $1 }') /boot/$(basename ${INITRAMFS})" > chroot/var/lib/initramfs-tools/$(basename ${INITRAMFS} | sed -e 's|initrd.img-||')
|
2011-06-13 18:38:44 +00:00
|
|
|
done
|
|
|
|
;;
|
|
|
|
|
|
|
|
lzma)
|
|
|
|
for INITRAMFS in $(find chroot/boot -name 'initrd*'); do
|
|
|
|
zcat "${INITRAMFS}" | lzma -c ${LZMA_OPTIONS} > "${INITRAMFS}.new"
|
|
|
|
mv "${INITRAMFS}.new" "${INITRAMFS}"
|
2014-04-25 19:28:12 +00:00
|
|
|
echo "$(sha1sum ${INITRAMFS} | awk '{ print $1 }') /boot/$(basename ${INITRAMFS})" > chroot/var/lib/initramfs-tools/$(basename ${INITRAMFS} | sed -e 's|initrd.img-||')
|
2011-06-13 18:38:44 +00:00
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-04-27 10:30:02 +00:00
|
|
|
rm -f chroot/etc/hosts
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_DEBIAN_INSTALLER}" = "live" ]
|
2008-03-01 12:43:47 -01:00
|
|
|
then
|
2009-01-26 12:04:48 -01:00
|
|
|
# This is a temporary hack to get rid of fstab;
|
2010-09-26 10:38:38 +00:00
|
|
|
# needs cleanup in live-boot first to proper fix.
|
2008-03-01 12:43:47 -01:00
|
|
|
rm -f chroot/etc/fstab
|
2012-04-06 10:10:04 +00:00
|
|
|
touch chroot/etc/fstab
|
2008-03-01 12:43:47 -01:00
|
|
|
fi
|
|
|
|
|
2011-06-08 10:30:29 +00:00
|
|
|
if [ "${LB_SWAP_FILE_PATH}" ]; then
|
|
|
|
dd if=/dev/zero of="chroot/${LB_SWAP_FILE_PATH}" bs=1024k count="${LB_SWAP_FILE_SIZE}"
|
|
|
|
mkswap "chroot/${LB_SWAP_FILE_PATH}"
|
|
|
|
fi
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Creating stage file
|
2020-03-13 16:11:53 -01:00
|
|
|
Create_stagefile
|