3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Delete all Linux headers
17 |
awk '{ print $2 }' \
18 |
grep 'linux-headers' \
19 |
xargs apt-get
-y purge
;
21 # Remove specific Linux kernels, such as linux-image-3.11.0-15-generic but
22 # keeps the current kernel and does not touch the virtual packages,
23 # e.g. 'linux-image-generic', etc.
25 |
awk '{ print $2 }' \
26 |
grep 'linux-image-.*-generic' \
27 |
grep -v `uname -r` \
28 |
xargs apt-get
-y purge
;
32 |
awk '{ print $2 }' \
34 |
xargs apt-get
-y purge
;
36 # Delete development packages
38 |
awk '{ print $2 }' \
40 |
xargs apt-get
-y purge
;
42 # delete docs packages
44 |
awk '{ print $2 }' \
46 |
xargs apt-get
-y purge
;
48 # Delete X11 libraries
49 apt-get
-y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6
;
51 # Delete obsolete networking
52 apt-get
-y purge ppp pppconfig pppoeconf
;
55 apt-get
-y purge popularity-contest installation-report command-not-found friendly-recovery bash-completion fonts-ubuntu-font-family-console laptop-detect
;
57 # 19.10+ don't have this package so fail gracefully
58 apt-get
-y purge command-not-found-data || true
;
60 # Exlude the files we don't need w/o uninstalling linux-firmware
61 echo "==> Setup dpkg excludes for linux-firmware"
62 cat <<_EOF_ | cat >> /etc/dpkg/dpkg.cfg.d/excludes
64 path-exclude=/lib/firmware/*
65 path-exclude=/usr/share/doc/linux-firmware/*
69 # Delete the massive firmware packages
70 rm -rf /lib
/firmware
/*
71 rm -rf /usr
/share
/doc
/linux-firmware
/*
73 apt-get
-y autoremove
;
77 rm -rf /usr
/share
/doc
/*
80 find /var
/cache
-type f
-exec rm -rf {} \
;
82 # truncate any logs that have built up during the install
83 find /var
/log
-type f
-exec truncate
--size=0 {} \
;
85 # Blank netplan machine-id (DUID) so machines get unique ID generated on boot.
86 truncate
-s 0 /etc
/machine-id
88 # remove the contents of /tmp and /var/tmp
89 rm -rf /tmp
/* /var
/tmp
/*
91 # clear the history so our install isn't there
93 rm -f /root
/.wget-hsts