Line 0
Link Here
|
|
|
1 |
#!/bin/sh -ex |
2 |
|
3 |
cd "$WORKDIR" |
4 |
|
5 |
# stage1 need this |
6 |
mkdir -p ./image |
7 |
|
8 |
# setup stage2 as init |
9 |
mv -f ./usr/sbin/install2-init ./sbin/init |
10 |
|
11 |
# udev needed this |
12 |
ln -s /proc/mounts /etc/mtab |
13 |
|
14 |
# remove all docs |
15 |
rm -rf ./usr/share/{doc,man,info,license,gfxboot} |
16 |
|
17 |
# remove icons |
18 |
rm -rf ./usr/share/icons/{hicolor,large,mini} |
19 |
|
20 |
# remove PAM plugins |
21 |
rm -rf ./lib*/security |
22 |
|
23 |
# remove cpp |
24 |
fakechroot "$WORKDIR/" rpmquery -a cpp\* gcc\* | |
25 |
xargs -r fakechroot "$WORKDIR/" rpmi -e --nodeps -- |
26 |
|
27 |
# remove X11 dri modules |
28 |
rm -rf ./usr/lib*/X11/modules/dri |
29 |
rm -rf ./usr/lib*/X11/modules/multimedia |
30 |
rm -rf ./usr/lib*/X11/mesa_gl |
31 |
|
32 |
rm -f ./usr/lib*/X11/modules/extensions/libglx.so |
33 |
rm -f ./usr/lib*/X11/modules/extensions/libdri.so |
34 |
rm -f ./usr/lib*/X11/modules/extensions/libGLcore.so |
35 |
|
36 |
# remove unneeded kernel modules |
37 |
rm -rf ./lib/modules/*/kernel/arch |
38 |
rm -rf ./lib/modules/*/kernel/crypto |
39 |
rm -rf ./lib/modules/*/kernel/drivers/atm |
40 |
rm -rf ./lib/modules/*/kernel/drivers/char/watchdog |
41 |
rm -rf ./lib/modules/*/kernel/drivers/cpufreq |
42 |
rm -rf ./lib/modules/*/kernel/drivers/edac |
43 |
rm -rf ./lib/modules/*/kernel/drivers/firmware |
44 |
rm -rf ./lib/modules/*/kernel/drivers/hwmon |
45 |
rm -rf ./lib/modules/*/kernel/drivers/infiniband |
46 |
rm -rf ./lib/modules/*/kernel/drivers/input/{gameport,joy*} |
47 |
rm -rf ./lib/modules/*/kernel/drivers/isdn |
48 |
rm -rf ./lib/modules/*/kernel/drivers/media |
49 |
rm -rf ./lib/modules/*/kernel/drivers/mmc |
50 |
rm -rf ./lib/modules/*/kernel/drivers/mtd* |
51 |
rm -rf ./lib/modules/*/kernel/drivers/net/irda |
52 |
rm -rf ./lib/modules/*/kernel/drivers/rtc |
53 |
rm -rf ./lib/modules/*/kernel/drivers/spi |
54 |
rm -rf ./lib/modules/*/kernel/drivers/telephony |
55 |
rm -rf ./lib/modules/*/kernel/drivers/usb/{misc,mon} |
56 |
rm -rf ./lib/modules/*/kernel/drivers/video |
57 |
rm -rf ./lib/modules/*/kernel/drivers/w1 |
58 |
rm -rf ./lib/modules/*/kernel/fs/quota* |
59 |
rm -rf ./lib/modules/*/kernel/fs/9p |
60 |
rm -rf ./lib/modules/*/kernel/fs/adfs |
61 |
rm -rf ./lib/modules/*/kernel/fs/affs |
62 |
rm -rf ./lib/modules/*/kernel/fs/afs |
63 |
rm -rf ./lib/modules/*/kernel/fs/autofs |
64 |
rm -rf ./lib/modules/*/kernel/fs/autofs4 |
65 |
rm -rf ./lib/modules/*/kernel/fs/befs |
66 |
rm -rf ./lib/modules/*/kernel/fs/bfs |
67 |
rm -rf ./lib/modules/*/kernel/fs/cifs |
68 |
rm -rf ./lib/modules/*/kernel/fs/coda |
69 |
rm -rf ./lib/modules/*/kernel/fs/configfs |
70 |
rm -rf ./lib/modules/*/kernel/fs/cramfs |
71 |
rm -rf ./lib/modules/*/kernel/fs/efs |
72 |
rm -rf ./lib/modules/*/kernel/fs/exportfs |
73 |
rm -rf ./lib/modules/*/kernel/fs/freevxfs |
74 |
rm -rf ./lib/modules/*/kernel/fs/fuse |
75 |
rm -rf ./lib/modules/*/kernel/fs/hfs |
76 |
rm -rf ./lib/modules/*/kernel/fs/hfsplus |
77 |
rm -rf ./lib/modules/*/kernel/fs/hpfs |
78 |
rm -rf ./lib/modules/*/kernel/fs/jffs |
79 |
rm -rf ./lib/modules/*/kernel/fs/jffs2 |
80 |
rm -rf ./lib/modules/*/kernel/fs/lockd |
81 |
rm -rf ./lib/modules/*/kernel/fs/minix |
82 |
rm -rf ./lib/modules/*/kernel/fs/ncpfs |
83 |
rm -rf ./lib/modules/*/kernel/fs/ocfs2 |
84 |
rm -rf ./lib/modules/*/kernel/fs/qnx4 |
85 |
rm -rf ./lib/modules/*/kernel/fs/smbfs |
86 |
rm -rf ./lib/modules/*/kernel/fs/sysv |
87 |
rm -rf ./lib/modules/*/kernel/fs/udf |
88 |
rm -rf ./lib/modules/*/kernel/fs/ufs |
89 |
rm -rf ./lib/modules/*/kernel/net/*/netfilter |
90 |
rm -rf ./lib/modules/*/kernel/net/appletalk |
91 |
rm -rf ./lib/modules/*/kernel/net/ax25 |
92 |
rm -rf ./lib/modules/*/kernel/net/bluetooth |
93 |
rm -rf ./lib/modules/*/kernel/net/bridge |
94 |
rm -rf ./lib/modules/*/kernel/net/dccp |
95 |
rm -rf ./lib/modules/*/kernel/net/decnet |
96 |
rm -rf ./lib/modules/*/kernel/net/econet |
97 |
rm -rf ./lib/modules/*/kernel/net/ipv6 |
98 |
rm -rf ./lib/modules/*/kernel/net/ipx |
99 |
rm -rf ./lib/modules/*/kernel/net/irda |
100 |
rm -rf ./lib/modules/*/kernel/net/netfilter |
101 |
rm -rf ./lib/modules/*/kernel/net/netrom |
102 |
rm -rf ./lib/modules/*/kernel/net/rose |
103 |
rm -rf ./lib/modules/*/kernel/net/sctp |
104 |
rm -rf ./lib/modules/*/kernel/net/tipc |
105 |
rm -rf ./lib/modules/*/kernel/net/x25 |
106 |
rm -rf ./lib/modules/*/kernel/sound |
107 |
|
108 |
# remove blacklisted kernel modules |
109 |
sed -n 's/^blacklist[[:space:]]\+\([^[:space:]]\+\).*/\1/p' ./etc/modprobe.d/* | |
110 |
while read i; do |
111 |
/.host/find ./lib/modules/ -type f -name "$i.ko" -delete |
112 |
done |
113 |
|
114 |
# remove rpm db |
115 |
rm -rf ./var/lib/rpm/* |
116 |
|
117 |
# remove apt data files |
118 |
rm -rf ./var/cache/apt ./var/lib*/apt |
119 |
|
120 |
# remove unneeded translations |
121 |
/.host/find ./usr/share/locale/ -type f \! -name 'alterator*' -delete |
122 |
|
123 |
# remove non-utf8 locales |
124 |
/.host/find ./usr/lib*/locale -mindepth 1 -maxdepth 1 -type d \! -name '*.utf8' -print0 | |
125 |
xargs -r0 rm -rf -- |
126 |
|
127 |
# run depmod |
128 |
if [ -x /usr/bin/fakechroot ]; then |
129 |
cat > .script.sh <<-EOF |
130 |
#!/bin/sh -x |
131 |
for i in /lib*/modules/*; do |
132 |
/sbin/depmod -a -F /boot/System.map-\${i##*/} \${i##*/} |
133 |
done |
134 |
EOF |
135 |
chmod +x .script.sh |
136 |
fakechroot /sbin/chroot "$WORKDIR/" /.script.sh |
137 |
rm -f .script.sh |
138 |
fi |
139 |
|
140 |
# remove ogfs |
141 |
rm -f ./lib*/evms/*/ogfs* |
142 |
|
143 |
# remove kernel images |
144 |
rm -rf ./boot/* |