7 # LLVMPipe on armhf is broken with LLVM 8
8 if [ `dpkg --print-architecture` = "armhf" ]; then
12 apt-get
-y install --no-install-recommends \
25 #######################################################################
26 # Strip the image to a small minimal system without removing the debian
29 # Copy timezone file and remove tzdata package
31 cp /usr
/share
/zoneinfo
/Etc
/UTC
/etc
/localtime
33 UNNEEDED_PACKAGES
="libfdisk1
37 export DEBIAN_FRONTEND
=noninteractive
39 # Removing unused packages
40 for PACKAGE
in ${UNNEEDED_PACKAGES}
43 if ! apt-get remove
--purge --yes "${PACKAGE}"
45 echo "WARNING: ${PACKAGE} isn't installed"
49 apt-get autoremove
--yes || true
54 # Dropping documentation, localization, i18n files, etc
55 rm -rf /usr
/share
/doc
/*
56 rm -rf /usr
/share
/locale
/*
58 rm -rf /usr
/share
/i18n
/*
59 rm -rf /usr
/share
/info
/*
60 rm -rf /usr
/share
/lintian
/*
61 rm -rf /usr
/share
/common-licenses
/*
62 rm -rf /usr
/share
/mime
/*
64 # Dropping reportbug scripts
67 # Drop udev hwdb not required on a stripped system
68 rm -rf /lib
/udev
/hwdb.bin
/lib
/udev
/hwdb.d
/*
70 # Drop all gconv conversions && binaries
72 rm -rf usr
/sbin
/iconvconfig
73 rm -rf usr
/lib
/*/gconv
/
75 # Remove libusb database
76 rm -rf usr
/sbin
/update-usbids
77 rm -rf var
/lib
/usbutils
/usb.ids
78 rm -rf usr
/share
/misc
/usb.ids
80 #######################################################################
81 # Crush into a minimal production image to be deployed via some type of image
83 # IMPORTANT: The Debian system is not longer functional at this point,
84 # for example, apt and dpkg will stop working
86 UNNEEDED_PACKAGES
="apt libapt-pkg5.0 "\
87 "ncurses-bin ncurses-base libncursesw5 libncurses5 "\
89 "debconf libdebconfclient0 "\
90 "e2fsprogs e2fslibs libfdisk1 "\
93 "init-system-helpers "\
97 "libsemanage1 libsemanage-common "\
103 "debian-archive-keyring "\
105 # Removing unneeded packages
106 for PACKAGE
in ${UNNEEDED_PACKAGES}
108 echo "Forcing removal of ${PACKAGE}"
109 if ! dpkg
--purge --force-remove-essential --force-depends "${PACKAGE}"
111 echo "WARNING: ${PACKAGE} isn't installed"
115 # Show what's left package-wise before dropping dpkg itself
116 COLUMNS
=300 dpkg-query
-W --showformat='${Installed-Size;10}\t${Package}\n' |
sort -k1,1n
119 dpkg
--purge --force-remove-essential --force-depends dpkg
121 # No apt or dpkg, no need for its configuration archives
125 # Drop directories not part of ostree
126 # Note that /var needs to exist as ostree bind mounts the deployment /var over
128 rm -rf var
/* opt srv share
130 # ca-certificates are in /etc drop the source
131 rm -rf usr
/share
/ca-certificates
133 # No bash, no need for completions
134 rm -rf usr
/share
/bash-completion
136 # No zsh, no need for comletions
137 rm -rf usr
/share
/zsh
/vendor-completions
139 # drop gcc-6 python helpers
140 rm -rf usr
/share
/gcc-6
142 # Drop sysvinit leftovers
144 rm -rf etc
/rc
[0-6S].d
146 # Drop upstart helpers
149 # Various xtables helpers
150 rm -rf usr
/lib
/xtables
153 # TODO: only remaining locale is actually "C". Should we really remove it?
154 rm -rf usr
/lib
/locale
/*
162 # Systemd dns resolver
163 find usr etc
-name '*systemd-resolve*' -prune -exec rm -r {} \
;
165 # Systemd network configuration
166 find usr etc
-name '*networkd*' -prune -exec rm -r {} \
;
169 find usr etc
-name '*timesyncd*' -prune -exec rm -r {} \
;
171 # systemd hw database manager
172 find usr etc
-name '*systemd-hwdb*' -prune -exec rm -r {} \
;
175 find usr etc
-name '*fuse*' -prune -exec rm -r {} \
;
177 # lsb init function leftovers
180 # Only needed when adding libraries
181 rm usr
/sbin
/ldconfig
*
186 # Remove pam module to authenticate against a DB
187 # plus libdb-5.3.so that is only used by this pam module
188 rm usr
/lib
/*/security
/pam_userdb.so
189 rm usr
/lib
/*/libdb-5.3.so
191 # remove NSS support for nis, nisplus and hesiod
192 rm usr
/lib
/*/libnss_hesiod
*
193 rm usr
/lib
/*/libnss_nis
*