5 apt-get
-y install --no-install-recommends \
18 export PS1=lava-shell:
23 #######################################################################
24 # Strip the image to a small minimal system without removing the debian
27 # Copy timezone file and remove tzdata package
29 cp /usr
/share
/zoneinfo
/Etc
/UTC
/etc
/localtime
31 UNNEEDED_PACKAGES
="libfdisk1
35 export DEBIAN_FRONTEND
=noninteractive
37 # Removing unused packages
38 for PACKAGE
in ${UNNEEDED_PACKAGES}
41 if ! apt-get remove
--purge --yes "${PACKAGE}"
43 echo "WARNING: ${PACKAGE} isn't installed"
47 apt-get autoremove
--yes || true
52 # Dropping documentation, localization, i18n files, etc
53 rm -rf /usr
/share
/doc
/*
54 rm -rf /usr
/share
/locale
/*
56 rm -rf /usr
/share
/i18n
/*
57 rm -rf /usr
/share
/info
/*
58 rm -rf /usr
/share
/lintian
/*
59 rm -rf /usr
/share
/common-licenses
/*
60 rm -rf /usr
/share
/mime
/*
62 # Dropping reportbug scripts
65 # Drop udev hwdb not required on a stripped system
66 rm -rf /lib
/udev
/hwdb.bin
/lib
/udev
/hwdb.d
/*
68 # Drop all gconv conversions && binaries
70 rm -rf usr
/sbin
/iconvconfig
71 rm -rf usr
/lib
/*/gconv
/
73 # Remove libusb database
74 rm -rf usr
/sbin
/update-usbids
75 rm -rf var
/lib
/usbutils
/usb.ids
76 rm -rf usr
/share
/misc
/usb.ids
78 #######################################################################
79 # Crush into a minimal production image to be deployed via some type of image
81 # IMPORTANT: The Debian system is not longer functional at this point,
82 # for example, apt and dpkg will stop working
84 UNNEEDED_PACKAGES
="apt libapt-pkg5.0 "\
85 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
87 "debconf libdebconfclient0 "\
88 "e2fsprogs e2fslibs libfdisk1 "\
91 "init-system-helpers "\
95 "libsemanage1 libsemanage-common "\
101 "debian-archive-keyring "\
103 # Removing unneeded packages
104 for PACKAGE
in ${UNNEEDED_PACKAGES}
106 echo "Forcing removal of ${PACKAGE}"
107 if ! dpkg
--purge --force-remove-essential --force-depends "${PACKAGE}"
109 echo "WARNING: ${PACKAGE} isn't installed"
113 # Show what's left package-wise before dropping dpkg itself
114 COLUMNS
=300 dpkg-query
-W --showformat='${Installed-Size;10}\t${Package}\n' |
sort -k1,1n
117 dpkg
--purge --force-remove-essential --force-depends dpkg
119 # No apt or dpkg, no need for its configuration archives
123 # Drop directories not part of ostree
124 # Note that /var needs to exist as ostree bind mounts the deployment /var over
126 rm -rf var
/* opt srv share
128 # ca-certificates are in /etc drop the source
129 rm -rf usr
/share
/ca-certificates
131 # No bash, no need for completions
132 rm -rf usr
/share
/bash-completion
134 # No zsh, no need for comletions
135 rm -rf usr
/share
/zsh
/vendor-completions
137 # drop gcc-6 python helpers
138 rm -rf usr
/share
/gcc-6
140 # Drop sysvinit leftovers
142 rm -rf etc
/rc
[0-6S].d
144 # Drop upstart helpers
147 # Various xtables helpers
148 rm -rf usr
/lib
/xtables
151 # TODO: only remaining locale is actually "C". Should we really remove it?
152 rm -rf usr
/lib
/locale
/*
160 # Systemd dns resolver
161 find usr etc
-name '*systemd-resolve*' -prune -exec rm -r {} \
;
163 # Systemd network configuration
164 find usr etc
-name '*networkd*' -prune -exec rm -r {} \
;
167 find usr etc
-name '*timesyncd*' -prune -exec rm -r {} \
;
169 # systemd hw database manager
170 find usr etc
-name '*systemd-hwdb*' -prune -exec rm -r {} \
;
173 find usr etc
-name '*fuse*' -prune -exec rm -r {} \
;
175 # lsb init function leftovers
178 # Only needed when adding libraries
179 rm usr
/sbin
/ldconfig
*
184 # Remove pam module to authenticate against a DB
185 # plus libdb-5.3.so that is only used by this pam module
186 rm usr
/lib
/*/security
/pam_userdb.so
187 rm usr
/lib
/*/libdb-5.3.so
189 # remove NSS support for nis, nisplus and hesiod
190 rm usr
/lib
/*/libnss_hesiod
*
191 rm usr
/lib
/*/libnss_nis
*