summaryrefslogtreecommitdiffstats
path: root/scripts/upd-instroot
blob: 6d4279bbfeef613ab8f5811f7718e0ccda8031c6 (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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
#!/bin/bash

ORIGDIR=`pwd`
COMPONENT=""

if [ "$1" == "--comp" ]; then
    COMPONENT=$2
    shift; shift
fi

if [ -z "$1" ]; then
	echo "upd-instroot: updates instimage from a Red Hat RPMS directory"
	echo "usage:        $0 --comp <comp> <packagedir> [templatedir] [instroot]"
	exit 1
fi

if [ ! -d $1 ]; then
	if [ -z "$ARCH" ]; then
		echo "ARCH must be set" >&2
		exit 1
	fi
	LATEST="latest --arch $ARCH"
fi

PACKAGEDIR=$1

if [ -z "$ARCH" ]; then
	ARCH=`rpm -qp --qf "%{ARCH}" $PACKAGEDIR/anaconda-runtime*.rpm`
fi

if [ $ARCH = x86_64 ]; then
    LIBDIR=lib64
else
    LIBDIR=lib
fi

NEEDGR=yes

prunePackageList() {
	PACKAGEPATH=$1
	PACKAGES="$2"

	if [ -n "$LATEST" ]; then
	    $LATEST $PACKAGEPATH $PACKAGES
	    if [ $? != 0 ]; then
		$LATEST $PACKAGEPATH $PACKAGES >&2
		kill -9 $$
	    fi
		
	    return
	fi

	PATTERN=""
	PACKAGEFILES=""
	for PKG in $PACKAGES; do
	    PATTERN="${PATTERN:+${PATTERN}|}(^$PKG )"
	    PACKAGEFILES="$PACKAGEFILES $(ls $PACKAGEPATH/${PKG}*{${ARCH},noarch}.rpm 2>/dev/null)"
	done

	# gtk+, enough said
	PATTERN=$(echo $PATTERN | sed 's,[\+\*],\\&,g')

	PACKAGEFILES=$(ls $PACKAGEFILES | sort -u)

	rpm --qf "%{NAME} $PACKAGEPATH/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\n" \
		-qp $PACKAGEFILES  | egrep "$PATTERN"  | sed 's/.* //' 
}

expandPackageSet() {
    RPMS=$1
    PKGDEST=$2
    KEEPFILES=$3

    for n in $RPMS; do 
	echo -ne "\rExpanding packages..." $(basename $n)
	if [ $(rpm -qp --qf '%{NAME}' $n) = "glibc-common" ] ; then
	    GLIBC=$n
	fi 
	rpm2cpio $n | (cd $PKGDEST; cpio -E $KEEPFILES --quiet -iumd)
	echo -ne "\rExpanding packages..." "$(basename $n | sed 's/./ /g')"
    done
}

if [ -z "$2" ]; then
    DEST=/tmp/upd-instroot
else
    DEST=$2
fi

if [ -z "$3" ]; then
    DESTGR=/tmp/upd-instroot
else
    DESTGR=$3
fi

rm -rf $DEST $DESTGR
mkdir -p $DEST
mkdir -p $DESTGR

PACKAGES="glibc glibc-common setup openssl python python2 newt libtermcap zlib
	 ash kon2 e2fsprogs util-linux raidtools popt mount procps rpm
	 XFree86 Xconfigurator anaconda anaconda-runtime kudzu-devel
	 kudzu hwdata db3 bzip2 bzip2-libs dosfstools pciutils 
	 reiserfs-utils parted busybox-anaconda rpm404-python anaconda-help booty
         hdparm lvm librpm404 rhpl libxml2 libxml2-python rdate"

if [ $ARCH = x86_64 ]; then
    PACKAGES="$PACKAGES libgcc libstdc++"
fi

if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
    PACKAGES="$PACKAGES kernel-pcmcia-cs kernel-utils"
fi

if [ $ARCH = ia64 ]; then
    PACKAGES="$PACKAGES elilo slang"
fi

if [ $ARCH = s390 -o $ARCH = s390x ]; then
    PACKAGES="$PACKAGES s390utils oco binutils s390installer pdksh wget 
	sed net-tools inetd openssh openssh-server fileutils modutils
	initscripts mount gawk xauth
	portmap textutils sh-utils telnet-server login ssh_keys"
fi

# xpm is missing

# Some packages are listed twice, but that's okay

PACKAGESGR="anaconda XFree86-libs imlib libpng libtiff libjpeg
           XFree86-S3 XFree86-SVGA XFree86-75dpi-fonts
           XFree86-ISO8859-2-75dpi-fonts glib2 gtk2
           XFree86-ISO8859-9-75dpi-fonts esound audiofile libgnome
           XFree86-100dpi-fonts fonts-ISO8859-2 fonts-ISO8859-9
           XFree86-xfs e2fsprogs fileutils glibc glibc-common rsh less
           ftp readline gzip popt specspo util-linux rpm librpm404
           open grep net-tools traceroute tar procps textutils sed
           ncurses bash cpio mt-st iputils sh-utils
           XFree86 Xconfigurator gnome-python2 pygtk2 gdk-pixbuf 
           XFree86-KOI8-R XFree86-KOI8-R-75dpi-fonts pciutils pam 
           reiserfs-utils atk pango freetype gnome-python2-canvas 
           libgnomecanvas libart_lgpl vte
           anaconda-images anaconda-help hdparm XFree86-base-fonts
           ttfonts-ko taipeifonts XFree86-ISO8859-15-75dpi-fonts rhpl
           redhat-config-keyboard Xft fontconfig expat redhat-artwork
           ttfonts-ja ttfonts-zh_TW bitmap-fonts-cjk urw-fonts rdate 
           comps-extras"

if [ -z "$NEEDGR" ]; then
    PACKAGESGR="bash"
fi

PACKAGES="$PACKAGES db1 db2"
if [ $ARCH != ia64 ]; then
    PACKAGESGR="$PACKAGESGR mtools pine modutils"
fi

if [ $ARCH = sparc ]; then
    PACKAGESGR="$PACKAGESGR XFree86-3DLabs XFree86-Mach64 tilo silo"
fi

if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
    PACKAGESGR="$PACKAGESGR XFree86-3DLabs XFree86-8514 XFree86-AGX
	       XFree86-FBDev XFree86-I128 XFree86-Mach32
	       XFree86-Mach64 XFree86-Mach8 XFree86-Mono XFree86-P9000
	       XFree86-S3 XFree86-S3V XFree86-SVGA XFree86-VGA16
	       XFree86-W32 syslinux" 
fi

if [ $ARCH = alpha ]; then
    PACKAGESGR="$PACKAGESGR XFree86-3DLabs XFree86-Mono XFree86-P9000
                XFree86-S3 XFree86-SVGA aboot"
fi

if [ $ARCH = x86_64 ]; then
    PACKAGES="$PACKAGES libgcc libstdc++"
fi

if [ $ARCH = ia64 ]; then
    PACKAGESGR="$PACKAGESGR elilo slang"
fi

if [ $ARCH = s390 -o $ARCH = s390x ]; then
    PACKAGESGR="$PACKAGESGR s390utils oco binutils s390installer pdksh 
	sed net-tools inetd openssh openssh-server fileutils login 
	wget initscripts xauth
	modutils portmap textutils openssl telnet-server strace ssh_keys"
fi

KEEPFILE=/tmp/keepfile.$$
cat > $KEEPFILE <<EOF
boot/efi/EFI/redhat/elilo.efi
bin/ash
bin/fdisk*
bin/mkfs*
etc/group
etc/nsswitch.conf
etc/passwd
etc/protocols
etc/services
$LIBDIR/ld-*
$LIBDIR/libc*
$LIBDIR/libcom_err*
$LIBDIR/libcrypt*
$LIBDIR/libdb-*
$LIBDIR/libdb-3.0
$LIBDIR/libdb.so.2
$LIBDIR/libdb.so.3
$LIBDIR/libdb1*
$LIBDIR/libdl*
$LIBDIR/libe2p*
$LIBDIR/libext2fs*
$LIBDIR/libgcc*
$LIBDIR/liblvm-10.so*
$LIBDIR/libm[-.]*
$LIBDIR/libnsl*
$LIBDIR/libnss_dns*
$LIBDIR/libnss_files*
$LIBDIR/libpthread*
$LIBDIR/libresolv*
$LIBDIR/librt[-.]*
$LIBDIR/libss*
$LIBDIR/libtermcap*
$LIBDIR/libutil*
$LIBDIR/libuuid*
sbin/badblocks
sbin/clock
sbin/debugfs
sbin/e2fsadm
sbin/e2label
sbin/fdisk
sbin/hdparm
sbin/hwclock
sbin/ldconfig
sbin/lvchange
sbin/lvcreate
sbin/lvdisplay
sbin/lvextend
sbin/lvmchange
sbin/lvmcreate_initrd
sbin/lvmdiskscan
sbin/lvmsadc
sbin/lvmsar
sbin/lvreduce
sbin/lvremove
sbin/lvrename
sbin/lvscan
sbin/mkdosfs
sbin/mke2fs
sbin/busybox.anaconda
sbin/mkfs.ext2
sbin/mkfs.ext3
sbin/mkfs.jfs
sbin/mkfs.msdos
sbin/mkfs.vfat
sbin/mkreiserfs
sbin/mkraid
sbin/mkswap
sbin/parted
sbin/pvchange
sbin/pvcreate
sbin/pvdata
sbin/pvdisplay
sbin/pvmove
sbin/pvscan
sbin/probe
sbin/sfdisk
sbin/tune2fs
sbin/vgcfgbackup
sbin/vgcfgrestore
sbin/vgchange
sbin/vgck
sbin/vgcreate
sbin/vgdisplay
sbin/vgexport
sbin/vgextend
sbin/vgimport
sbin/vgmerge
sbin/vgmknodes
sbin/vgreduce
sbin/vgremove
sbin/vgrename
sbin/vgscan
sbin/vgsplit
usr/X11R6/lib/X11/Cards
usr/X11R6/share/Xconfigurator/MonitorsDB
usr/bin/python
usr/bin/python2.2
usr/bin/rdate
usr/lib/anaconda-runtime/*
usr/lib/anaconda/*
usr/lib/anaconda/installclasses/*
usr/lib/anaconda/textw/*
usr/lib/booty/*
usr/$LIBDIR/gconv/ISO8859-1.so
usr/$LIBDIR/gconv/gconv-modules
usr/$LIBDIR/libssl*
usr/$LIBDIR/libcrypto*
usr/$LIBDIR/libbz2*
usr/$LIBDIR/libdb.so.2
usr/$LIBDIR/libdb.so.3
usr/$LIBDIR/libdb1*
usr/$LIBDIR/libnewt*
usr/$LIBDIR/libparted*
usr/$LIBDIR/libpopt*
usr/$LIBDIR/librpm-*4.0.4.so*
usr/$LIBDIR/librpmdb*4.0.4.so*
usr/$LIBDIR/librpmio*4.0.4.so*
usr/$LIBDIR/libslang*
usr/$LIBDIR/libstdc++*
usr/$LIBDIR/libxml2.so*
usr/$LIBDIR/libz.*
usr/$LIBDIR/python2.2/*
usr/$LIBDIR/python2.2/site-packages/libxml2*
usr/$LIBDIR/python2.2/site-packages/*vte*
usr/$LIBDIR/python2.2/site-packages/*kudzu*
usr/$LIBDIR/python2.2/site-packages/rpmmodule.so
usr/$LIBDIR/python2.2/site-packages/partedmodule.so
usr/$LIBDIR/python2.2/site-packages/rhpl
usr/lib/rpm/macros
usr/lib/rpm/rpmpopt
usr/lib/rpm/rpmrc
usr/share/locale/*/LC_MESSAGES/anaconda.mo
usr/sbin/anaconda
usr/sbin/ddcprobe
usr/sbin/dmidecode
usr/share/anaconda/locale-list
usr/share/anaconda/anaconda.conf
usr/share/terminfo/l/linux
usr/share/doc/kon2*/terminfo.kon
usr/share/hwdata/pcitable
usr/share/hwdata/pci.ids
usr/share/hwdata/Cards
usr/share/hwdata/MonitorsDB
usr/share/rhpl/extramodes
usr/share/rhpl/vesamodes
EOF

if [ $ARCH = s390 -o $ARCH = s390x ]; then
    cat >> $KEEPFILE <<EOF
linuxrc
usr/share/terminfo/a/ansi
usr/share/terminfo/d/dumb
usr/share/terminfo/s/screen
usr/share/terminfo/v/vt100
usr/share/terminfo/v/vt102
usr/share/terminfo/x/xterm
usr/share/terminfo/x/xterm-color
usr/bin/strace
usr/bin/ldd
usr/bin/wget
usr/bin/printf
usr/bin/dasdformat
usr/bin/formatmnt
usr/bin/mountpoint
usr/bin/netsetup
usr/bin/pkgselect
usr/bin/pkgsrc
usr/bin/rdate
usr/sbin/chroot
usr/sbin/sshd
usr/sbin/glibc_post_upgrade
usr/sbin/inetd
usr/sbin/in.telnetd
sbin/busybox.anaconda
sbin/consoletype
sbin/rhsetup
sbin/ifconfig
sbin/route
sbin/portmap
sbin/fdasd
sbin/dasdfmt
sbin/swapon
sbin/swapoff
sbin/mkswap
sbin/tune2fs
bin/dd
bin/gawk-3.1.0
bin/mknod
bin/login
bin/ksh
bin/cat
bin/chmod
bin/sed
bin/sort
bin/mount
bin/umount
bin/rpm
$LIBDIR/libpam.so*
$LIBDIR/libdl.so*
$LIBDIR/libdl-*.so*
usr/$LIBDIR/libz.so*
$LIBDIR/libnsl.so*
$LIBDIR/libnsl-*.so*
$LIBDIR/libnss*
$LIBDIR/libutil.so*
$LIBDIR/libutil-*.so*
$LIBDIR/libcrypt*
$LIBDIR/libc.so*
$LIBDIR/libc-*so*
$LIBDIR/ld.so*
$LIBDIR/ld-*.so*
$LIBDIR/libresolv.so*
$LIBDIR/libresolv-*.so*
$LIBDIR/libvtoc*.so*
$LIBDIR/modules/ibm*
etc/inetd.conf
etc/ssh/*
etc/motd
etc/issue.net
usr/X11R6/bin/xauth
EOF
fi
      

KEEPFILEGR=/tmp/keepfilegr.$$
cp $KEEPFILE $KEEPFILEGR
cat >> $KEEPFILEGR <<EOF
boot/efi/EFI/redhat/elilo.efi
bin/bash
bin/cat
bin/chmod
bin/cp
bin/cpio
bin/dd
bin/df
bin/du
bin/grep
bin/gunzip
bin/gzip
bin/ln
bin/ls
bin/mkdir
bin/mt
bin/mv
bin/ping
bin/ps
bin/rm
bin/rpm
bin/sed
bin/sync
bin/tar
bin/touch
bin/umount
bin/zcat
boot/*.b
boot/bootlx
etc/gtk-2.0/gtkrc*
etc/im_palette.pal
etc/imrc
etc/pango/*
etc/fonts/*
$LIBDIR/libnss_dns*
$LIBDIR/libpam*
$LIBDIR/libproc*
sbin/depmod
sbin/debugfs
sbin/e2fsck
sbin/e2label
sbin/reiserfsck
sbin/fsck
sbin/fsck.ext2
sbin/fsck.ext3
sbin/fsck.jfs
sbin/ifconfig
sbin/insmod
sbin/lsmod
sbin/lspci
sbin/modprobe
sbin/parted
sbin/rmmod
sbin/route
sbin/silo
sbin/tune2fs
usr/X11R6/bin/XF86_3DLabs
usr/X11R6/bin/XF86_FBDev
usr/X11R6/bin/XF86_I128
usr/X11R6/bin/XF86_Mach32
usr/X11R6/bin/XF86_Mach64
usr/X11R6/bin/XF86_S3
usr/X11R6/bin/XF86_S3V
usr/X11R6/bin/XF86_SVGA
usr/X11R6/bin/XF86_TGA
usr/X11R6/bin/XF86_VGA16
usr/X11R6/bin/XFree86
usr/X11R6/bin/Xsun
usr/X11R6/bin/Xsun24
usr/X11R6/bin/XsunMono
usr/X11R6/bin/Xtest
usr/X11R6/bin/setxkbmap
usr/X11R6/bin/xsetroot
usr/X11R6/lib/X11/XKeysymDB
usr/X11R6/lib/X11/fonts/misc/6x13*
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/fonts/Type1/l047013t*
usr/X11R6/lib/X11/fonts/Type1/*
usr/X11R6/lib/X11/locale/*
usr/X11R6/lib/X11/rgb*
usr/X11R6/lib/X11/xkb/*
usr/X11R6/lib/X11/xserver/SecurityPolicy
usr/X11R6/lib/libICE*
usr/X11R6/lib/libSM*
usr/X11R6/lib/libX11*
usr/X11R6/lib/libXext*
usr/X11R6/lib/libXft*
usr/X11R6/lib/libXi*
usr/X11R6/lib/libXmu*
usr/X11R6/lib/libXpm*
usr/X11R6/lib/libXrender*
usr/X11R6/lib/libXt*
usr/X11R6/lib/modules/*
usr/X11R6/share/Xconfigurator/pixmaps/*
usr/bin/chattr*
usr/bin/ftp
usr/bin/fc-cache
usr/bin/gtk-query*
usr/bin/head
usr/bin/less
usr/bin/lsattr*
usr/bin/maketilo
usr/bin/mattrib
usr/bin/mbadblocks
usr/bin/mcd
usr/bin/mcopy
usr/bin/mdel
usr/bin/mdeltree
usr/bin/mdir
usr/bin/mdu
usr/bin/mformat
usr/bin/minfo
usr/bin/mini-wm
usr/bin/mlabel
usr/bin/mmd
usr/bin/mmount
usr/bin/mmove
usr/bin/mpartition
usr/bin/mrd
usr/bin/mread
usr/bin/mren
usr/bin/mshowfat
usr/bin/mtools
usr/bin/mtype
usr/bin/mwrite
usr/bin/mzip
usr/bin/open
usr/bin/pango*
usr/bin/pico
usr/bin/rcp
usr/bin/rlogin
usr/bin/rsh
usr/bin/syslinux
usr/bin/tac
usr/bin/tail
usr/bin/tilo
usr/bin/uniq
usr/lib/anaconda/iw
usr/$LIBDIR/gconv/*
usr/$LIBDIR/gdk-pixbuf/loaders/*png*
usr/$LIBDIR/gdk-pixbuf/loaders/*la*
usr/$LIBDIR/gdkimlib*
usr/$LIBDIR/gtk-2.0/*/engines/libbluecurve.so
usr/$LIBDIR/gtk-2.0/*/loaders/*png*
usr/$LIBDIR/gtk-2.0/*/loaders/*la*
usr/$LIBDIR/gtk-2.0/immodules/
usr/$LIBDIR/libImlib*
usr/$LIBDIR/libXft*
usr/$LIBDIR/libart*
usr/$LIBDIR/libatk*
usr/$LIBDIR/libaudio*
usr/$LIBDIR/libesd*
usr/$LIBDIR/libexpat*
usr/$LIBDIR/libfontconfig*
usr/$LIBDIR/libfreetype*
usr/$LIBDIR/libgdk*
usr/$LIBDIR/libglib*
usr/$LIBDIR/libgmodule*
usr/$LIBDIR/libgnome*
usr/$LIBDIR/libgnomesupport*
usr/$LIBDIR/libgnomeui*
usr/$LIBDIR/libgnorba*
usr/$LIBDIR/libgnorbagtk*
usr/$LIBDIR/libgobject*
usr/$LIBDIR/libgthread*
usr/$LIBDIR/libgtk*
usr/$LIBDIR/libgtkxmhtml*
usr/$LIBDIR/libimlib-png*
usr/$LIBDIR/libimlib-pnm*
usr/$LIBDIR/libimlib-xpm*
usr/$LIBDIR/libjpeg*
usr/$LIBDIR/libncurses*
usr/$LIBDIR/libpango*
usr/$LIBDIR/libpng.so.3*
usr/$LIBDIR/libpng12*
usr/$LIBDIR/libreadline*
usr/$LIBDIR/libthread*
usr/$LIBDIR/libtiff*
usr/$LIBDIR/libvte*
usr/$LIBDIR/locale/*
usr/$LIBDIR/pango/*
usr/$LIBDIR/python2.2/site-packages/gtk*/gtk/*
usr/$LIBDIR/rpm/rpmpopt
usr/lib/syslinux/*
usr/sbin/chroot
usr/sbin/ddcprobe
usr/sbin/gnome-pty-helper
usr/sbin/traceroute
usr/share/anaconda/*
usr/share/fonts/bitmap-fonts/fangsongti*
usr/share/fonts/default/Type1/n019003l*
usr/share/fonts/default/Type1/n019004l*
usr/share/fonts/default/Type1/n019023l*
usr/share/fonts/default/Type1/n019024l*
usr/share/fonts/default/Type1/n021003l*
usr/share/fonts/default/Type1/n021004l*
usr/share/fonts/default/Type1/n021023l*
usr/share/fonts/default/Type1/n021024l*
usr/share/fonts/ko/TrueType/dotum.ttf
usr/share/fonts/ja/TrueType/kochi-gothic.ttf
usr/share/fonts/zh_TW/TrueType/bsmi00lp.ttf
usr/share/locale/*
usr/share/pixmaps/comps/*.png
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/redhat-config-keyboard/*
usr/share/terminfo/l/linux
usr/share/terminfo/x/xterm
usr/share/terminfo/k/kon
usr/share/themes/Bluecurve/gtk-2.0/*
usr/share/vte/termcap/xterm
usr/share/zoneinfo/zone.tab
EOF

TIMEZONES="
usr/share/zoneinfo/US
usr/share/zoneinfo/Europe
usr/share/zoneinfo/Japan
usr/share/zoneinfo/America
"

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

if [ $ARCH = 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*
usr/share/fonts/ISO8859-2/100dpi/cour*
usr/share/fonts/ISO8859-2/100dpi/helv*
usr/share/fonts/ISO8859-2/100dpi/tim*
usr/share/fonts/ISO8859-2/100dpi/fonts*
EOF
fi

echo "Assembling package list..."
RPMS=$(prunePackageList $PACKAGEDIR "$PACKAGES")
RPMSGR=$(prunePackageList $PACKAGEDIR "$PACKAGESGR")

rm -rf $DEST; mkdir -p $DEST/usr/sbin
rm -rf $DESTGR; mkdir -p $DESTGR/usr/sbin $DESTGR/var/lib
ln -s /tmp $DESTGR/var/lib/xkb 

for file in $KEEPFILE $KEEPFILEGR; do
   cat $file | awk '{print $1 "\n./" $1}' > $file-
   mv -f $file- $file
done

echo -n "Expanding packages..."
expandPackageSet "$RPMS" $DEST $KEEPFILE

(cd $DEST; tar cSpf - .) | (cd $DESTGR; tar xSpf -)

expandPackageSet "$RPMSGR" $DESTGR $KEEPFILEGR
echo -e "\rExpanding packages..."

if [ -f $DEST/usr/share/doc/kon2*/terminfo.kon ]; then
   tic $DEST/usr/share/doc/kon2*/terminfo.kon -o $DEST/usr/share/terminfo
   tic $DEST/usr/share/doc/kon2*/terminfo.kon -o $DESTGR/usr/share/terminfo
   rm $DEST/usr/share/doc/kon2*/terminfo.kon
