99-reduce.sh
76 lines
| 2.5 KiB
| application/x-sh
|
BashLexer
/ bootstrap.d / 99-reduce.sh
|
r76 | # | ||
# 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 | ||||
|
r94 | install_readonly files/dpkg/01nodoc "${ETC_DIR}/dpkg/dpkg.cfg.d/01nodoc" | ||
|
r76 | fi | ||
# Install APT configuration files | ||||
|
r94 | install_readonly files/apt/02nocache "${ETC_DIR}/apt/apt.conf.d/02nocache" | ||
install_readonly files/apt/03compress "${ETC_DIR}/apt/apt.conf.d/03compress" | ||||
install_readonly files/apt/04norecommends "${ETC_DIR}/apt/apt.conf.d/04norecommends" | ||||
|
r76 | |||
# Remove APT cache files | ||||
|
r82 | rm -fr "${R}/var/cache/apt/pkgcache.bin" | ||
rm -fr "${R}/var/cache/apt/srcpkgcache.bin" | ||||
|
r76 | fi | ||
# Remove all doc files | ||||
if [ "$REDUCE_DOC" = true ] ; then | ||||
|
r312 | find "${R}/usr/share/doc" -depth -type f ! -name copyright -print0 | xargs -0 rm || true | ||
find "${R}/usr/share/doc" -empty -print0 | xargs -0 rmdir || true | ||||
|
r76 | fi | ||
# Remove all man pages and info files | ||||
if [ "$REDUCE_MAN" = true ] ; then | ||||
|
r82 | 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" | ||
|
r76 | fi | ||
# Remove all locale translation files | ||||
if [ "$REDUCE_LOCALE" = true ] ; then | ||||
|
r312 | find "${R}/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' -print0 | xargs -0 rm -r | ||
|
r76 | 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 | ||||
|
r385 | # Purge bash and update alternatives | ||
echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash | ||||
|
r76 | chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100 | ||
fi | ||||
# Remove sound utils and libraries | ||||
if [ "$ENABLE_SOUND" = false ] ; then | ||||
|
r142 | chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data | ||
|
r76 | fi | ||
# Remove GPU kernels | ||||
if [ "$ENABLE_MINGPU" = true ] ; then | ||||
|
r94 | rm -f "${BOOT_DIR}/start.elf" | ||
rm -f "${BOOT_DIR}/fixup.dat" | ||||
rm -f "${BOOT_DIR}/start_x.elf" | ||||
rm -f "${BOOT_DIR}/fixup_x.dat" | ||||
|
r76 | fi | ||
|
r77 | # Remove kernel and initrd from /boot (already in /boot/firmware) | ||
if [ "$BUILD_KERNEL" = false ] ; then | ||||
|
r82 | rm -f "${R}/boot/vmlinuz-*" | ||
rm -f "${R}/boot/initrd.img-*" | ||||
|
r77 | fi | ||
|
r76 | # Clean APT list of repositories | ||
|
r82 | rm -fr "${R}/var/lib/apt/lists/*" | ||
|
r76 | chroot_exec apt-get -qq -y update | ||
fi | ||||