5 apt-get
-y install --no-install-recommends \
21 export PS1=lava-shell:
26 mkdir
-p /lib
/firmware
/rtl_nic
27 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
29 #######################################################################
30 # Strip the image to a small minimal system without removing the debian
33 # xz compress firmware so it doesn't waste RAM at runtime.
34 find /lib
/firmware
-type f
-print0 |
xargs -0r -P4 -n4 xz
-T1 -C crc32
36 # Copy timezone file and remove tzdata package
38 cp /usr
/share
/zoneinfo
/Etc
/UTC
/etc
/localtime
40 UNNEEDED_PACKAGES
="libfdisk1
44 export DEBIAN_FRONTEND
=noninteractive
46 # Removing unused packages
47 for PACKAGE
in ${UNNEEDED_PACKAGES}
50 if ! apt-get remove
--purge --yes "${PACKAGE}"
52 echo "WARNING: ${PACKAGE} isn't installed"
56 apt-get autoremove
--yes || true
61 # Dropping documentation, localization, i18n files, etc
62 rm -rf /usr
/share
/doc
/*
63 rm -rf /usr
/share
/locale
/*
65 rm -rf /usr
/share
/i18n
/*
66 rm -rf /usr
/share
/info
/*
67 rm -rf /usr
/share
/lintian
/*
68 rm -rf /usr
/share
/common-licenses
/*
69 rm -rf /usr
/share
/mime
/*
71 # Dropping reportbug scripts
74 # Drop udev hwdb not required on a stripped system
75 rm -rf /lib
/udev
/hwdb.bin
/lib
/udev
/hwdb.d
/*
77 # Drop all gconv conversions && binaries
79 rm -rf usr
/sbin
/iconvconfig
80 rm -rf usr
/lib
/*/gconv
/
82 # Remove libusb database
83 rm -rf usr
/sbin
/update-usbids
84 rm -rf var
/lib
/usbutils
/usb.ids
85 rm -rf usr
/share
/misc
/usb.ids
87 #######################################################################
88 # Crush into a minimal production image to be deployed via some type of image
90 # IMPORTANT: The Debian system is not longer functional at this point,
91 # for example, apt and dpkg will stop working
93 UNNEEDED_PACKAGES
="apt libapt-pkg5.0 "\
94 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
96 "debconf libdebconfclient0 "\
97 "e2fsprogs e2fslibs libfdisk1 "\
100 "init-system-helpers "\
105 "libsemanage1 libsemanage-common "\
110 "debian-archive-keyring "\
112 # Removing unneeded packages
113 for PACKAGE
in ${UNNEEDED_PACKAGES}
115 echo "Forcing removal of ${PACKAGE}"
116 if ! dpkg
--purge --force-remove-essential --force-depends "${PACKAGE}"
118 echo "WARNING: ${PACKAGE} isn't installed"
122 # Show what's left package-wise before dropping dpkg itself
123 COLUMNS
=300 dpkg-query
-W --showformat='${Installed-Size;10}\t${Package}\n' |
sort -k1,1n
126 dpkg
--purge --force-remove-essential --force-depends dpkg
128 # No apt or dpkg, no need for its configuration archives
132 # Drop directories not part of ostree
133 # Note that /var needs to exist as ostree bind mounts the deployment /var over
135 rm -rf var
/* opt srv share
137 # ca-certificates are in /etc drop the source
138 rm -rf usr
/share
/ca-certificates
140 # No bash, no need for completions
141 rm -rf usr
/share
/bash-completion
143 # No zsh, no need for comletions
144 rm -rf usr
/share
/zsh
/vendor-completions
146 # drop gcc-6 python helpers
147 rm -rf usr
/share
/gcc-6
149 # Drop sysvinit leftovers
151 rm -rf etc
/rc
[0-6S].d
153 # Drop upstart helpers
156 # Various xtables helpers
157 rm -rf usr
/lib
/xtables
160 # TODO: only remaining locale is actually "C". Should we really remove it?
161 rm -rf usr
/lib
/locale
/*
169 # Systemd dns resolver
170 find usr etc
-name '*systemd-resolve*' -prune -exec rm -r {} \
;
172 # Systemd network configuration
173 find usr etc
-name '*networkd*' -prune -exec rm -r {} \
;
176 find usr etc
-name '*timesyncd*' -prune -exec rm -r {} \
;
178 # systemd hw database manager
179 find usr etc
-name '*systemd-hwdb*' -prune -exec rm -r {} \
;
182 find usr etc
-name '*fuse*' -prune -exec rm -r {} \
;
184 # lsb init function leftovers
187 # Only needed when adding libraries
188 rm usr
/sbin
/ldconfig
*
193 # Remove pam module to authenticate against a DB
194 # plus libdb-5.3.so that is only used by this pam module
195 rm usr
/lib
/*/security
/pam_userdb.so
196 rm usr
/lib
/*/libdb-5.3.so
198 # remove NSS support for nis, nisplus and hesiod
199 rm usr
/lib
/*/libnss_hesiod
*
200 rm usr
/lib
/*/libnss_nis
*