fi

echo "retrieving timezones"
TZDIR=/tmp/glibc-timezone-$$
mkdir -p $TZDIR/usr/share/zoneinfo
rpm2cpio $GLIBC | (cd $TZDIR; cpio --quiet -iumd usr/share/zoneinfo ./usr/share/zoneinfo ./usr/share/zoneinfo/* usr/share/zoneinfo/*)
(cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DEST; tar xSpf -)
(cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DESTGR; tar xSpf -)
rm -rf $TZDIR

chown -R root:root $DEST $DESTGR
chmod -R a+rX-w $DEST $DESTGR
if [ $ARCH = s390 -o $ARCH = s390x ]; then
    for i in $DEST $DESTGR; do
	(cd $i/etc/ssh; chmod og-r ssh_host*key primes sshd_config)
	mv $i/bin/sed $i/bin/sed_save
	mv $i/bin/mount $i/bin/mount_save
	mv $i/bin/sort $i/bin/sort_save
	mv $i/bin/mknod $i/bin/mknod_save
    done
fi

if [ $ARCH = sparc ]; then
    rm -f $DESTGR/usr/X11R6/bin/XF86_VGA16
fi

# Remove locales unused during the install
cat $DESTGR/usr/lib/anaconda/lang-table* | awk '
{ print $5;
  print gensub(/\..*$/,"","",$5);
  print gensub(/_.*$/,"","",$5);
  if (split ($5, a, "\.") > 1) {
    print gensub(/\..*$/,tolower("." a[2]),"",$5);
  };
}
' | LC_ALL=C sort -u > $DESTGR/locales
for p in lib share; do (
cd $DESTGR/usr/$p/locale && {
ls | grep -v locale.alias | LC_ALL=C sort > $DESTGR/locales.list
LC_ALL=C comm -13 $DESTGR/locales $DESTGR/locales.list | xargs rm -rf
}
); done
rm -f $DESTGR/locales $DESTGR/locales.list

# Remove unneeded XFree86 modules
rm -rf $DESTGR/usr/X11R6/lib/modules/dri
rm -f $DESTGR/usr/X11R6/lib/modules/extensions/lib{GLcore,glx,pex5}*

# moving comps-extras images in to where anaconda expects them
echo "Moving comps-extras pixmaps to where anaconda expects them"
if [ -n "$NEEDGR" ]; then
    mkdir -p $DESTGR/usr/share/anaconda/pixmaps/comps
    mv $DESTGR/usr/share/pixmaps/comps/* $DESTGR/usr/share/anaconda/pixmaps/comps/
fi

echo "Running mkfontdir..."
if [ -n "$NEEDGR" ]; then
    /usr/X11R6/bin/mkfontdir -p /usr/X11R6/lib/X11/fonts/encodings/ -e $DESTGR/usr/X11R6/lib/X11/fonts/encodings $DESTGR/usr/X11R6/lib/X11/fonts/* $DESTGR/usr/share/fonts/ISO8859-2/* $DESTGR/usr/share/fonts/ISO8859-9/*
    rm -f $DESTGR/usr/X11R6/bin/mkfontdir
fi

echo "Getting pango modules"
if [ -n "$NEEDGR" ]; then
    if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then
    	REALPATH=`(cd $DESTGR; /bin/pwd | sed 's,/md1/,/,g')`
    	runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/lib:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/pango-querymodules 2> $REALPATH/etc/pango/pango.modules"
    else
	/usr/sbin/chroot $DESTGR /usr/bin/pango-querymodules > $DESTGR/etc/pango/pango.modules
    fi
    rm -f $DESTGR/usr/bin/pango-querymodules
fi

echo "Getting gtk2 input method modules"
if [ -n "$NEEDGR" ]; then
    if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then
    	REALPATH=`(cd $DESTGR; /bin/pwd | sed 's,/md1/,/,g')`
	runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/lib:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/gtk-query-immodules-2.0 2> $REALPATH/etc/gtk-2.0/gtk.immodules"
    else
	/usr/sbin/chroot $DESTGR /usr/bin/gtk-query-immodules-2.0 > $DESTGR/etc/gtk-2.0/gtk.immodules
    fi
    rm -f $DESTGR/usr/bin/gtk-query-immodules-2.0
fi

# make the changes we want to fonts.conf for anaconda (#65913)
if [ -n "$NEEDGR" ]; then
    echo -n "Munging fonts.conf"
    sed s/AR\ PL\ SungtiL\ GB/Fangsong\ ti/g $DESTGR/etc/fonts/fonts.conf > $DESTGR/etc/fonts/fonts.conf.foo
    mv $DESTGR/etc/fonts/fonts.conf.foo $DESTGR/etc/fonts/fonts.conf
fi

# minislang can pretend to be utf8 slang for us
for p in $DEST $DESTGR; do
    ln -sf ./libslang.so.1 $p/usr/$LIBDIR/libslang-utf8.so.1
done

rm -f $KEEPFILE $KEEPFILEGR

echo -n "Scrubbing trees..."
for p in $DEST $DESTGR; do
	echo -n -e "\rScrubbing trees..." "$p"
	cp $p/usr/lib/anaconda/raidstart-stub $p/usr/bin/raidstart
	cp $p/usr/lib/anaconda/raidstop-stub $p/usr/bin/raidstop
	cp $p/usr/lib/anaconda/losetup-stub $p/usr/bin/losetup
	cp $p/usr/lib/anaconda/pump-stub $p/usr/bin/pump
	cp $p/usr/lib/anaconda/list-harddrives-stub $p/usr/bin/list-harddrives
	cp $p/usr/lib/anaconda/kudzu-probe-stub $p/usr/bin/kudzu-probe

	mv $p/usr/sbin/anaconda $p/usr/bin/anaconda
	mv $p/usr/lib/anaconda-runtime/lib* $p/usr/$LIBDIR

	mv $p/usr/lib/anaconda-runtime/collage $p/usr/bin

	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; find) | (cd $p/bin; /bin/cpio --quiet -pdmu $p/usr/bin)
	(cd $p/sbin; find) | (cd $p/sbin; /bin/cpio --quiet -pdmu $p/usr/sbin)
	rm -rf $p/bin
	rm -rf $p/sbin

	# copy bootloader files for sparc
	if [ $ARCH = sparc -a $p = $DESTGR ]; then
	    mkdir -p $p/usr/lib/anaconda-runtime/boot
	    (cd $p/boot; find -name "*.b") | (cd $p/boot; /bin/cpio --quiet -pdmu $p/usr/lib/anaconda-runtime/boot)
        fi

	# copy bootloader file for alpha
	if [ $ARCH = alpha -a $p = $DESTGR ]; then
	    mkdir -p $p/usr/lib/anaconda-runtime/boot
	    cp -af $p/boot/bootlx $p/usr/lib/anaconda-runtime/boot
        fi
	
	# copy bootloader files for ia64
	if [ $ARCH = ia64 -a $p = $DESTGR ]; then
	    mkdir -p $p/usr/lib/anaconda-runtime/boot
	    cp -af $p/boot/efi/EFI/redhat//* $p/usr/lib/anaconda-runtime/boot
	fi    

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

	find $p -name "*.a" | grep -v "usr/X11R6/lib/modules" | xargs rm -rf
	find $p -name "lib*.la" |grep -v "usr/$LIBDIR/gtk-2.0" | xargs rm -rf
	for f in newt popt rpm rpmio; do
	    rm -f $p/usr/$LIBDIR/lib$f.so
	done

	if [ "$ARCH" != "s390" -a "$ARCH" != "s390x" ]; then
	   (cd $p/lib; rm -f libnss_files.so.1 libnss_dns.so.1)
	fi

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

	if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then
	    REALPATH=`(cd $p; /bin/pwd | sed 's,/md1/,/,g')`
            runroot $COMPONENT --onlyone --arch $ARCH "cd $REALPATH\; usr/lib/anaconda-runtime/scrubtree $REALPATH"
	else
	    $p/usr/lib/anaconda-runtime/scrubtree $p
	fi
	echo -n -e "\rScrubbing trees..." "$(echo $p | sed 's/./ /g')"
done

echo -e "\nCompressing .mo files in stage2 images..."
if [ -d $DEST/usr/share/locale ]; then
    for i in `find $DEST/usr/share/locale -name anaconda.mo`; do
	gzip -9 $i
	mv -f $i.gz $i
    done
fi

echo "Creating fontconfig cache"
if [ -n "$NEEDGR" ]; then
    if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then
    	REALPATH=`(cd $DESTGR; /bin/pwd | sed 's,/md1/,/,g')`
	runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/lib:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/fc-cache -v"
    else
	/usr/sbin/chroot $DESTGR /usr/bin/fc-cache -v
    fi
    rm -f $DESTGR/usr/bin/fc-cache
fi


if [ $ARCH = "alpha" ]; then
    rm -rf $DEST/usr/share/locale
    rm -rf $DEST/usr/$LIBDIR/locale
fi

echo "Patching python library..."

# always use passive mode for ftp installs
cd $DEST/usr/$LIBDIR/python2.2
patch -p0 > /dev/null <<EOF
--- urllib.py.orig	Thu Oct 25 17:05:06 2001
+++ urllib.py	Thu Oct 25 17:05:34 2001
@@ -453,6 +453,7 @@
         path, attrs = splitattr(path)
         path = unquote(path)
         dirs = path.split('/')
+        dirs[0] = '/' + dirs[0]
         dirs, file = dirs[:-1], dirs[-1]
         if dirs and not dirs[0]: dirs = dirs[1:]
         if dirs and not dirs[0]: dirs[0] = '/'
@@ -707,6 +708,7 @@
         self.ftp = ftplib.FTP()
         self.ftp.connect(self.host, self.port)
         self.ftp.login(self.user, self.passwd)
+        self.ftp.set_pasv(1)
         for dir in self.dirs:
             self.ftp.cwd(dir)
EOF
cd -

echo -n -e "Removing unused python files in hdimage... "

if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then
    REALPATH=`(cd $DEST; /bin/pwd | sed 's,/md1/,/,g')`
    runroot $COMPONENT --onlyone --arch $ARCH "cd $REALPATH\; usr/lib/anaconda-runtime/pythondeps $REALPATH"
else
    $DEST/usr/lib/anaconda-runtime/pythondeps $DEST
fi
echo "done."

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

# this is only for the minimal second stage
echo "Cleaning ramdisk install images..."
    rm -rf $DEST/usr/lib/anaconda-runtime

if [ "$ARCH" != "s390" -a "$ARCH" != "s390x" ]; then
   if [ $NEEDGR ]; then
       # 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
   fi

   if [ -n "$NEEDGR" ]; then
    cd $ORIGDIR
    $DESTGR/usr/lib/anaconda-runtime/checkcards.py $DESTGR/usr/share/hwdata/pcitable $DESTGR/usr/X11R6/lib/X11/Cards
   fi
fi