@@ -1,98 +1,105 | |||||
1 | # |
|
1 | # | |
2 | # Reduce system disk usage |
|
2 | # Reduce system disk usage | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | if [ "$ENABLE_IPV6" = false ] ; then |
|
8 | if [ "$ENABLE_IPV6" = false ] ; then | |
9 | "$LIB_DIR"/xtables/libip6t_ah.so |
|
9 | "$LIB_DIR"/xtables/libip6t_ah.so | |
10 | "$LIB_DIR"/xtables/libip6t_dst.so |
|
10 | "$LIB_DIR"/xtables/libip6t_dst.so | |
11 | "$LIB_DIR"/xtables/libip6t_eui64.so |
|
11 | "$LIB_DIR"/xtables/libip6t_eui64.so | |
12 | "$LIB_DIR"/xtables/libip6t_frag.so |
|
12 | "$LIB_DIR"/xtables/libip6t_frag.so | |
13 | "$LIB_DIR"/xtables/libip6t_hbh.so |
|
13 | "$LIB_DIR"/xtables/libip6t_hbh.so | |
14 | "$LIB_DIR"/xtables/libip6t_hl.so |
|
14 | "$LIB_DIR"/xtables/libip6t_hl.so | |
15 | "$LIB_DIR"/xtables/libip6t_HL.so |
|
15 | "$LIB_DIR"/xtables/libip6t_HL.so | |
16 | "$LIB_DIR"/xtables/libip6t_icmp6.so |
|
16 | "$LIB_DIR"/xtables/libip6t_icmp6.so | |
17 | "$LIB_DIR"/xtables/libip6t_ipv6header.so |
|
17 | "$LIB_DIR"/xtables/libip6t_ipv6header.so | |
18 | "$LIB_DIR"/xtables/libip6t_LOG.so |
|
18 | "$LIB_DIR"/xtables/libip6t_LOG.so | |
19 | "$LIB_DIR"/xtables/libip6t_mh.so |
|
19 | "$LIB_DIR"/xtables/libip6t_mh.so | |
20 | "$LIB_DIR"/xtables/libip6t_REJECT.so |
|
20 | "$LIB_DIR"/xtables/libip6t_REJECT.so | |
21 | "$LIB_DIR"/xtables/libip6t_rt.so |
|
21 | "$LIB_DIR"/xtables/libip6t_rt.so | |
22 | "$LIB_DIR"/xtables/libip6t_DNAT.so |
|
22 | "$LIB_DIR"/xtables/libip6t_DNAT.so | |
23 | "$LIB_DIR"/xtables/libip6t_DNPT.so |
|
23 | "$LIB_DIR"/xtables/libip6t_DNPT.so | |
24 | "$LIB_DIR"/xtables/libip6t_MASQUERADE.so |
|
24 | "$LIB_DIR"/xtables/libip6t_MASQUERADE.so | |
25 | "$LIB_DIR"/xtables/libip6t_NETMAP.so |
|
25 | "$LIB_DIR"/xtables/libip6t_NETMAP.so | |
26 | "$LIB_DIR"/xtables/libip6t_REDIRECT.so |
|
26 | "$LIB_DIR"/xtables/libip6t_REDIRECT.so | |
27 | "$LIB_DIR"/xtables/libip6t_SNAT.so |
|
27 | "$LIB_DIR"/xtables/libip6t_SNAT.so | |
28 | "$LIB_DIR"/xtables/libip6t_SNPT.so |
|
28 | "$LIB_DIR"/xtables/libip6t_SNPT.so | |
29 | fi |
|
29 | fi | |
30 | # Reduce the image size by various operations |
|
30 | # Reduce the image size by various operations | |
31 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
31 | if [ "$ENABLE_REDUCE" = true ] ; then | |
32 | if [ "$REDUCE_APT" = true ] ; then |
|
32 | if [ "$REDUCE_APT" = true ] ; then | |
33 | # Install dpkg configuration file |
|
33 | # Install dpkg configuration file | |
34 | if [ "$REDUCE_DOC" = true ] || [ "$REDUCE_MAN" = true ] ; then |
|
34 | if [ "$REDUCE_DOC" = true ] || [ "$REDUCE_MAN" = true ] ; then | |
35 | install_readonly files/dpkg/01nodoc "${ETC_DIR}/dpkg/dpkg.cfg.d/01nodoc" |
|
35 | install_readonly files/dpkg/01nodoc "${ETC_DIR}/dpkg/dpkg.cfg.d/01nodoc" | |
36 | fi |
|
36 | fi | |
37 |
|
37 | |||
38 | # Install APT configuration files |
|
38 | # Install APT configuration files | |
39 | install_readonly files/apt/02nocache "${ETC_DIR}/apt/apt.conf.d/02nocache" |
|
39 | install_readonly files/apt/02nocache "${ETC_DIR}/apt/apt.conf.d/02nocache" | |
40 | install_readonly files/apt/03compress "${ETC_DIR}/apt/apt.conf.d/03compress" |
|
40 | install_readonly files/apt/03compress "${ETC_DIR}/apt/apt.conf.d/03compress" | |
41 | install_readonly files/apt/04norecommends "${ETC_DIR}/apt/apt.conf.d/04norecommends" |
|
41 | install_readonly files/apt/04norecommends "${ETC_DIR}/apt/apt.conf.d/04norecommends" | |
42 |
|
42 | |||
43 | # Remove APT cache files |
|
43 | # Remove APT cache files | |
44 | rm -fr "${R}/var/cache/apt/pkgcache.bin" |
|
44 | rm -fr "${R}/var/cache/apt/pkgcache.bin" | |
45 | rm -fr "${R}/var/cache/apt/srcpkgcache.bin" |
|
45 | rm -fr "${R}/var/cache/apt/srcpkgcache.bin" | |
46 | fi |
|
46 | fi | |
47 |
|
47 | |||
48 | # Remove all doc files |
|
48 | # Remove all doc files | |
49 | if [ "$REDUCE_DOC" = true ] ; then |
|
49 | if [ "$REDUCE_DOC" = true ] ; then | |
50 | find "${R}/usr/share/doc" -depth -type f ! -name copyright -print0 | xargs -0 rm || true |
|
50 | find "${R}/usr/share/doc" -depth -type f ! -name copyright -print0 | xargs -0 rm || true | |
51 | find "${R}/usr/share/doc" -empty -print0 | xargs -0 rmdir || true |
|
51 | find "${R}/usr/share/doc" -empty -print0 | xargs -0 rmdir || true | |
52 | fi |
|
52 | fi | |
53 |
|
53 | |||
54 | # Remove all man pages and info files |
|
54 | # Remove all man pages and info files | |
55 | if [ "$REDUCE_MAN" = true ] ; then |
|
55 | if [ "$REDUCE_MAN" = true ] ; then | |
56 | rm -rf "${R}/usr/share/man" "${R}/usr/share/groff" "${R}/usr/share/info" "${R}/usr/share/lintian" "${R}/usr/share/linda" "${R}/var/cache/man" |
|
56 | rm -rf "${R}/usr/share/man" "${R}/usr/share/groff" "${R}/usr/share/info" "${R}/usr/share/lintian" "${R}/usr/share/linda" "${R}/var/cache/man" | |
57 | fi |
|
57 | fi | |
58 |
|
58 | |||
59 | # Remove all locale translation files |
|
59 | # Remove all locale translation files | |
60 | if [ "$REDUCE_LOCALE" = true ] ; then |
|
60 | if [ "$REDUCE_LOCALE" = true ] ; then | |
61 | find "${R}/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' -print0 | xargs -0 rm -r |
|
61 | find "${R}/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' -print0 | xargs -0 rm -r | |
62 | fi |
|
62 | fi | |
63 |
|
63 | |||
64 | # Remove hwdb PCI device classes (experimental) |
|
64 | # Remove hwdb PCI device classes (experimental) | |
65 | if [ "$REDUCE_HWDB" = true ] ; then |
|
65 | if [ "$REDUCE_HWDB" = true ] ; then | |
66 | rm -fr "/lib/udev/hwdb.d/20-pci-*" |
|
66 | rm -fr "/lib/udev/hwdb.d/20-pci-*" | |
67 | fi |
|
67 | fi | |
68 |
|
68 | |||
69 | # Replace bash shell by dash shell (experimental) |
|
69 | # Replace bash shell by dash shell (experimental) | |
70 | if [ "$REDUCE_BASH" = true ] ; then |
|
70 | if [ "$REDUCE_BASH" = true ] ; then | |
71 | # Purge bash and update alternatives |
|
71 | # Purge bash and update alternatives | |
72 | echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash |
|
72 | echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash | |
73 | chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100 |
|
73 | chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100 | |
74 | fi |
|
74 | fi | |
75 |
|
75 | |||
76 | # Remove sound utils and libraries |
|
76 | # Remove sound utils and libraries | |
77 | if [ "$ENABLE_SOUND" = false ] ; then |
|
77 | if [ "$ENABLE_SOUND" = false ] ; then | |
|
78 | if [ "$ENABLE_BLUETOOTH" = false ] ; then | |||
78 |
|
|
79 | chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data | |
|
80 | else | |||
|
81 | chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 | |||
|
82 | fi | |||
79 | fi |
|
83 | fi | |
80 |
|
84 | |||
81 | # Remove GPU kernels |
|
85 | # Remove GPU kernels | |
82 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
86 | if [ "$ENABLE_MINGPU" = true ] ; then | |
83 | rm -f "${BOOT_DIR}/start.elf" |
|
87 | rm -f "${BOOT_DIR}/start.elf" | |
84 | rm -f "${BOOT_DIR}/fixup.dat" |
|
88 | rm -f "${BOOT_DIR}/fixup.dat" | |
85 | rm -f "${BOOT_DIR}/start_x.elf" |
|
89 | rm -f "${BOOT_DIR}/start_x.elf" | |
86 | rm -f "${BOOT_DIR}/fixup_x.dat" |
|
90 | rm -f "${BOOT_DIR}/fixup_x.dat" | |
87 | fi |
|
91 | fi | |
88 |
|
92 | |||
89 | # Remove kernel and initrd from /boot (already in /boot/firmware) |
|
93 | # Remove kernel and initrd from /boot (already in /boot/firmware) | |
90 | if [ "$BUILD_KERNEL" = false ] ; then |
|
94 | if [ "$BUILD_KERNEL" = false ] ; then | |
91 | rm -f "${R}/boot/vmlinuz-*" |
|
95 | rm -f "${R}/boot/vmlinuz-*" | |
92 | rm -f "${R}/boot/initrd.img-*" |
|
96 | rm -f "${R}/boot/initrd.img-*" | |
93 | fi |
|
97 | fi | |
94 |
|
98 | |||
|
99 | #Reduce BOOT | |||
|
100 | #Only necessary files for my gen pi | |||
|
101 | ||||
95 | # Clean APT list of repositories |
|
102 | # Clean APT list of repositories | |
96 | rm -fr "${R}/var/lib/apt/lists/*" |
|
103 | rm -fr "${R}/var/lib/apt/lists/*" | |
97 | chroot_exec apt-get -qq -y update |
|
104 | chroot_exec apt-get -qq -y update | |
98 | fi |
|
105 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant