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. Except db820c's
35 # GPU firmware, due to using a precompiled kernel without compression support.
36 find /lib
/firmware
-type f
-print0 | \
38 xargs -0r -P4 -n4 xz
-T1 -C crc32
39 ln -s /lib
/firmware
/qcom
/a530
* /lib
/firmware
/
41 # Copy timezone file and remove tzdata package
43 cp /usr
/share
/zoneinfo
/Etc
/UTC
/etc
/localtime
45 UNNEEDED_PACKAGES
="libfdisk1
49 export DEBIAN_FRONTEND
=noninteractive
51 # Removing unused packages
52 for PACKAGE
in ${UNNEEDED_PACKAGES}
55 if ! apt-get remove
--purge --yes "${PACKAGE}"
57 echo "WARNING: ${PACKAGE} isn't installed"
61 apt-get autoremove
--yes || true
66 # Dropping documentation, localization, i18n files, etc
67 rm -rf /usr
/share
/doc
/*
68 rm -rf /usr
/share
/locale
/*
70 rm -rf /usr
/share
/i18n
/*
71 rm -rf /usr
/share
/info
/*
72 rm -rf /usr
/share
/lintian
/*
73 rm -rf /usr
/share
/common-licenses
/*
74 rm -rf /usr
/share
/mime
/*
76 # Dropping reportbug scripts
79 # Drop udev hwdb not required on a stripped system
80 rm -rf /lib
/udev
/hwdb.bin
/lib
/udev
/hwdb.d
/*
82 # Drop all gconv conversions && binaries
84 rm -rf usr
/sbin
/iconvconfig
85 rm -rf usr
/lib
/*/gconv
/
87 # Remove libusb database
88 rm -rf usr
/sbin
/update-usbids
89 rm -rf var
/lib
/usbutils
/usb.ids
90 rm -rf usr
/share
/misc
/usb.ids
92 #######################################################################
93 # Crush into a minimal production image to be deployed via some type of image
95 # IMPORTANT: The Debian system is not longer functional at this point,
96 # for example, apt and dpkg will stop working
98 UNNEEDED_PACKAGES
="apt libapt-pkg5.0 "\
99 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
101 "debconf libdebconfclient0 "\
102 "e2fsprogs e2fslibs libfdisk1 "\
105 "init-system-helpers "\
110 "libsemanage1 libsemanage-common "\
115 "debian-archive-keyring "\
117 # Removing unneeded packages
118 for PACKAGE
in ${UNNEEDED_PACKAGES}
120 echo "Forcing removal of ${PACKAGE}"
121 if ! dpkg
--purge --force-remove-essential --force-depends "${PACKAGE}"
123 echo "WARNING: ${PACKAGE} isn't installed"
127 # Show what's left package-wise before dropping dpkg itself
128 COLUMNS
=300 dpkg-query
-W --showformat='${Installed-Size;10}\t${Package}\n' |
sort -k1,1n
131 dpkg
--purge --force-remove-essential --force-depends dpkg
133 # No apt or dpkg, no need for its configuration archives
137 # Drop directories not part of ostree
138 # Note that /var needs to exist as ostree bind mounts the deployment /var over
140 rm -rf var
/* opt srv share
142 # ca-certificates are in /etc drop the source
143 rm -rf usr
/share
/ca-certificates
145 # No bash, no need for completions
146 rm -rf usr
/share
/bash-completion
148 # No zsh, no need for comletions
149 rm -rf usr
/share
/zsh
/vendor-completions
151 # drop gcc-6 python helpers
152 rm -rf usr
/share
/gcc-6
154 # Drop sysvinit leftovers
156 rm -rf etc
/rc
[0-6S].d
158 # Drop upstart helpers
161 # Various xtables helpers
162 rm -rf usr
/lib
/xtables
165 # TODO: only remaining locale is actually "C". Should we really remove it?
166 rm -rf usr
/lib
/locale
/*
174 # Systemd dns resolver
175 find usr etc
-name '*systemd-resolve*' -prune -exec rm -r {} \
;
177 # Systemd network configuration
178 find usr etc
-name '*networkd*' -prune -exec rm -r {} \
;
181 find usr etc
-name '*timesyncd*' -prune -exec rm -r {} \
;
183 # systemd hw database manager
184 find usr etc
-name '*systemd-hwdb*' -prune -exec rm -r {} \
;
187 find usr etc
-name '*fuse*' -prune -exec rm -r {} \
;
189 # lsb init function leftovers
192 # Only needed when adding libraries
193 rm usr
/sbin
/ldconfig
*
198 # Remove pam module to authenticate against a DB
199 # plus libdb-5.3.so that is only used by this pam module
200 rm usr
/lib
/*/security
/pam_userdb.so
201 rm usr
/lib
/*/libdb-5.3.so
203 # remove NSS support for nis, nisplus and hesiod
204 rm usr
/lib
/*/libnss_hesiod
*
205 rm usr
/lib
/*/libnss_nis
*