aboutsummaryrefslogtreecommitdiff
path: root/bootstrap.d
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 /bootstrap.d
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
Diffstat (limited to 'bootstrap.d')
-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
4 files changed, 112 insertions, 3 deletions
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