aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wagner <mail@jwagner.eu>2016-03-17 17:36:16 +0100
committerJan Wagner <mail@jwagner.eu>2016-03-17 17:36:16 +0100
commit50170a27d4119c047344793bb7aec685acb3ad6e (patch)
tree923c75f339921a125ddafbbd5ebc9bc2ee480ed8
parent24bd7e97cf9d07454c9cde74e4d80a1b3de9dfac (diff)
downloadrpi2-gen-image-50170a27d4119c047344793bb7aec685acb3ad6e.tar.gz
rpi2-gen-image-50170a27d4119c047344793bb7aec685acb3ad6e.tar.bz2
rpi2-gen-image-50170a27d4119c047344793bb7aec685acb3ad6e.zip
Added: KERNEL_REDUCE - less than 128MB used space, Added: REDUCE_ parameters
-rw-r--r--README.md32
-rw-r--r--bootstrap.d/10-bootstrap.sh2
-rw-r--r--bootstrap.d/13-kernel.sh39
-rw-r--r--bootstrap.d/50-firstboot.sh2
-rw-r--r--bootstrap.d/99-reduce.sh72
-rw-r--r--files/firstboot/24-create-resolv-symlink.sh11
-rwxr-xr-xrpi2-gen-image.sh172
7 files changed, 230 insertions, 100 deletions
diff --git a/README.md b/README.md
index c32bd8d..853730b 100644
--- a/README.md
+++ b/README.md
@@ -131,7 +131,7 @@ Install a user defined window manager for the X Window System. To make sure all
Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
##### `ENABLE_REDUCE`=false
-Reduce the disk usage by deleting all man pages and doc files (harsh). APT will be configured to use compressed package repository lists and no package caching files. If `ENABLE_MINGPU`=true unnecessary start.elf and fixup.dat files will also be removed from the boot partition. This will make it possible to generate output OS images with about 160MB of used disk space. It's recommended to use this parameter in combination with `ENABLE_MINBASE`=true.
+Reduce the disk usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
##### `ENABLE_UBOOT`=false
Replace default RPi2 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
@@ -165,6 +165,9 @@ Path to a directory with scripts that should be run in the chroot before the ima
##### `BUILD_KERNEL`=false
Build and install the latest RPi2 Linux kernel. Currently only the default RPi2 kernel configuration is used. Detailed configuration parameters for customizing the kernel and minor bug fixes still need to get implemented. feel free to help.
+##### `KERNEL_REDUCE`=false
+Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
+
##### `KERNEL_THREADS`=1
Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
@@ -189,6 +192,33 @@ Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the k
##### `KERNELSRC_PREBUILT`=false
With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
+#### Reduce disk usage:
+The following list of parameters is ignored if `ENABLE_REDUCE`=false.
+
+##### `REDUCE_APT`=true
+Configure APT to use compressed package repository lists and no package caching files.
+
+##### `REDUCE_DOC`=true
+Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
+
+##### `REDUCE_MAN`=true
+Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
+
+##### `REDUCE_VIM`=true
+Replace `vim-tiny` package by `levee` a tiny vim clone.
+
+##### `REDUCE_BASH`=false
+Remove `bash` package and switch to `dash` shell (experimental).
+
+##### `REDUCE_HWDB`=true
+Remove PCI related hwdb files (experimental).
+
+##### `REDUCE_SSHD`=true
+Replace `openssh-server` with dropbear.
+
+##### `REDUCE_LOCALE`=true
+Remove all `locale` translation files.
+
## Understanding the script
The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order:
diff --git a/bootstrap.d/10-bootstrap.sh b/bootstrap.d/10-bootstrap.sh
index f4a57cc..7b4a04d 100644
--- a/bootstrap.d/10-bootstrap.sh
+++ b/bootstrap.d/10-bootstrap.sh
@@ -7,7 +7,7 @@
# Base debootstrap (unpack only)
if [ "$ENABLE_MINBASE" = true ] ; then
- http_proxy=${APT_PROXY} debootstrap --arch="${RELEASE_ARCH}" --variant=minbase --foreign --include="${APT_INCLUDES}" "${RELEASE}" "$R" "http://${APT_SERVER}/debian"
+ http_proxy=${APT_PROXY} debootstrap --arch="${RELEASE_ARCH}" --foreign --variant=minbase --include="${APT_INCLUDES}" "${RELEASE}" "$R" "http://${APT_SERVER}/debian"
else
http_proxy=${APT_PROXY} debootstrap --arch="${RELEASE_ARCH}" --foreign --include="${APT_INCLUDES}" "${RELEASE}" "$R" "http://${APT_SERVER}/debian"
fi
diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh
index a8e4f4a..671025d 100644
--- a/bootstrap.d/13-kernel.sh
+++ b/bootstrap.d/13-kernel.sh
@@ -29,7 +29,44 @@ if [ "$BUILD_KERNEL" = true ] ; then
KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
fi
+ # Configure and build kernel
if [ "$KERNELSRC_PREBUILT" = false ] ; then
+ # Remove device, network and filesystem drivers from kernel configuration
+ if [ "$KERNEL_REDUCE" = true ] ; then
+ make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
+ sed -i\
+ -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
+ -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
+ -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
+ -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
+ -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
+ -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
+ -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
+ "$R/usr/src/linux/.config"
+ fi
+
if [ "$KERNELSRC_CONFIG" = true ] ; then
# Load default raspberry kernel configuration
make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
@@ -62,7 +99,7 @@ if [ "$BUILD_KERNEL" = true ] ; then
fi
# Install kernel headers
- if [ "$KERNEL_HEADERS" = true ] ; then
+ if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
fi
diff --git a/bootstrap.d/50-firstboot.sh b/bootstrap.d/50-firstboot.sh
index 4892c4b..0c93d11 100644
--- a/bootstrap.d/50-firstboot.sh
+++ b/bootstrap.d/50-firstboot.sh
@@ -9,7 +9,7 @@
cat files/firstboot/10-begin.sh > "$R/etc/rc.firstboot"
# Ensure openssh server host keys are regenerated on first boot
-if [ "$ENABLE_SSHD" = true ] ; then
+if [ "$ENABLE_SSHD" = true ] && [ "$ENABLE_REDUCE" = false ]; then
cat files/firstboot/21-generate-ssh-keys.sh >> "$R/etc/rc.firstboot"
rm -f "$R/etc/ssh/ssh_host_*"
fi
diff --git a/bootstrap.d/99-reduce.sh b/bootstrap.d/99-reduce.sh
new file mode 100644
index 0000000..f3b2848
--- /dev/null
+++ b/bootstrap.d/99-reduce.sh
@@ -0,0 +1,72 @@
+#
+# Reduce system disk usage
+#
+
+# Load utility functions
+. ./functions.sh
+
+# Reduce the image size by various operations
+if [ "$ENABLE_REDUCE" = true ] ; then
+ if [ "$REDUCE_APT" = true ] ; then
+ # Install dpkg configuration file
+ if [ "$REDUCE_DOC" = true ] || [ "$REDUCE_MAN" = true ] ; then
+ install_readonly files/dpkg/01nodoc "$R/etc/dpkg/dpkg.cfg.d/01nodoc"
+ fi
+
+ # Install APT configuration files
+ install_readonly files/apt/02nocache "$R/etc/apt/apt.conf.d/02nocache"
+ install_readonly files/apt/03compress "$R/etc/apt/apt.conf.d/03compress"
+ install_readonly files/apt/04norecommends "$R/etc/apt/apt.conf.d/04norecommends"
+
+ # Remove APT cache files
+ rm -fr "$R/var/cache/apt/pkgcache.bin"
+ rm -fr "$R/var/cache/apt/srcpkgcache.bin"
+ fi
+
+ # Remove all doc files
+ if [ "$REDUCE_DOC" = true ] ; then
+ find "$R/usr/share/doc" -depth -type f ! -name copyright | xargs rm || true
+ find "$R/usr/share/doc" -empty | xargs rmdir || true
+ fi
+
+ # Remove all man pages and info files
+ if [ "$REDUCE_MAN" = true ] ; then
+ rm -rf "$R/usr/share/man" "$R/usr/share/groff" "$R/usr/share/info" "$R/usr/share/lintian" "$R/usr/share/linda" "$R/var/cache/man"
+ fi
+
+ # Remove all locale translation files
+ if [ "$REDUCE_LOCALE" = true ] ; then
+ find "$R/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' | xargs rm -r
+ fi
+
+ # Remove hwdb PCI device classes (experimental)
+ if [ "$REDUCE_HWDB" = true ] ; then
+ rm -fr "/lib/udev/hwdb.d/20-pci-*"
+ fi
+
+ # Replace bash shell by dash shell (experimental)
+ if [ "$REDUCE_BASH" = true ] ; then
+ echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --force-yes bash
+ chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100
+ fi
+
+ # Remove sound utils and libraries
+ if [ "$ENABLE_SOUND" = false ] ; then
+ chroot_exec apt-get -qq -y --force-yes purge alsa-utils libsamplerate0 libasound2 libasound2-data
+ fi
+
+ # Re-install tools for managing kernel moduless
+ chroot_exec apt-get -qq -y --force-yes install module-init-tools
+
+ # Remove GPU kernels
+ if [ "$ENABLE_MINGPU" = true ] ; then
+ rm -f "$R/boot/firmware/start.elf"
+ rm -f "$R/boot/firmware/fixup.dat"
+ rm -f "$R/boot/firmware/start_x.elf"
+ rm -f "$R/boot/firmware/fixup_x.dat"
+ fi
+
+ # Clean APT list of repositories
+ rm -fr "$R/var/lib/apt/lists/*"
+ chroot_exec apt-get -qq -y update
+fi
diff --git a/files/firstboot/24-create-resolv-symlink.sh b/files/firstboot/24-create-resolv-symlink.sh
index e4a65b4..0dd09de 100644
--- a/files/firstboot/24-create-resolv-symlink.sh
+++ b/files/firstboot/24-create-resolv-symlink.sh
@@ -1,4 +1,13 @@
logger -t "rc.firstboot" "Creating /etc/resolv.conf symlink"
-if [ -f "/run/systemd/resolve/resolv.conf" ] ; then
+
+
+# Check if systemd resolve directory exists
+if [ -d "/run/systemd/resolve" ] ; then
+ # Create resolv.conf file if it does not exists
+ if [ ! -f "/run/systemd/resolve/resolv.conf" ] ; then
+ touch /run/systemd/resolve/resolv.conf
+ fi
+
+ # Create symlink to /etc/reolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
fi
diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh
index 258fa6e..dcaef9c 100755
--- a/rpi2-gen-image.sh
+++ b/rpi2-gen-image.sh
@@ -15,6 +15,12 @@
# Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
########################################################################
+# Are we running as root?
+if [ "$(id -u)" -ne "0" ] ; then
+ echo "error: this script must be executed with root privileges!"
+ exit 1
+fi
+
# Check if ./functions.sh script exists
if [ ! -r "./functions.sh" ] ; then
echo "error: './functions.sh' required script not found. please reinstall the latest script version!"
@@ -38,9 +44,10 @@ COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
-# Build settings
+# Build directories
BASEDIR=$(pwd)/images/${RELEASE}
BUILDDIR=${BASEDIR}/build
+R=${BUILDDIR}/chroot
# General settings
HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
@@ -59,7 +66,6 @@ XKB_OPTIONS=${XKB_OPTIONS:=""}
ENABLE_DHCP=${ENABLE_DHCP:=true}
# Network settings (static)
-# only used on ENABLE_DHCP=false
NET_ADDRESS=${NET_ADDRESS:=""}
NET_GATEWAY=${NET_GATEWAY:=""}
NET_DNS_1=${NET_DNS_1:=""}
@@ -98,6 +104,7 @@ ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
# Kernel compilation settings
BUILD_KERNEL=${BUILD_KERNEL:=false}
+KERNEL_REDUCE=${KERNEL_REDUCE:=false}
KERNEL_THREADS=${KERNEL_THREADS:=1}
KERNEL_HEADERS=${KERNEL_HEADERS:=true}
KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
@@ -109,62 +116,40 @@ KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
-# Image chroot path
-R=${BUILDDIR}/chroot
+# Reduce disk usage settings
+REDUCE_APT=${REDUCE_APT:=true}
+REDUCE_DOC=${REDUCE_DOC:=true}
+REDUCE_MAN=${REDUCE_MAN:=true}
+REDUCE_VIM=${REDUCE_VIM:=true}
+REDUCE_BASH=${REDUCE_BASH:=false}
+REDUCE_HWDB=${REDUCE_HWDB:=true}
+REDUCE_SSHD=${REDUCE_SSHD:=true}
+REDUCE_LOCALE=${REDUCE_LOCALE:=true}
+
+# Chroot scripts directory
CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
-# Packages required for bootstrapping
-REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
-
-# Missing packages that need to be installed
-MISSING_PACKAGES=""
-
# Packages required in the chroot build environment
APT_INCLUDES=${APT_INCLUDES:=""}
APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo"
-set +x
-
-# Are we running as root?
-if [ "$(id -u)" -ne "0" ] ; then
- echo "error: this script must be executed with root privileges!"
- exit 1
-fi
-
-# Check if ./bootstrap.d directory exists
-if [ ! -d "./bootstrap.d/" ] ; then
- echo "error: './bootstrap.d' required directory not found. please reinstall the latest script version!"
- exit 1
-fi
-
-# Check if ./files directory exists
-if [ ! -d "./files/" ] ; then
- echo "error: './files' required directory not found. please reinstall the latest script version!"
- exit 1
-fi
-
-# Check if specified KERNELSRC_DIR directory exists
-if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
- echo "error: ${KERNELSRC_DIR} (KERNELSRC_DIR) specified directory not found!"
- exit 1
-fi
+# Packages required for bootstrapping
+REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
+MISSING_PACKAGES=""
-# Check if specified CHROOT_SCRIPTS directory exists
-if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
- echo "error: ${CHROOT_SCRIPTS} (CHROOT_SCRIPTS) specified directory not found!"
- exit 1
-fi
+set +x
# Add packages required for kernel cross compilation
if [ "$BUILD_KERNEL" = true ] ; then
REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
+fi
- if [ "$KERNEL_MENUCONFIG" = true ] ; then
- REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ncurses-dev"
- fi
+# Add libncurses5 to enable kernel menuconfig
+if [ "$KERNEL_MENUCONFIG" = true ] ; then
+ REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
fi
-# Check if all required packages are installed
+# Check if all required packages are installed on the build system
for package in $REQUIRED_PACKAGES ; do
if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
MISSING_PACKAGES="${MISSING_PACKAGES} $package"
@@ -178,14 +163,36 @@ if [ -n "$MISSING_PACKAGES" ] ; then
echo -n "\ndo you want to install the missing packages right now? [y/n] "
read confirm
- if [ "$confirm" != "y" ] ; then
- exit 1
- fi
+ [ "$confirm" != "y" ] && exit 1
fi
# Make sure all required packages are installed
apt-get -qq -y install ${REQUIRED_PACKAGES}
+# Check if ./bootstrap.d directory exists
+if [ ! -d "./bootstrap.d/" ] ; then
+ echo "error: './bootstrap.d' required directory not found!"
+ exit 1
+fi
+
+# Check if ./files directory exists
+if [ ! -d "./files/" ] ; then
+ echo "error: './files' required directory not found!"
+ exit 1
+fi
+
+# Check if specified KERNELSRC_DIR directory exists
+if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
+ echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
+ exit 1
+fi
+
+# Check if specified CHROOT_SCRIPTS directory exists
+if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
+ echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
+ exit 1
+fi
+
# Don't clobber an old build
if [ -e "$BUILDDIR" ] ; then
echo "error: directory ${BUILDDIR} already exists, not proceeding"
@@ -197,15 +204,10 @@ mkdir -p "$R"
# Check if build directory has enough of free disk space >512MB
if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
- echo "error: ${BUILDDIR} not enough space left on this partition to generate the output image!"
+ echo "error: ${BUILDDIR} not enough space left to generate the output image!"
exit 1
fi
-# Warn if build directory has low free disk space <1024MB
-if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "1048576" ] ; then
- echo `df -h --output=avail ${BUILDDIR} | sed "1 s|.*Avail|warning: $partition is low on free space:|"`
-fi
-
set -x
# Call "cleanup" function on various signals and errors
@@ -267,30 +269,45 @@ if [ "$ENABLE_XORG" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},xorg"
fi
-# Set KERNELSRC_CONFIG=true
+# Replace selected packages with smaller clones
+if [ "$ENABLE_REDUCE" = true ] ; then
+ # Add levee package instead of vim-tiny
+ if [ "$REDUCE_VIM" = true ] ; then
+ APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
+ fi
+
+ # Add dropbear package instead of openssh-server
+ if [ "$REDUCE_SSHD" = true ] ; then
+ APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
+ fi
+fi
+
+# Configure kernel sources if no KERNELSRC_DIR
if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
KERNELSRC_CONFIG=true
fi
-## MAIN bootstrap
+# Configure reduced kernel
+if [ "$KERNEL_REDUCE" = true ] ; then
+ KERNELSRC_CONFIG=false
+fi
+
+# Execute bootstrap scripts
for SCRIPT in bootstrap.d/*.sh; do
- # Execute bootstrap scripts (lexicographical order)
head -n 3 "$SCRIPT"
. "$SCRIPT"
done
-## Custom bootstrap scripts
+## Execute custom bootstrap scripts
if [ -d "custom.d" ] ; then
- # Execute custom bootstrap scripts (lexicographical order)
for SCRIPT in custom.d/*.sh; do
. "$SCRIPT"
done
fi
-# Invoke custom scripts
+# Execute custom scripts inside the chroot
if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
- # Execute scripts inside the chroot (lexicographical order)
chroot_exec /bin/bash -x <<'EOF'
for SCRIPT in /chroot_scripts/* ; do
if [ -f $SCRIPT -a -x $SCRIPT ] ; then
@@ -304,41 +321,6 @@ fi
# Remove apt-utils
chroot_exec apt-get purge -qq -y --force-yes apt-utils
-# Reduce the image size by removing and compressing
-if [ "$ENABLE_REDUCE" = true ] ; then
- # Install dpkg configuration fragment file
- install_readonly files/dpkg/01nodoc "$R/etc/dpkg/dpkg.cfg.d/01nodoc"
-
- # Install APT configuration fragment files
- install_readonly files/apt/02nocache "$R/etc/apt/apt.conf.d/02nocache"
- install_readonly files/apt/03compress "$R/etc/apt/apt.conf.d/03compress"
- install_readonly files/apt/04norecommends "$R/etc/apt/apt.conf.d/04norecommends"
-
- # Remove APT cache files
- rm -fr "$R/var/cache/apt/pkgcache.bin"
- rm -fr "$R/var/cache/apt/srcpkgcache.bin"
-
- # Remove all doc and man files
- find "$R/usr/share/doc" -depth -type f ! -name copyright | xargs rm || true
- find "$R/usr/share/doc" -empty | xargs rmdir || true
- rm -rf "$R/usr/share/man" "$R/usr/share/groff" "$R/usr/share/info" "$R/usr/share/lintian" "$R/usr/share/linda" "$R/var/cache/man"
-
- # Remove all translation files
- find "$R/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' | xargs rm -r
-
- # Clean APT list of repositories
- rm -fr "$R/var/lib/apt/lists/*"
- chroot_exec apt-get -qq -y update
-
- # Remove GPU kernels
- if [ "$ENABLE_MINGPU" = true ] ; then
- rm -f "$R/boot/firmware/start.elf"
- rm -f "$R/boot/firmware/fixup.dat"
- rm -f "$R/boot/firmware/start_x.elf"
- rm -f "$R/boot/firmware/fixup_x.dat"
- fi
-fi
-
# APT Cleanup
chroot_exec apt-get -y clean
chroot_exec apt-get -y autoclean