From 50794b1de1b0211ee4c040a83bba9a5f3148d066 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 20 May 2015 08:19:39 +0200 Subject: Splitting non-live specific hooks into their own subdirectory within hooks. --- scripts/build/binary_hooks | 35 +++++++++++----------- scripts/build/chroot_hooks | 21 +++++++------ scripts/build/config | 10 ++++++- scripts/build/source_hooks | 35 +++++++++++----------- .../live/0020-create-mtab-symlink.hook.chroot | 11 ------- .../hooks/live/0030-enable-cryptsetup.hook.chroot | 21 ------------- .../live/0040-create-locales-files.hook.chroot | 7 ----- .../0100-remove-adjtime-configuration.hook.chroot | 11 ------- .../live/0110-remove-backup-files.hook.chroot | 18 ----------- .../live/0120-remove-dbus-machine-id.hook.chroot | 9 ------ .../live/0130-remove-gnome-icon-cache.hook.chroot | 9 ------ share/hooks/live/0140-remove-log-files.hook.chroot | 9 ------ .../0150-remove-mdadm-configuration.hook.chroot | 7 ----- ...160-remove-openssh-server-host-keys.hook.chroot | 10 ------- share/hooks/live/0170-remove-python-py.hook.chroot | 9 ------ .../0180-remove-systemd-machine-id.hook.chroot | 13 -------- .../live/0190-remove-temporary-files.hook.chroot | 14 --------- .../live/0195-remove-ssl-cert-snakeoil.hook.chroot | 13 -------- ...200-remove-udev-persistent-cd-rules.hook.chroot | 13 -------- ...00-remove-udev-persistent-net-rules.hook.chroot | 16 ---------- .../live/0400-update-apt-file-cache.hook.chroot | 14 --------- .../live/0410-update-apt-xapian-index.hook.chroot | 14 --------- .../live/0420-update-glx-alternative.hook.chroot | 9 ------ .../live/0430-update-mlocate-database.hook.chroot | 14 --------- .../0440-update-nvidia-alternative.hook.chroot | 9 ------ share/hooks/live/0910-remove-apt-sources-lists | 8 ----- .../normal/0020-create-mtab-symlink.hook.chroot | 11 +++++++ .../normal/0030-enable-cryptsetup.hook.chroot | 21 +++++++++++++ .../normal/0040-create-locales-files.hook.chroot | 7 +++++ .../0100-remove-adjtime-configuration.hook.chroot | 11 +++++++ .../normal/0110-remove-backup-files.hook.chroot | 18 +++++++++++ .../normal/0120-remove-dbus-machine-id.hook.chroot | 9 ++++++ .../0130-remove-gnome-icon-cache.hook.chroot | 9 ++++++ .../hooks/normal/0140-remove-log-files.hook.chroot | 9 ++++++ .../0150-remove-mdadm-configuration.hook.chroot | 7 +++++ ...160-remove-openssh-server-host-keys.hook.chroot | 10 +++++++ .../hooks/normal/0170-remove-python-py.hook.chroot | 9 ++++++ .../0180-remove-systemd-machine-id.hook.chroot | 13 ++++++++ .../normal/0190-remove-temporary-files.hook.chroot | 14 +++++++++ .../0195-remove-ssl-cert-snakeoil.hook.chroot | 13 ++++++++ ...200-remove-udev-persistent-cd-rules.hook.chroot | 13 ++++++++ ...00-remove-udev-persistent-net-rules.hook.chroot | 16 ++++++++++ .../normal/0400-update-apt-file-cache.hook.chroot | 14 +++++++++ .../0410-update-apt-xapian-index.hook.chroot | 14 +++++++++ .../normal/0420-update-glx-alternative.hook.chroot | 9 ++++++ .../0430-update-mlocate-database.hook.chroot | 14 +++++++++ .../0440-update-nvidia-alternative.hook.chroot | 9 ++++++ share/hooks/normal/0910-remove-apt-sources-lists | 8 +++++ 48 files changed, 315 insertions(+), 302 deletions(-) delete mode 100755 share/hooks/live/0020-create-mtab-symlink.hook.chroot delete mode 100755 share/hooks/live/0030-enable-cryptsetup.hook.chroot delete mode 100755 share/hooks/live/0040-create-locales-files.hook.chroot delete mode 100755 share/hooks/live/0100-remove-adjtime-configuration.hook.chroot delete mode 100755 share/hooks/live/0110-remove-backup-files.hook.chroot delete mode 100755 share/hooks/live/0120-remove-dbus-machine-id.hook.chroot delete mode 100755 share/hooks/live/0130-remove-gnome-icon-cache.hook.chroot delete mode 100755 share/hooks/live/0140-remove-log-files.hook.chroot delete mode 100755 share/hooks/live/0150-remove-mdadm-configuration.hook.chroot delete mode 100755 share/hooks/live/0160-remove-openssh-server-host-keys.hook.chroot delete mode 100755 share/hooks/live/0170-remove-python-py.hook.chroot delete mode 100755 share/hooks/live/0180-remove-systemd-machine-id.hook.chroot delete mode 100755 share/hooks/live/0190-remove-temporary-files.hook.chroot delete mode 100755 share/hooks/live/0195-remove-ssl-cert-snakeoil.hook.chroot delete mode 100755 share/hooks/live/0200-remove-udev-persistent-cd-rules.hook.chroot delete mode 100755 share/hooks/live/0300-remove-udev-persistent-net-rules.hook.chroot delete mode 100755 share/hooks/live/0400-update-apt-file-cache.hook.chroot delete mode 100755 share/hooks/live/0410-update-apt-xapian-index.hook.chroot delete mode 100755 share/hooks/live/0420-update-glx-alternative.hook.chroot delete mode 100755 share/hooks/live/0430-update-mlocate-database.hook.chroot delete mode 100755 share/hooks/live/0440-update-nvidia-alternative.hook.chroot delete mode 100755 share/hooks/live/0910-remove-apt-sources-lists create mode 100755 share/hooks/normal/0020-create-mtab-symlink.hook.chroot create mode 100755 share/hooks/normal/0030-enable-cryptsetup.hook.chroot create mode 100755 share/hooks/normal/0040-create-locales-files.hook.chroot create mode 100755 share/hooks/normal/0100-remove-adjtime-configuration.hook.chroot create mode 100755 share/hooks/normal/0110-remove-backup-files.hook.chroot create mode 100755 share/hooks/normal/0120-remove-dbus-machine-id.hook.chroot create mode 100755 share/hooks/normal/0130-remove-gnome-icon-cache.hook.chroot create mode 100755 share/hooks/normal/0140-remove-log-files.hook.chroot create mode 100755 share/hooks/normal/0150-remove-mdadm-configuration.hook.chroot create mode 100755 share/hooks/normal/0160-remove-openssh-server-host-keys.hook.chroot create mode 100755 share/hooks/normal/0170-remove-python-py.hook.chroot create mode 100755 share/hooks/normal/0180-remove-systemd-machine-id.hook.chroot create mode 100755 share/hooks/normal/0190-remove-temporary-files.hook.chroot create mode 100755 share/hooks/normal/0195-remove-ssl-cert-snakeoil.hook.chroot create mode 100755 share/hooks/normal/0200-remove-udev-persistent-cd-rules.hook.chroot create mode 100755 share/hooks/normal/0300-remove-udev-persistent-net-rules.hook.chroot create mode 100755 share/hooks/normal/0400-update-apt-file-cache.hook.chroot create mode 100755 share/hooks/normal/0410-update-apt-xapian-index.hook.chroot create mode 100755 share/hooks/normal/0420-update-glx-alternative.hook.chroot create mode 100755 share/hooks/normal/0430-update-mlocate-database.hook.chroot create mode 100755 share/hooks/normal/0440-update-nvidia-alternative.hook.chroot create mode 100755 share/hooks/normal/0910-remove-apt-sources-lists diff --git a/scripts/build/binary_hooks b/scripts/build/binary_hooks index bdad671cc..b40139797 100755 --- a/scripts/build/binary_hooks +++ b/scripts/build/binary_hooks @@ -58,21 +58,22 @@ do done ## Processing local hooks +for HOOK in config/hooks/normal/*.binary config/hooks/live/*.binary +do + if [ ! -e "${HOOK}" ] + then + continue + fi + + # Making hook executable + if [ ! -x "${HOOK}" ] + then + chmod +x "${HOOK}" + fi + + # Executing hook + ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} +done -if Find_files config/hooks/live/*.binary -then - for HOOK in config/hooks/live/*.binary - do - # Making hook executable - if [ ! -x "${HOOK}" ] - then - chmod +x "${HOOK}" - fi - - # Executing hook - ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} - done - - # Creating stage file - Create_stagefile .build/binary_hooks -fi +# Creating stage file +Create_stagefile .build/binary_hooks diff --git a/scripts/build/chroot_hooks b/scripts/build/chroot_hooks index e25f3b7fd..26ffdd701 100755 --- a/scripts/build/chroot_hooks +++ b/scripts/build/chroot_hooks @@ -78,28 +78,32 @@ then fi ## Processing local hooks - -if Find_files config/hooks/live/*.chroot +if ls config/hooks/*.chroot > /dev/null 2>&1 then # Restoring cache Restore_cache cache/packages.chroot - for _HOOK in config/hooks/live/*.chroot + for HOOK in config/hooks/normal/*.binary config/hooks/live/*.binary do + if [ ! -e "${HOOK}" ] + then + continue + fi + # Copying hook - cp "${_HOOK}" chroot/root + cp "${HOOK}" chroot/root # Making hook executable - if [ ! -x chroot/root/"$(basename ${_HOOK})" ] + if [ ! -x chroot/root/"$(basename ${HOOK})" ] then - chmod +x chroot/root/"$(basename ${_HOOK})" + chmod +x chroot/root/"$(basename ${HOOK})" fi # Executing hook - Chroot chroot "/root/$(basename ${_HOOK})" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + Chroot chroot "/root/$(basename ${HOOK})" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} # Removing hook - rm -f chroot/root/"$(basename ${_HOOK})" + rm -f chroot/root/"$(basename ${HOOK})" done # Saving cache @@ -112,4 +116,3 @@ fi # Remove bind mount of build config inside chroot. umount chroot/live-build/config rmdir chroot/live-build/config - diff --git a/scripts/build/config b/scripts/build/config index 8e2109594..e6dcd4341 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -1312,11 +1312,19 @@ then rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true fi -mkdir -p config/hooks/live +mkdir -p config/hooks/normal config/hooks/live mkdir -p config/includes config/includes.bootstrap config/includes.chroot config/includes.binary config/includes.source Echo_message "Symlinking hooks..." +for _HOOK in "${LIVE_BUILD}"/share/hooks/normal/*.hook* /usr/share/normal/build/hooks/normal/*.hook* +do + if [ -e "${_HOOK}" ] && [ ! -e "config/hooks/normal/$(basename ${_HOOK})" ] + then + ln -s "${_HOOK}" "config/hooks/normal/$(basename ${_HOOK})" + fi +done + for _HOOK in "${LIVE_BUILD}"/share/hooks/live/*.hook* /usr/share/live/build/hooks/live/*.hook* do if [ -e "${_HOOK}" ] && [ ! -e "config/hooks/live/$(basename ${_HOOK})" ] diff --git a/scripts/build/source_hooks b/scripts/build/source_hooks index 6f3e08dcd..d3059de98 100755 --- a/scripts/build/source_hooks +++ b/scripts/build/source_hooks @@ -58,21 +58,22 @@ do done ## Processing local hooks +for HOOK in config/hooks/normal/*.source config/hooks/live/*.source +do + if [ ! -e "${HOOK}" ] + then + continue + fi + + # Making hook executable + if [ ! -x "${HOOK}" ] + then + chmod +x "${HOOK}" + fi + + # Executing hook + ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} +done -if Find_files config/hooks/live/*.source -then - for HOOK in config/hooks/live/*.source - do - # Making hook executable - if [ ! -x "${HOOK}" ] - then - chmod +x "${HOOK}" - fi - - # Executing hook - ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} - done - - # Creating stage file - Create_stagefile .build/source_hooks -fi +# Creating stage file +Create_stagefile .build/source_hooks diff --git a/share/hooks/live/0020-create-mtab-symlink.hook.chroot b/share/hooks/live/0020-create-mtab-symlink.hook.chroot deleted file mode 100755 index 5c2fa64ae..000000000 --- a/share/hooks/live/0020-create-mtab-symlink.hook.chroot +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e - -# Create /etc/mtab symlink, replacing a regular file if necessary - -if [ ! -L /etc/mtab ] -then - rm -f /etc/mtab - ln -s /proc/mounts /etc/mtab -fi diff --git a/share/hooks/live/0030-enable-cryptsetup.hook.chroot b/share/hooks/live/0030-enable-cryptsetup.hook.chroot deleted file mode 100755 index 54c2978d2..000000000 --- a/share/hooks/live/0030-enable-cryptsetup.hook.chroot +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -# Enable cryptsetup - -if [ -e /sbin/cryptsetup ] -then - if [ ! -e /etc/initramfs-tools/conf.d/cryptsetup ] - then - mkdir -p /etc/initramfs-tools/conf.d - -cat > /etc/initramfs-tools/conf.d/cryptsetup << EOF -# /etc/initramfs-tools/conf.d/cryptsetup - -CRYPTSETUP=yes -export CRYPTSETUP -EOF - - fi -fi diff --git a/share/hooks/live/0040-create-locales-files.hook.chroot b/share/hooks/live/0040-create-locales-files.hook.chroot deleted file mode 100755 index 8a5a8677c..000000000 --- a/share/hooks/live/0040-create-locales-files.hook.chroot +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -set -e - -# Create /etc/environment and /etc/default/locale -touch /etc/environment -touch /etc/default/locale diff --git a/share/hooks/live/0100-remove-adjtime-configuration.hook.chroot b/share/hooks/live/0100-remove-adjtime-configuration.hook.chroot deleted file mode 100755 index 7fe5bbd15..000000000 --- a/share/hooks/live/0100-remove-adjtime-configuration.hook.chroot +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e - -# Reset generated file - -cat > /etc/adjtime << EOF -0.0 0 0.0 -0 -UTC -EOF diff --git a/share/hooks/live/0110-remove-backup-files.hook.chroot b/share/hooks/live/0110-remove-backup-files.hook.chroot deleted file mode 100755 index 55a6b75af..000000000 --- a/share/hooks/live/0110-remove-backup-files.hook.chroot +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -# Remove backup files -rm -f /boot/*.bak -rm -f /boot/*.old-dkms - -rm -f /etc/apt/sources.list~ -rm -f /etc/apt/trusted.gpg~ - -rm -f /etc/passwd- -rm -f /etc/group- -rm -f /etc/shadow- -rm -f /etc/gshadow- - -rm -f /var/cache/debconf/*-old -rm -f /var/lib/dpkg/*-old diff --git a/share/hooks/live/0120-remove-dbus-machine-id.hook.chroot b/share/hooks/live/0120-remove-dbus-machine-id.hook.chroot deleted file mode 100755 index 230099e46..000000000 --- a/share/hooks/live/0120-remove-dbus-machine-id.hook.chroot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# Remove dbus machine id. -# -# This removes dbus machine id that cache that makes each system unique. - -rm -f /var/lib/dbus/machine-id diff --git a/share/hooks/live/0130-remove-gnome-icon-cache.hook.chroot b/share/hooks/live/0130-remove-gnome-icon-cache.hook.chroot deleted file mode 100755 index ab35a1d68..000000000 --- a/share/hooks/live/0130-remove-gnome-icon-cache.hook.chroot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# Remove GNOME icon cache. -# -# This saves space some space. - -rm -f /usr/share/icons/*/icon-theme.cache diff --git a/share/hooks/live/0140-remove-log-files.hook.chroot b/share/hooks/live/0140-remove-log-files.hook.chroot deleted file mode 100755 index f95e54686..000000000 --- a/share/hooks/live/0140-remove-log-files.hook.chroot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# Truncate log files -for _FILE in $(find /var/log/ -type f) -do - : > ${_FILE} -done diff --git a/share/hooks/live/0150-remove-mdadm-configuration.hook.chroot b/share/hooks/live/0150-remove-mdadm-configuration.hook.chroot deleted file mode 100755 index 206b494da..000000000 --- a/share/hooks/live/0150-remove-mdadm-configuration.hook.chroot +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -set -e - -# Remove generated files - -rm -f /etc/mdadm/mdadm.conf diff --git a/share/hooks/live/0160-remove-openssh-server-host-keys.hook.chroot b/share/hooks/live/0160-remove-openssh-server-host-keys.hook.chroot deleted file mode 100755 index 862704981..000000000 --- a/share/hooks/live/0160-remove-openssh-server-host-keys.hook.chroot +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -set -e - -# Remove OpenSSH Host Keys. -# -# This removes openssh-server host keys, they are regenerated by live-config -# on system start. - -rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub diff --git a/share/hooks/live/0170-remove-python-py.hook.chroot b/share/hooks/live/0170-remove-python-py.hook.chroot deleted file mode 100755 index ff705838f..000000000 --- a/share/hooks/live/0170-remove-python-py.hook.chroot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# Remove Python *.py files. -# -# This removes byte-compiled Python modules to save some space. - -find /usr -name "*.pyc" -print0 | xargs -0r rm -f diff --git a/share/hooks/live/0180-remove-systemd-machine-id.hook.chroot b/share/hooks/live/0180-remove-systemd-machine-id.hook.chroot deleted file mode 100755 index ed5d6bf6a..000000000 --- a/share/hooks/live/0180-remove-systemd-machine-id.hook.chroot +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -# Blank out systemd machine id. If it does not exist, systemd-journald -# will fail, but if it exists and is empty, systemd will automatically -# set up a new unique ID. - -if [ -e /etc/machine-id ] -then - rm -f /etc/machine-id - : > /etc/machine-id -fi diff --git a/share/hooks/live/0190-remove-temporary-files.hook.chroot b/share/hooks/live/0190-remove-temporary-files.hook.chroot deleted file mode 100755 index fd220e030..000000000 --- a/share/hooks/live/0190-remove-temporary-files.hook.chroot +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -# Remove temporary files -rm -rf /var/cache/man/* - -for _DIRECTORY in /tmp /var/tmp -do - rm -rf ${_DIRECTORY} - - mkdir -p ${_DIRECTORY} - chmod 1777 ${_DIRECTORY} -done diff --git a/share/hooks/live/0195-remove-ssl-cert-snakeoil.hook.chroot b/share/hooks/live/0195-remove-ssl-cert-snakeoil.hook.chroot deleted file mode 100755 index cdfe39d24..000000000 --- a/share/hooks/live/0195-remove-ssl-cert-snakeoil.hook.chroot +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -# Remove ssl-cert snakeoil - -if [ -e /etc/ssl/certs/ssl-cert-snakeoil.pem ] -then - rm -f /etc/ssl/certs/$(openssl x509 -hash -noout -in /etc/ssl/certs/ssl-cert-snakeoil.pem) - - rm -f /etc/ssl/certs/ssl-cert-snakeoil.pem - rm -f /etc/ssl/private/ssl-cert-snakeoil.key -fi diff --git a/share/hooks/live/0200-remove-udev-persistent-cd-rules.hook.chroot b/share/hooks/live/0200-remove-udev-persistent-cd-rules.hook.chroot deleted file mode 100755 index bdfe52d96..000000000 --- a/share/hooks/live/0200-remove-udev-persistent-cd-rules.hook.chroot +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -# Remove udev persistent rules. -# -# This removes udev persistent rules that cache the host systems cd drive as -# well as the running live systems cd drive to remember its device name. - -if [ -e /etc/udev/rules.d ] -then - > /etc/udev/rules.d/70-persistent-cd.rules -fi diff --git a/share/hooks/live/0300-remove-udev-persistent-net-rules.hook.chroot b/share/hooks/live/0300-remove-udev-persistent-net-rules.hook.chroot deleted file mode 100755 index 148ba30d1..000000000 --- a/share/hooks/live/0300-remove-udev-persistent-net-rules.hook.chroot +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -e - -# Remove udev persistent rules. -# -# This removes udev persistent rules that cache the host systems mac address to -# remember its device name. - -for _FILE in /etc/udev/rules.d/*persistent-net.rules -do - if [ -e "${_FILE}" ] - then - : > ${_FILE} - fi -done diff --git a/share/hooks/live/0400-update-apt-file-cache.hook.chroot b/share/hooks/live/0400-update-apt-file-cache.hook.chroot deleted file mode 100755 index 771e9032a..000000000 --- a/share/hooks/live/0400-update-apt-file-cache.hook.chroot +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -# Update the Apt File cache. -# -# This allows to use using apt-file out-of-the-box. - -. /live-build/config/binary - -if [ -x /usr/bin/apt-file ] && [ "${LB_APT_INDICES}" = "true" ] -then - apt-file update -fi diff --git a/share/hooks/live/0410-update-apt-xapian-index.hook.chroot b/share/hooks/live/0410-update-apt-xapian-index.hook.chroot deleted file mode 100755 index dcb39b261..000000000 --- a/share/hooks/live/0410-update-apt-xapian-index.hook.chroot +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -# Update the Apt Xapian index. -# -# The package would do this itself, but (a) it checks policy-rc.d which says it -# is not allowed to, and (b) it wants to build the index in the background which -# will be racy in the context of live-build. - -if [ -x /usr/sbin/update-apt-xapian-index ] -then - PYTHONDONTWRITEBYTECODE=1 /usr/sbin/update-apt-xapian-index --force --quiet -fi diff --git a/share/hooks/live/0420-update-glx-alternative.hook.chroot b/share/hooks/live/0420-update-glx-alternative.hook.chroot deleted file mode 100755 index 8c36c43f9..000000000 --- a/share/hooks/live/0420-update-glx-alternative.hook.chroot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# Use mesa renderer by default -if [ -e /etc/alternatives/glx ] -then - update-alternatives --quiet --set glx /usr/lib/mesa-diverted -fi diff --git a/share/hooks/live/0430-update-mlocate-database.hook.chroot b/share/hooks/live/0430-update-mlocate-database.hook.chroot deleted file mode 100755 index 6bfdb3d4f..000000000 --- a/share/hooks/live/0430-update-mlocate-database.hook.chroot +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -# Update the mlocate database. -# -# It is convenient for this to be already up to date on the live system, and it -# means that if the live system is later installed to a hard disk then less -# work will be required after installation. - -if [ -x /usr/bin/updatedb.mlocate ] -then - updatedb.mlocate -fi diff --git a/share/hooks/live/0440-update-nvidia-alternative.hook.chroot b/share/hooks/live/0440-update-nvidia-alternative.hook.chroot deleted file mode 100755 index e73b9678b..000000000 --- a/share/hooks/live/0440-update-nvidia-alternative.hook.chroot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# Use newest nvidia version by default -if [ -e /etc/alternatives/nvidia ] && [ -e /usr/lib/nvidia/current ] -then - update-alternatives --quiet --set nvidia /usr/lib/nvidia/current -fi diff --git a/share/hooks/live/0910-remove-apt-sources-lists b/share/hooks/live/0910-remove-apt-sources-lists deleted file mode 100755 index 1c8ca2d22..000000000 --- a/share/hooks/live/0910-remove-apt-sources-lists +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -set -e - -# Remove apt sources.list files - -rm -f /etc/apt/sources.list -rm -f /etc/apt/sources.list.d/*.list diff --git a/share/hooks/normal/0020-create-mtab-symlink.hook.chroot b/share/hooks/normal/0020-create-mtab-symlink.hook.chroot new file mode 100755 index 000000000..5c2fa64ae --- /dev/null +++ b/share/hooks/normal/0020-create-mtab-symlink.hook.chroot @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +# Create /etc/mtab symlink, replacing a regular file if necessary + +if [ ! -L /etc/mtab ] +then + rm -f /etc/mtab + ln -s /proc/mounts /etc/mtab +fi diff --git a/share/hooks/normal/0030-enable-cryptsetup.hook.chroot b/share/hooks/normal/0030-enable-cryptsetup.hook.chroot new file mode 100755 index 000000000..54c2978d2 --- /dev/null +++ b/share/hooks/normal/0030-enable-cryptsetup.hook.chroot @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +# Enable cryptsetup + +if [ -e /sbin/cryptsetup ] +then + if [ ! -e /etc/initramfs-tools/conf.d/cryptsetup ] + then + mkdir -p /etc/initramfs-tools/conf.d + +cat > /etc/initramfs-tools/conf.d/cryptsetup << EOF +# /etc/initramfs-tools/conf.d/cryptsetup + +CRYPTSETUP=yes +export CRYPTSETUP +EOF + + fi +fi diff --git a/share/hooks/normal/0040-create-locales-files.hook.chroot b/share/hooks/normal/0040-create-locales-files.hook.chroot new file mode 100755 index 000000000..8a5a8677c --- /dev/null +++ b/share/hooks/normal/0040-create-locales-files.hook.chroot @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +# Create /etc/environment and /etc/default/locale +touch /etc/environment +touch /etc/default/locale diff --git a/share/hooks/normal/0100-remove-adjtime-configuration.hook.chroot b/share/hooks/normal/0100-remove-adjtime-configuration.hook.chroot new file mode 100755 index 000000000..7fe5bbd15 --- /dev/null +++ b/share/hooks/normal/0100-remove-adjtime-configuration.hook.chroot @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +# Reset generated file + +cat > /etc/adjtime << EOF +0.0 0 0.0 +0 +UTC +EOF diff --git a/share/hooks/normal/0110-remove-backup-files.hook.chroot b/share/hooks/normal/0110-remove-backup-files.hook.chroot new file mode 100755 index 000000000..55a6b75af --- /dev/null +++ b/share/hooks/normal/0110-remove-backup-files.hook.chroot @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +# Remove backup files +rm -f /boot/*.bak +rm -f /boot/*.old-dkms + +rm -f /etc/apt/sources.list~ +rm -f /etc/apt/trusted.gpg~ + +rm -f /etc/passwd- +rm -f /etc/group- +rm -f /etc/shadow- +rm -f /etc/gshadow- + +rm -f /var/cache/debconf/*-old +rm -f /var/lib/dpkg/*-old diff --git a/share/hooks/normal/0120-remove-dbus-machine-id.hook.chroot b/share/hooks/normal/0120-remove-dbus-machine-id.hook.chroot new file mode 100755 index 000000000..230099e46 --- /dev/null +++ b/share/hooks/normal/0120-remove-dbus-machine-id.hook.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# Remove dbus machine id. +# +# This removes dbus machine id that cache that makes each system unique. + +rm -f /var/lib/dbus/machine-id diff --git a/share/hooks/normal/0130-remove-gnome-icon-cache.hook.chroot b/share/hooks/normal/0130-remove-gnome-icon-cache.hook.chroot new file mode 100755 index 000000000..ab35a1d68 --- /dev/null +++ b/share/hooks/normal/0130-remove-gnome-icon-cache.hook.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# Remove GNOME icon cache. +# +# This saves space some space. + +rm -f /usr/share/icons/*/icon-theme.cache diff --git a/share/hooks/normal/0140-remove-log-files.hook.chroot b/share/hooks/normal/0140-remove-log-files.hook.chroot new file mode 100755 index 000000000..f95e54686 --- /dev/null +++ b/share/hooks/normal/0140-remove-log-files.hook.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# Truncate log files +for _FILE in $(find /var/log/ -type f) +do + : > ${_FILE} +done diff --git a/share/hooks/normal/0150-remove-mdadm-configuration.hook.chroot b/share/hooks/normal/0150-remove-mdadm-configuration.hook.chroot new file mode 100755 index 000000000..206b494da --- /dev/null +++ b/share/hooks/normal/0150-remove-mdadm-configuration.hook.chroot @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +# Remove generated files + +rm -f /etc/mdadm/mdadm.conf diff --git a/share/hooks/normal/0160-remove-openssh-server-host-keys.hook.chroot b/share/hooks/normal/0160-remove-openssh-server-host-keys.hook.chroot new file mode 100755 index 000000000..862704981 --- /dev/null +++ b/share/hooks/normal/0160-remove-openssh-server-host-keys.hook.chroot @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +# Remove OpenSSH Host Keys. +# +# This removes openssh-server host keys, they are regenerated by live-config +# on system start. + +rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub diff --git a/share/hooks/normal/0170-remove-python-py.hook.chroot b/share/hooks/normal/0170-remove-python-py.hook.chroot new file mode 100755 index 000000000..ff705838f --- /dev/null +++ b/share/hooks/normal/0170-remove-python-py.hook.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# Remove Python *.py files. +# +# This removes byte-compiled Python modules to save some space. + +find /usr -name "*.pyc" -print0 | xargs -0r rm -f diff --git a/share/hooks/normal/0180-remove-systemd-machine-id.hook.chroot b/share/hooks/normal/0180-remove-systemd-machine-id.hook.chroot new file mode 100755 index 000000000..ed5d6bf6a --- /dev/null +++ b/share/hooks/normal/0180-remove-systemd-machine-id.hook.chroot @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +# Blank out systemd machine id. If it does not exist, systemd-journald +# will fail, but if it exists and is empty, systemd will automatically +# set up a new unique ID. + +if [ -e /etc/machine-id ] +then + rm -f /etc/machine-id + : > /etc/machine-id +fi diff --git a/share/hooks/normal/0190-remove-temporary-files.hook.chroot b/share/hooks/normal/0190-remove-temporary-files.hook.chroot new file mode 100755 index 000000000..fd220e030 --- /dev/null +++ b/share/hooks/normal/0190-remove-temporary-files.hook.chroot @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# Remove temporary files +rm -rf /var/cache/man/* + +for _DIRECTORY in /tmp /var/tmp +do + rm -rf ${_DIRECTORY} + + mkdir -p ${_DIRECTORY} + chmod 1777 ${_DIRECTORY} +done diff --git a/share/hooks/normal/0195-remove-ssl-cert-snakeoil.hook.chroot b/share/hooks/normal/0195-remove-ssl-cert-snakeoil.hook.chroot new file mode 100755 index 000000000..cdfe39d24 --- /dev/null +++ b/share/hooks/normal/0195-remove-ssl-cert-snakeoil.hook.chroot @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +# Remove ssl-cert snakeoil + +if [ -e /etc/ssl/certs/ssl-cert-snakeoil.pem ] +then + rm -f /etc/ssl/certs/$(openssl x509 -hash -noout -in /etc/ssl/certs/ssl-cert-snakeoil.pem) + + rm -f /etc/ssl/certs/ssl-cert-snakeoil.pem + rm -f /etc/ssl/private/ssl-cert-snakeoil.key +fi diff --git a/share/hooks/normal/0200-remove-udev-persistent-cd-rules.hook.chroot b/share/hooks/normal/0200-remove-udev-persistent-cd-rules.hook.chroot new file mode 100755 index 000000000..bdfe52d96 --- /dev/null +++ b/share/hooks/normal/0200-remove-udev-persistent-cd-rules.hook.chroot @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +# Remove udev persistent rules. +# +# This removes udev persistent rules that cache the host systems cd drive as +# well as the running live systems cd drive to remember its device name. + +if [ -e /etc/udev/rules.d ] +then + > /etc/udev/rules.d/70-persistent-cd.rules +fi diff --git a/share/hooks/normal/0300-remove-udev-persistent-net-rules.hook.chroot b/share/hooks/normal/0300-remove-udev-persistent-net-rules.hook.chroot new file mode 100755 index 000000000..148ba30d1 --- /dev/null +++ b/share/hooks/normal/0300-remove-udev-persistent-net-rules.hook.chroot @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +# Remove udev persistent rules. +# +# This removes udev persistent rules that cache the host systems mac address to +# remember its device name. + +for _FILE in /etc/udev/rules.d/*persistent-net.rules +do + if [ -e "${_FILE}" ] + then + : > ${_FILE} + fi +done diff --git a/share/hooks/normal/0400-update-apt-file-cache.hook.chroot b/share/hooks/normal/0400-update-apt-file-cache.hook.chroot new file mode 100755 index 000000000..771e9032a --- /dev/null +++ b/share/hooks/normal/0400-update-apt-file-cache.hook.chroot @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# Update the Apt File cache. +# +# This allows to use using apt-file out-of-the-box. + +. /live-build/config/binary + +if [ -x /usr/bin/apt-file ] && [ "${LB_APT_INDICES}" = "true" ] +then + apt-file update +fi diff --git a/share/hooks/normal/0410-update-apt-xapian-index.hook.chroot b/share/hooks/normal/0410-update-apt-xapian-index.hook.chroot new file mode 100755 index 000000000..dcb39b261 --- /dev/null +++ b/share/hooks/normal/0410-update-apt-xapian-index.hook.chroot @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# Update the Apt Xapian index. +# +# The package would do this itself, but (a) it checks policy-rc.d which says it +# is not allowed to, and (b) it wants to build the index in the background which +# will be racy in the context of live-build. + +if [ -x /usr/sbin/update-apt-xapian-index ] +then + PYTHONDONTWRITEBYTECODE=1 /usr/sbin/update-apt-xapian-index --force --quiet +fi diff --git a/share/hooks/normal/0420-update-glx-alternative.hook.chroot b/share/hooks/normal/0420-update-glx-alternative.hook.chroot new file mode 100755 index 000000000..8c36c43f9 --- /dev/null +++ b/share/hooks/normal/0420-update-glx-alternative.hook.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# Use mesa renderer by default +if [ -e /etc/alternatives/glx ] +then + update-alternatives --quiet --set glx /usr/lib/mesa-diverted +fi diff --git a/share/hooks/normal/0430-update-mlocate-database.hook.chroot b/share/hooks/normal/0430-update-mlocate-database.hook.chroot new file mode 100755 index 000000000..6bfdb3d4f --- /dev/null +++ b/share/hooks/normal/0430-update-mlocate-database.hook.chroot @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# Update the mlocate database. +# +# It is convenient for this to be already up to date on the live system, and it +# means that if the live system is later installed to a hard disk then less +# work will be required after installation. + +if [ -x /usr/bin/updatedb.mlocate ] +then + updatedb.mlocate +fi diff --git a/share/hooks/normal/0440-update-nvidia-alternative.hook.chroot b/share/hooks/normal/0440-update-nvidia-alternative.hook.chroot new file mode 100755 index 000000000..e73b9678b --- /dev/null +++ b/share/hooks/normal/0440-update-nvidia-alternative.hook.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# Use newest nvidia version by default +if [ -e /etc/alternatives/nvidia ] && [ -e /usr/lib/nvidia/current ] +then + update-alternatives --quiet --set nvidia /usr/lib/nvidia/current +fi diff --git a/share/hooks/normal/0910-remove-apt-sources-lists b/share/hooks/normal/0910-remove-apt-sources-lists new file mode 100755 index 000000000..1c8ca2d22 --- /dev/null +++ b/share/hooks/normal/0910-remove-apt-sources-lists @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +# Remove apt sources.list files + +rm -f /etc/apt/sources.list +rm -f /etc/apt/sources.list.d/*.list -- cgit v1.2.3