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