summaryrefslogtreecommitdiffstats
path: root/upd-instroot
blob: b40bf44c28af215a871338a82eab601b760ff57b (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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash

if [ -z "$1" -o ! -d "$1" ]; then
	echo "$0: updates instimage from a Red Hat RPMS directory"
	echo "usage: $0 <dir>"
	exit 1
fi

HOMEDIR=`pwd`
echo HOMEDIR $HOMEDIR

# remove all non unused python files
pythondeps() {
        DIR=$1

	mkdir -p $DIR/proc
	mount -t proc /proc $DIR/proc
	(chroot $DIR /usr/bin/anaconda -m dir://mnt/source --test --text --traceonly; \
	cd $DIR; find usr/lib/python* -type f | sed 's,^,/,' ) | sort | uniq -u |
	sed s,^,./, | while read fn; do
  	    [ ! -d $DIR/$fn ] && rm $DIR/$fn
  	done
	umount $DIR/proc
	rmdir $DIR/proc
}

SRC=$1/RedHat/RPMS

cd ../trees/hdimage
DEST=$PWD
cd -

cd ../../../RedHat/instimage
DESTGR=$PWD
cd -

echo "DEST is $DEST"
echo "DESTGR is $DESTGR"

PACKAGES="glibc-2 ldconfig setup e2fsprogs-1 XFree86-libs XFree86-SVGA
          XFree86-S3 XFree86-S3V XFree86-Mach32 XFree86-Mach64
          XFree86-FBDev XFree86-75dpi-fonts XFree86-100dpi-fonts XFree86-I128
          XFree86-3DLabs XFree86-VGA16 XFree86-Sun
	  XFree86-3. xpm-3 glib- gtk+-
          gnome-libs python-1 newt imlib-1 libpng libtiff libjpeg-
          libtermcap-2 zlib rpm rpm-devel ash- bash- pygtk- pygnome-
          util-linux procps esound-0 audiofile-0 kernel-pcmcia-cs
          Xconfigurator raidtools-"

KEEPFILE=/tmp/keepfile.$$
cat > $KEEPFILE <<EOF
sbin/mkfs.ext2
sbin/mke2fs
sbin/mkswap
sbin/probe
sbin/fdisk
sbin/mkraid
sbin/raidstart
etc/nsswitch.conf
lib/ld-*
lib/libc*
lib/libm*
lib/libcrypt*
lib/libdl*
lib/libdb.so.2
lib/libdb1*
lib/libnsl*
lib/libnss_files*
lib/libpthread*
lib/libresolv*
lib/libNoVersion*
etc/group
etc/passwd
etc/services
usr/bin/python*
usr/lib/python*
usr/lib/libnewt*
lib/libtermcap*
usr/lib/libz.*
usr/lib/rpm/rpmpopt
usr/lib/rpm/macros
usr/lib/rpm/rpmrc
usr/lib/librpm.so*
bin/ash
bin/mkfs*
bin/fdisk*
sbin/badblocks
lib/libcom_err*
lib/libe2p*
lib/libext2fs*
lib/libss*
lib/libuuid*
usr/X11R6/lib/X11/Cards
usr/X11R6/share/Xconfigurator/MonitorsDB
EOF

KEEPFILEGR=/tmp/keepfilegr.$$
cp $KEEPFILE $KEEPFILEGR
cat >> $KEEPFILEGR <<EOF
bin/bash
bin/ps
lib/libproc*
lib/libutil*
lib/libnss_dns*
bin/rpm
usr/lib/rpm/rpmpopt
etc/im_palette.pal
etc/imrc
usr/lib/libesd*
usr/lib/libaudio*
usr/lib/libImlib*
usr/lib/gdkimlib*
usr/lib/libimlib-pnm*
usr/lib/libimlib-xpm*
usr/lib/libimlib-png*
usr/lib/libpng*
usr/lib/libtiff*
usr/lib/libjpeg*
usr/lib/libzvt*
usr/sbin/gnome-pty-helper
usr/X11R6/lib/libICE*
usr/X11R6/lib/libSM*
usr/X11R6/lib/libX11*
usr/X11R6/lib/libXext*
usr/X11R6/bin/XF86_3DLabs
usr/X11R6/bin/XF86_I128
usr/X11R6/bin/XF86_FBDev
usr/X11R6/bin/XF86_Mach32
usr/X11R6/bin/XF86_Mach64
usr/X11R6/bin/XF86_SVGA
usr/X11R6/bin/XF86_S3
usr/X11R6/bin/XF86_S3V
usr/X11R6/bin/XF86_VGA16
usr/X11R6/bin/XsunMono
usr/X11R6/bin/Xsun
usr/X11R6/bin/Xsun24
usr/X11R6/bin/Xtest
usr/X11R6/lib/X11/fonts/75dpi/cour*
usr/X11R6/lib/X11/fonts/75dpi/helv*
usr/X11R6/lib/X11/fonts/75dpi/tim*
usr/X11R6/lib/X11/fonts/75dpi/fonts*
usr/X11R6/lib/X11/fonts/misc/6x*
usr/X11R6/lib/X11/fonts/misc/9x*
usr/X11R6/lib/X11/fonts/misc/fonts*
usr/X11R6/lib/X11/fonts/misc/cursor*
usr/X11R6/lib/X11/fonts/misc/olcursor*
usr/X11R6/lib/X11/locale/*
usr/X11R6/lib/X11/xkb/*
usr/X11R6/lib/X11/rgb*
usr/X11R6/lib/X11/XKeysymDB
usr/X11R6/lib/libXpm*
usr/lib/libglib*
usr/lib/libthread*
etc/gtk/gtkrc
usr/lib/libgtk*
usr/lib/libgdk*
usr/lib/libart*
usr/lib/libgnome*
usr/lib/libgmodule*
usr/lib/libgthread*
usr/lib/libgnomesupport*
usr/lib/libgnomeui*
usr/lib/libgnorba*
usr/lib/libgnorbagtk*
usr/lib/libgtkxmhtml*
usr/share/pixmaps/gnome-default-dlg.png
usr/share/pixmaps/gnome-error.png
usr/share/pixmaps/gnome-info.png
usr/share/pixmaps/gnome-question.png
usr/share/pixmaps/gnome-warning.png
usr/share/pixmaps/no.xpm
usr/share/pixmaps/yes.xpm
usr/share/zoneinfo/zone.tab
usr/bin/chattr*
usr/bin/lsattr*
EOF

# sparc needs 100dpi fonts as well, otherwise
# things look ugly

if [ `uname -m | sed 's/sparc64/sparc/'` = sparc ]; then
    cat >> $KEEPFILEGR <<-EOF
usr/X11R6/lib/X11/fonts/100dpi/cour*
usr/X11R6/lib/X11/fonts/100dpi/helv*
usr/X11R6/lib/X11/fonts/100dpi/tim*
usr/X11R6/lib/X11/fonts/100dpi/fonts*
EOF
fi

for I in $PACKAGES; do
    for J in `ls $SRC/$I*`; do
	if [ "$I" != "rpm-devel" ]; then
            if ! echo $J | grep devel > /dev/null; then
	        RPMS="$RPMS $J"
            fi
        else
                RPMS="$RPMS $J"
	fi
    done
done

rm -rf $DEST; mkdir -p $DEST/usr/sbin
rm -rf $DESTGR; mkdir -p $DESTGR/usr/sbin

for n in $RPMS; do 
    echo "expanding $n"
    rpm2cpio $n | (cd $DEST; cpio -E $KEEPFILE --quiet -iumd)
    rpm2cpio $n | (cd $DESTGR; cpio -E $KEEPFILEGR --quiet -iumd)
done

for I in $DESTGR/usr/X11R6/lib/X11/fonts/*; do
    mkfontdir $I
done

rm -f $KEEPFILE $KEEPFILEGR

make install-hd DESTDIR=$DEST > /dev/null
make install DESTDIR=$DESTGR > /dev/null

for p in $DEST $DESTGR; do
	find $p -type d | xargs chmod 755

	if [ -f $p/bin/bash ]; then
	    rm -f $p/bin/ash
	    ln -s bash $p/bin/sh
	else
	    ln -s ash $p/bin/sh
	fi

	(cd $p/bin; tar cSpf - .) | (cd $p/usr/bin; tar xSpf -)
	(cd $p/sbin; tar cSpf - .) | (cd $p/usr/sbin; tar xSpf -)
	rm -rf $p/bin
	rm -rf $p/sbin

	rm -rf $p/boot $p/home $p/root $p/tmp

	cp /sbin/ldconfig $p
	# Must create ld.so.conf, because ldconfig does not cache
	# dirs specified on the command line.
	touch $p/etc/ld.so.conf
	[ -d $p/usr/X11R6/lib ] && echo /usr/X11R6/lib > $p/etc/ld.so.conf
	(cd $p; chroot $p ./ldconfig )
	rm -f $p/ldconfig $p/etc/ld.so.conf

	for l in `find $p -exec file {} \; | sed -n 's/^\([^:]*\):.*ELF.*$/\1/p'`; do
	    # Strip dwarf stuff, symbols and unneeded not-alloced sections
	    strip $l -R .comment -R .note `objdump -h $l | \
		sed -n 's/^.*\(\.gnu\.warning\.[^ ]*\) .*$/-R \1/p'`
	done
	find $p -name "*.a" | xargs rm -rf

	(cd /usr/share/zoneinfo; find . -type f -or -type l | 
		grep '^./[A-Z]' | sort | sed 's/^..//' | 
		gzip -9) > $p/usr/lib/timezones.gz
done

pythondeps $DEST

for p in $DEST $DESTGR; do
	find $p -name "*.py" | while read fn; do
	    if [ -f ${fn}c ]; then
		rm -f ${fn}c
	    fi
	    if [ -f ${fn}o ]; then
		rm -f ${fn}o
	    fi
	done
done

# Xserver needs a place to put the compiled xkb maps.
rm -rf $DESTGR/usr/X11R6/lib/X11/xkb/compiled
ln -s /tmp $DESTGR/usr/X11R6/lib/X11/xkb/compiled

# this is only for the minimal second stage

	cd $DEST/usr/lib
	find python1.5 | cpio --quiet -H crc -o | gzip -9 > python1.5.cgz
	rm -rf python1.5
	ls libnewt* libslang* | cpio --quiet -H crc -o | 
		gzip -9 > slang-newt.cgz
	rm -f libnewt* libslang*

	cd $DEST/usr/bin
	echo python1.5 | cpio --quiet -H crc -o | gzip -9 > python1.5.cgz
	rm -f python python1.5
	ln -s python1.5 python
	mv anaconda anaconda.real

	cd $DEST/lib
	ls    libcom* libcrypt* libdl* libe2p* libext2* libm* libnss* libnsl* \
	      libpthread* libss* libtermcap* libuuid* \
			| cpio --quiet -H crc -o | gzip -9 > libs.cgz
	rm -f libcom* libcrypt* libdl* libe2p* libext2* libm* libnss* libnsl* \
	      libpthread* libss* libtermcap* libuuid*

	cd $DEST/usr
	find X11R6 | cpio --quiet -H crc -o | gzip -9 > X11R6.cgz
	rm -rf X11R5

	cp -a $HOMEDIR/anaconda-stub $DEST/usr/bin/anaconda