blob: 3ca684ea342ccdab0e26afaa5781be59438c8d3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#!/bin/bash
export LANG=C.UTF-8
export HOSTNAME="arch-base"
export BOOT_LANG=en_GB.UTF-8
export TIMEZONE=UTC
export PKG_REMOVED=()
declare -a LOCALES=(
"en_GB.UTF-8 UTF-8"
"en_US.UTF-8 UTF-8"
)
strip_bin() {
find /usr/bin -type f \( -perm -0100 \) -print |
xargs file |
sed -n '/executable .*not stripped/s/: TAB .*//p' |
xargs -rt strip --strip-unneeded
}
strip_lib() {
find /usr/lib -type f \( -perm -0100 \) -print |
xargs file |
sed -n '/executable .*not stripped/s/: TAB .*//p' |
xargs -rt strip --strip-unneeded
}
bootstrap_clean_common() {
echo ""
echo "==> cleaning ..."
echo ">>> stripping binaries"
strip_bin
echo ">>> stripping libraries"
strip_lib
rm -rf /usr/share/doc/*
rm -rf /usr/share/licenses/*
rm -rf /usr/share/locale/*
rm -rf /usr/share/man/*
rm -rf /usr/share/info/*
rm -rf /var/cache/pacman/pkg/*
rm -rf /var/log/*
rm -f /vars.sh
}
bootstrap_hostname() {
echo ""
echo "==> set hostname to '${HOSTNAME}' ..."
echo ${HOSTNAME} > /etc/hostname
}
bootstrap_timezone() {
echo ""
echo "==> set timezone to '${TIMEZONE}'..."
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
}
bootstrap_locales() {
echo ""
echo "==> set locales ..."
echo "#" > /etc/locale.gen
for i in "${LOCALES[@]}"; do
echo "$i" >> /etc/locale.gen
done
echo "==> generate locale ..."
/usr/bin/locale-gen
echo "==> set locale preferences ..."
echo "LANG=${BOOT_LANG}" > "$rootfs"/etc/locale.conf
echo "LC_MESSAGES=C" >> "$rootfs"/etc/locale.conf
}
bootstrap_remove_packages() {
echo ""
echo "==> remove unneeded packages ..."
for pkg in ${PKGS_REMOVED[@]}; do
echo " removing $pkg"
pacman -Rs --noconfirm $pkg
done
echo ">>> force remove packages ..."
for pkg in ${PKGS_REMOVED_FORCE[@]}; do
echo " force removing $pkg"
pacman -Rdd --noconfirm $pkg
done
}
bootstrap_clean_base() {
echo ""
echo "==> cleaning base ..."
## Remove all charmaps except UTF-8.
find /usr/share/i18n/charmaps/ \! -name "UTF-8.gz" -delete
## Remove all locales except en_GB and en_US.
find /usr/share/i18n/locales/ \! -name "en_GB" \! -name "en_US" -delete
## Remove all terminfo excetp ansi,cygwin,linux,screen-256color,vt100,vt220,
## and xterm.
find /usr/share/terminfo/ \
\! -name ansi \
\! -name cygwin \
\! -name linux \
\! -name screen-256color \
\! -name vt100 \
\! -name vt220 \
\! -name xterm \
-delete
## Remove all unneeded doc.
rm -rf /usr/share/texinfo/*
rm -rf /usr/share/zoneinfo/*
rm -rf /usr/share/iana-etc/*
rm -rf /usr/share/gtk-doc/*
rm -rf /usr/share/readline/*
rm -r /usr/share/icu/*
rm -rf /usr/lib/python2.7/test
rm -rf /usr/share/perl5
echo "==> cleaning nodejs ..."
rm -r /usr/lib/node_modules/npm/doc/*
rm -r /usr/lib/node_modules/npm/html/doc/*
rm -r /usr/lib/node_modules/npm/man/*
find /usr/lib/node_modules -name man -type d -exec rm -rf '{}' \;
find /usr/lib/node_modules -name doc -type d -exec rm -rf '{}' \;
find /usr/lib/node_modules -name html -type d -exec rm -rf '{}' \;
}
bootstrap_clean_myself() {
echo ""
echo "==> bootstrap: cleaning my self"
rm -f /_bootstrap_script.sh
rm -f /_bootstrap_post.sh
rm -f /run_bootstrap.sh
}
bootstrap_post_main() {
echo "==> post bootstrap ..."
bootstrap_hostname
bootstrap_timezone
bootstrap_locales
bootstrap_clean_common
bootstrap_clean_base
bootstrap_clean_myself
}
|