5 apt-get
-y install --no-install-recommends \
22 export PS1=lava-shell:
27 mkdir
-p /lib
/firmware
/rtl_nic
28 wget https
://git.kernel.org
/pub
/scm
/linux
/kernel
/git
/firmware
/linux-firmware.git
/tree
/rtl_nic
/rtl8153a-3.fw
-O /lib
/firmware
/rtl_nic
/rtl8153a-3.fw
30 #######################################################################
31 # Strip the image to a small minimal system without removing the debian
34 # xz compress firmware so it doesn't waste RAM at runtime.
35 find /lib
/firmware
-type f
-print0 |
xargs -0r -P4 -n4 xz
-T1 -C crc32
37 # Copy timezone file and remove tzdata package
39 cp /usr
/share
/zoneinfo
/Etc
/UTC
/etc
/localtime
41 UNNEEDED_PACKAGES
="libfdisk1
45 export DEBIAN_FRONTEND
=noninteractive
47 # Removing unused packages
48 for PACKAGE
in ${UNNEEDED_PACKAGES}
51 if ! apt-get remove
--purge --yes "${PACKAGE}"
53 echo "WARNING: ${PACKAGE} isn't installed"
57 apt-get autoremove
--yes || true
62 # Dropping documentation, localization, i18n files, etc
63 rm -rf /usr
/share
/doc
/*
64 rm -rf /usr
/share
/locale
/*
66 rm -rf /usr
/share
/i18n
/*
67 rm -rf /usr
/share
/info
/*
68 rm -rf /usr
/share
/lintian
/*
69 rm -rf /usr
/share
/common-licenses
/*
70 rm -rf /usr
/share
/mime
/*
72 # Dropping reportbug scripts
75 # Drop udev hwdb not required on a stripped system
76 rm -rf /lib
/udev
/hwdb.bin
/lib
/udev
/hwdb.d
/*
78 # Drop all gconv conversions && binaries
80 rm -rf usr
/sbin
/iconvconfig
81 rm -rf usr
/lib
/*/gconv
/
83 # Remove libusb database
84 rm -rf usr
/sbin
/update-usbids
85 rm -rf var
/lib
/usbutils
/usb.ids
86 rm -rf usr
/share
/misc
/usb.ids
88 #######################################################################
89 # Crush into a minimal production image to be deployed via some type of image
91 # IMPORTANT: The Debian system is not longer functional at this point,
92 # for example, apt and dpkg will stop working
94 UNNEEDED_PACKAGES
="apt libapt-pkg5.0 "\
95 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
97 "debconf libdebconfclient0 "\
98 "e2fsprogs e2fslibs libfdisk1 "\
101 "init-system-helpers "\
106 "libsemanage1 libsemanage-common "\
111 "debian-archive-keyring "\
113 # Removing unneeded packages
114 for PACKAGE
in ${UNNEEDED_PACKAGES}
116 echo "Forcing removal of ${PACKAGE}"
117 if ! dpkg
--purge --force-remove-essential --force-depends "${PACKAGE}"
119 echo "WARNING: ${PACKAGE} isn't installed"
123 # Show what's left package-wise before dropping dpkg itself
124 COLUMNS
=300 dpkg-query
-W --showformat='${Installed-Size;10}\t${Package}\n' |
sort -k1,1n
127 dpkg
--purge --force-remove-essential --force-depends dpkg
129 # No apt or dpkg, no need for its configuration archives
133 # Drop directories not part of ostree
134 # Note that /var needs to exist as ostree bind mounts the deployment /var over
136 rm -rf var
/* opt srv share
138 # ca-certificates are in /etc drop the source
139 rm -rf usr
/share
/ca-certificates
141 # No bash, no need for completions
142 rm -rf usr
/share
/bash-completion
144 # No zsh, no need for comletions
145 rm -rf usr
/share
/zsh
/vendor-completions
147 # drop gcc-6 python helpers
148 rm -rf usr
/share
/gcc-6
150 # Drop sysvinit leftovers
152 rm -rf etc
/rc
[0-6S].d
154 # Drop upstart helpers
157 # Various xtables helpers
158 rm -rf usr
/lib
/xtables
161 # TODO: only remaining locale is actually "C". Should we really remove it?
162 rm -rf usr
/lib
/locale
/*
170 # Systemd dns resolver
171 find usr etc
-name '*systemd-resolve*' -prune -exec rm -r {} \
;
173 # Systemd network configuration
174 find usr etc
-name '*networkd*' -prune -exec rm -r {} \
;
177 find usr etc
-name '*timesyncd*' -prune -exec rm -r {} \
;
179 # systemd hw database manager
180 find usr etc
-name '*systemd-hwdb*' -prune -exec rm -r {} \
;
183 find usr etc
-name '*fuse*' -prune -exec rm -r {} \
;
185 # lsb init function leftovers
188 # Only needed when adding libraries
189 rm usr
/sbin
/ldconfig
*
194 # Remove pam module to authenticate against a DB
195 # plus libdb-5.3.so that is only used by this pam module
196 rm usr
/lib
/*/security
/pam_userdb.so
197 rm usr
/lib
/*/libdb-5.3.so
199 # remove NSS support for nis, nisplus and hesiod
200 rm usr
/lib
/*/libnss_hesiod
*
201 rm usr
/lib
/*/libnss_nis
*