summaryrefslogtreecommitdiffstats
path: root/scripts/upd-instroot
blob: 21c6bd62f83f5f9db3e648644c01a703fee14991 (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
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
#!/bin/bash
#
# upd-instroot
#
# Copyright (C) 2007, 2008 Red Hat, Inc.  All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

ORIGDIR=`pwd`
DEBUG=""
ARCH=`uname -m`

while [ $# -gt 0 ]; do
    case $1 in
        --debug)
            DEBUG="--debug"
            shift
        ;;

        --arch)
            ARCH=$2
            shift; shift
        ;;

        --imgdir)
            DEST=$2
            shift; shift
        ;;

        # a filesystem tree to use as updates.  could be the output
        # of 'make install' from anaconda...
        --updates)
            UPDATES=$2
            shift; shift
        ;;

        --nogr)
            echo "*** DeprecationWarning: ignoring --nogr option." >&2
            shift
        ;;

        --mindir)
            echo "*** DeprecationWarning: ignoring --mindir option." >&2
            shift; shift
        ;;

        --stg2dir)
            echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
            shift; shift
        ;;

        *)
            yumconf=$1
            shift
        ;;
    esac
done

if [ -z "$yumconf" ]; then
    echo "upd-instroot: updates instimage from a Red Hat RPMS directory"
    echo "usage:        $0 [--debug] [--arch arch] [--imgdir imgdir] [yumconf]"
    exit 1
fi

if [ $ARCH = x86_64 -o $ARCH = s390x -o $ARCH = ppc64 ]; then
    LIBDIR=lib64
else
    LIBDIR=lib
fi

if [ -z "$DEST" ]; then
    DEST=`mktemp -d ${TMPDIR:-/tmp}/dest.XXXXXX`
fi

if [ ! -f $yumconf ]; then
    echo "Unable to find yum repo information!"
    exit 1
fi

. $(dirname $0)/buildinstall.functions

expandPackageSet() {
    YUMCONF=$1
    YUMDIR=$2
    RPMS=$3
    PKGDEST=$4
    KEEPFILES=$5

    [ -d $PKGDEST ] || die "ERROR: directory missing: $PKGDEST"

    [ -z "$DEBUG" ] && outlvl="--quiet" || outlvl="--verbose"

    yum $outlvl -c $YUMCONF -y --installroot=$YUMDIR install $RPMS 2>&1 || die "ERROR: could not install packages"

    if [ -n "$UPDATES" ]; then
        (cd $UPDATES; find) | (cd $UPDATES ; /bin/cpio --quiet -pmdu $YUMDIR)
    fi

    # figure out the theme to keep
    if [ -f $YUMDIR/etc/gtk-2.0/gtkrc ]; then
        gtktheme=$(grep "gtk-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
        echo "usr/share/themes/$gtktheme" >> $KEEPFILES
        # find gtk engine needed
        for engine in `grep engine $YUMDIR/usr/share/themes/$gtktheme/gtk-2.0/gtkrc | grep -v ^# | awk {'print $2;'} | sed -e 's/"//g' | sort -u` ; do
            echo "usr/$LIBDIR/gtk-2.0/*/engines/*$engine*" >> $KEEPFILES
        done

        theme=$(grep "gtk-icon-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
        while [ -n "$theme" ]; do
            echo "usr/share/icons/$theme" >> $KEEPFILES
            theme=$(grep Inherits $YUMDIR/usr/share/icons/$theme/index.theme | cut -d = -f 2)
        done

        cursortheme=$(grep "gtk-cursor-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
        if [ -n "$cursortheme" ]; then
            echo "usr/share/icons/$cursortheme" >> $KEEPFILES
        fi
    fi

    echo `date` "Installing files"
    pushd $YUMDIR >/dev/null
    cat $KEEPFILES | while read spec ; do
        #Pull off path
        path=`echo "$spec" | sed 's,\([^[*\?]*\)/.*,\1,'`
        for filespec in `find ./$path -path "./$spec" 2> /dev/null` ; do
            if [ ! -e $filespec ]; then
                continue
            elif [ ! -d $filespec ]; then
                instFile $filespec $PKGDEST
            else
                for i in `find $filespec -type f 2> /dev/null` ; do instFile $i $PKGDEST ; done
                for i in `find $filespec -type l 2> /dev/null` ; do instFile $i $PKGDEST ; done
                for d in `find $filespec -type d 2> /dev/null` ; do instDir $d $PKGDEST ; done
            fi
        done
    done
    popd >/dev/null
}

die () {
    echo "$@"
    echo "Aborting instroot creation..."
    exit 1
}

PACKAGES="GConf2 NetworkManager ORBit2 acl anaconda
    anaconda-yum-plugins at-spi atk attr audit-libs bash bitmap-fonts-cjk
    btrfs-progs bzip2 bzip2-libs ca-certificates cairo cjkuni-uming-fonts
    comps-extras coreutils cpio cracklib cracklib-dicts cracklib-python
    cryptsetup-luks cyrus-sasl-lib db4 dbus dbus-python dbus-x11 dejavu-sans-fonts
    dcbd dejavu-sans-mono-fonts device-mapper device-mapper-libs
    device-mapper-multipath device-mapper-multipath-libs
    dhclient dmraid dmraid-libs
    dogtail dosfstools e2fsprogs e2fsprogs-libs echo-icon-theme ethtool
    elfutils-libelf expat fcoe-utils
    firstboot fontconfig fonts-ISO8859-2 freetype gail gawk gdb-gdbserver
    gdk-pixbuf gfs2-utils glib2 glibc-common gnome-python2-canvas gnome-python2-gconf
    gnome-themes gpm grep gtk2 gtk2-engines
    hdparm hwdata initscripts iproute iputils iscsi-initiator-utils
    jfsutils kpartx keyutils-libs krb5-libs libICE libSM libX11 libXau
    libXaw libXcursor libXdmcp libXevie libXext libXfixes libXfont libXft
    libXi libXinerama libXmu libXpm libXrandr libXrender libXt libXtst
    libXxf86misc libacl libaio libart_lgpl libattr
    libbonobo libcanberra libcanberra-gtk2 libcurl libfontenc libidn libgcc
    libglade2 libgnomecanvas libgcrypt libgpg-error libjpeg libnl libogg
    libpng libselinux libselinux-python libsemanage
    libsemanage-python libsepol libssh2 libstdc++ libtdb libthai libtirpc 
    libtool-ltdl libuser
    libuser-python libvolume_id libvorbis libxcb libxkbfile libxml2 lklug-fonts
    lohit-assamese-fonts lohit-bengali-fonts lohit-gujarati-fonts lohit-hindi-fonts
    lohit-kashmiri-fonts lohit-kannada-fonts lohit-maithili-fonts lohit-marathi-fonts
    lohit-oriya-fonts lohit-punjabi-fonts lohit-sindhi-fonts lohit-tamil-fonts
    lohit-telugu-fonts lvm2 madan-fonts mdadm
    mesa-dri-drivers metacity module-init-tools ncurses neon net-tools
    newt newt-python nfs-utils nspr nss nss-softokn ntfs-3g
    openldap openssh openssh-server
    pam pango parted pciutils pcre psmisc
    pygtk2-libglade pykickstart pyparted python python-bugzilla python-decorator
    python-libs python-nss python-pyblock python-sqlite python-epdb
    python-urlgrabber python-volume_key pyxf86config readline redhat-artwork
    reiserfs-utils report-config-default report-gtk report-newt rpm rpm-libs
    rpm-python rsyslog sed selinux-policy-targeted
    setup slang smc-meera-fonts specspo sqlite startup-notification strace
    synaptics system-config-date
    system-config-keyboard ${brandpkgname}-logos ${brandpkgname}-release
    sysvinit-tools taipeifonts tcp_wrappers tcp_wrappers-libs telnet
    tigervnc-server tigervnc-server-module tzdata
    udev un-core-dotum-fonts urw-fonts usbutils util-linux-ng
    vlgothic-fonts vim-minimal
    wget wpa_supplicant xcb-util xkeyboard-config xfsprogs xorg-x11-xauth
    xorg-x11-drivers xorg-x11-font-utils xorg-x11-fonts-ethiopic
    xorg-x11-fonts-misc xorg-x11-server-utils
    xorg-x11-server-Xorg xorg-x11-xkb-utils xorg-x11-xfs yum
    yum-metadata-parser zenity zlib /etc/gtk-2.0/gtkrc"

if [ $ARCH = i386 ]; then
    PACKAGES="$PACKAGES glibc.i386 openssl.i386"
elif [ $ARCH = i586 ]; then
    PACKAGES="$PACKAGES glibc.i586 openssl.i586"
elif [ $ARCH = sparc -o $ARCH = sparcv9 -o $ARCH = sparc64 ]; then
    PACKAGES="$PACKAGES glibc.sparcv9 openssl.sparcv9"
else
    PACKAGES="$PACKAGES glibc openssl"
fi

if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
    PACKAGES="$PACKAGES pcmciautils grub"
fi

if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 -o $ARCH = ia64 ]; then
    PACKAGES="$PACKAGES dmidecode efibootmgr"
fi

if [ $ARCH = ia64 ]; then
    # XXX this needs to switch to grub at some point...
    PACKAGES="$PACKAGES elilo"
fi

if [ $ARCH = s390 -o $ARCH = s390x ]; then
    PACKAGES="$PACKAGES bind-utils binutils coreutils findutils gzip
              initscripts iputils less libgcc login lsscsi modutils mount
              net-tools openssh-clients pam portmap
              s390utils sed strace tar xorg-x11-libs
              xorg-x11-xauth"
fi

if [ $ARCH = ppc -o $ARCH = ppc64 ]; then
    PACKAGES="$PACKAGES pcmciautils pdisk yaboot hfsutils kernel-bootwrapper"
fi

#
# stuff ONLY included for rescue mode
#
# these packages are combined with the PACKAGES for big stage 2
#
PACKAGESRESCUE="bzip2 bzip2-libs dump
                findutils ftp gzip iputils joe krb5-libs less man
                modutils mtools mt-st mtr net-tools smartmontools
                openssh openssh-clients pciutils rsh traceroute tar rsync
                device-mapper device-mapper-libs dmraid ntfsprogs samba-client
		firstaidkit firstaidkit-plugin-passwd firstaidkit-plugin-xserver
		firstaidkit-gui firstaidkit-plugin-mdadm-conf firstaidkit-plugin-key-recovery volume_key"

if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
  PACKAGESRESCUE="$PACKAGESRESCUE gpart grub firstaidkit-plugin-grub"
fi

#
# add bootloader for particular arch
#
if [ $ARCH = sparc -o $ARCH = sparcv9 -o $ARCH = sparc64 ]; then
    PACKAGES="$PACKAGES tilo silo"
fi

if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
    PACKAGES="$PACKAGES syslinux memtest86+ grub"
fi

if [ $ARCH = alpha ]; then
    PACKAGES="$PACKAGES aboot"
fi

if [ $ARCH = ppc ]; then
    PACKAGES="$PACKAGES fbset yaboot ppc64-utils"
fi

#
# KEEPFILE is all files to keep from the packages in PACKAGES
#
# The files in this list define the install image used for all installation
# methods.
#
# The rescue mode of anaconda uses these files as well as those defined
# by KEEPFILERESCUE below.  The total size of this image should be
# under the size of the miniature CD used for the rescue CD (around 68MB).
#
KEEPFILE=${TMPDIR:-/tmp}/keepfile.$$
cat > $KEEPFILE <<EOF
$LIBDIR/dbus-1
$LIBDIR/libaio.so*
$LIBDIR/libfreebl3.so
$LIBDIR/libmultipath.so*
$LIBDIR/libnss_dns*
$LIBDIR/libnss_files*
$LIBDIR/libnssdbm3.so
$LIBDIR/libsoftokn3.so
$LIBDIR/libwrap*.so*
$LIBDIR/multipath/*
$LIBDIR/rsyslog
$LIBDIR/security/pam_*
bin/arch
bin/basename
bin/bash
bin/cat
bin/chgrp
bin/chmod
bin/chown
bin/cp
bin/cpio
bin/cut
bin/date
bin/dbus-daemon
bin/dbus-uuidgen
bin/dd
bin/df
bin/dmesg
bin/du
bin/echo
bin/env
bin/false
bin/fdisk*
bin/gawk
bin/*grep
bin/hostname
bin/ipcalc
bin/kill
bin/ln
bin/login
bin/ls
bin/mkdir
bin/mknod
bin/mktemp
bin/more
bin/mount
bin/mv
bin/ntfs-3g
bin/ps
bin/pwd
bin/rm
bin/rmdir
bin/rpm
bin/sed
bin/sleep
bin/sort
bin/sync
bin/touch
bin/true
bin/umount
bin/vi
boot/*.b
boot/bootlx
boot/efi/EFI/redhat/elilo.efi
boot/efi/EFI/redhat/grub.efi
boot/efika.forth
boot/memtest86*
etc/NetworkManager/nm-system-settings.conf
etc/NetworkManager/dispatcher.d
etc/dbus-1/*
etc/dbus-1/system.d/*
etc/dcbd
etc/fb.modes
etc/fcoe
etc/fonts
etc/group
etc/gtk-2.0/gtkrc*
etc/hosts
etc/im_palette.pal
etc/imrc
etc/iscsid.conf
etc/man.config
etc/mke2fs.conf
etc/netconfig
etc/nsswitch.conf
etc/pam.d/other
etc/pam.d/sshd
etc/pango
etc/passwd
etc/pcmcia
etc/pki/tls/certs/ca-bundle.crt
etc/polkit-1/localauthority.conf.d/*
etc/polkit-1/nullbackend.conf.d/*
etc/prelink.conf
etc/protocols
etc/rc.d/init.d/functions
etc/report.d/*
etc/rpm/macros.prelink
etc/security/limits.conf
etc/security/pam_env.conf
etc/selinux/targeted
etc/services
etc/shells
etc/sysconfig/network-scripts/network-functions*
etc/udev
etc/wpa_supplicant/wpa_supplicant.conf
etc/xorg.conf.d/*
etc/yum.repos.d/*
etc/yum/pluginconf.d/blacklist.conf
etc/yum/pluginconf.d/fedorakmod.conf
etc/yum/pluginconf.d/whiteout.conf
lib/terminfo
lib/udev
sbin/*gfs*
sbin/arping
sbin/badblocks
sbin/blockdev
sbin/btrfsctl
sbin/btrfsck
sbin/cciss_id
sbin/clock
sbin/consoletype
sbin/cryptsetup
sbin/debugfs
sbin/debugreiserfs
sbin/dhclient
sbin/dhclient-script
sbin/dhcp6c
sbin/dosfslabel
sbin/dumpe2fs
sbin/fsadm
sbin/e2fsck
sbin/e2label
sbin/ethtool
sbin/fdisk
sbin/fsck
sbin/fsck.ext*
sbin/fsck.jfs
sbin/fsck.reiserfs
sbin/fsck.xfs
sbin/hdparm
sbin/hwclock
sbin/ifconfig
sbin/ip
sbin/iscsiadm
sbin/iscsid
sbin/iscsistart
sbin/jfs_tune
sbin/killall5
sbin/kpartx
sbin/ldconfig
sbin/load_policy
sbin/lspci
sbin/lvm*
sbin/mdadm
sbin/mdmon
sbin/mkdosfs
sbin/mke2fs
sbin/mkfs.btrfs
sbin/mkfs.ext*
sbin/mkfs.gfs2
sbin/mkfs.jfs
sbin/mkfs.msdos
sbin/mkfs.reiserfs
sbin/mkfs.vfat
sbin/mkfs.xfs
sbin/mkofboot
sbin/mkraid
sbin/mkreiserfs
sbin/mkswap
sbin/mount.nfs*
sbin/mount.ntfs*
sbin/multipath
sbin/nologin
sbin/ofpath
sbin/parted
sbin/pcmcia-socket-startup
sbin/pdisk
sbin/probe
sbin/pidof
sbin/reiserfsck
sbin/reiserfstune
sbin/resize_reiserfs
sbin/resize2fs
sbin/route
sbin/rsyslogd
sbin/setfiles
sbin/sfdisk
sbin/silo
sbin/swapoff
sbin/swapon
sbin/tune2fs
sbin/udev*
sbin/umount.nfs*
sbin/xfs_repair
sbin/xfsrestore
sbin/ybin
usr/$LIBDIR/NetworkManager
usr/$LIBDIR/dri
usr/$LIBDIR/gconv
usr/$LIBDIR/gdk-pixbuf/loaders/*la*
usr/$LIBDIR/gdk-pixbuf/loaders/*png*
usr/$LIBDIR/gdk-pixbuf/loaders/*xpm*
usr/$LIBDIR/gtk-2.0/*/engines/libclearlooks.so
usr/$LIBDIR/gtk-2.0/*/loaders/*la*
usr/$LIBDIR/gtk-2.0/*/loaders/*png*
usr/$LIBDIR/gtk-2.0/*/loaders/*xpm*
usr/$LIBDIR/gtk-2.0/immodules
usr/$LIBDIR/kernel-wrapper/*
usr/$LIBDIR/libuser/*
usr/$LIBDIR/pango
usr/$LIBDIR/python?.?
usr/$LIBDIR/rpm/rpmpopt
usr/$LIBDIR/libiscsi.so*
usr/$LIBDIR/libmetacity-private.so*
usr/$LIBDIR/libsqlite3.so*
usr/$LIBDIR/xorg/modules
usr/$LIBDIR/xserver/SecurityPolicy
usr/$LIBDIR/libfreebl3.so
usr/$LIBDIR/libnss3.so
usr/$LIBDIR/libnssckbi.so
usr/$LIBDIR/libnssdbm3.so
usr/$LIBDIR/libnsspem.so
usr/$LIBDIR/libsmime3.so
usr/$LIBDIR/libsoftokn3.so
usr/$LIBDIR/libssl3.so
usr/bin/[
usr/bin/Xorg
usr/bin/Xvnc
usr/bin/chattr*
usr/bin/dbus-launch
usr/bin/du
usr/bin/expr
usr/bin/gdb-gdbserver
usr/bin/gdialog
usr/bin/gdk-pixbuf-query-loaders*
usr/bin/gtk-query*
usr/bin/gtk-update-icon-cache*
usr/bin/hattrib
usr/bin/hcopy
usr/bin/head
usr/bin/hformat
usr/bin/hmount
usr/bin/humount
usr/bin/killall
usr/bin/logger
usr/bin/lsattr*
usr/bin/maketilo
usr/bin/md5sum
usr/bin/metacity
usr/bin/mkzimage
usr/bin/pango*
usr/bin/python
usr/bin/python?.?
usr/bin/readlink
usr/bin/reduce-font
usr/bin/setxkbmap
usr/bin/sha1sum
usr/bin/split
usr/bin/ssh-keygen
usr/bin/strace
usr/bin/syslinux
usr/bin/tac
usr/bin/tail
usr/bin/tee
usr/bin/telnet
usr/bin/tilo
usr/bin/top
usr/bin/wc
usr/bin/udev*
usr/bin/uniq
usr/bin/vncconfig
usr/bin/vncpasswd
usr/bin/wget
usr/bin/xkbcomp
usr/bin/zenity
usr/lib/anaconda
usr/lib/anaconda-runtime
usr/lib/anaconda/installclasses
usr/lib/anaconda/iw
usr/lib/anaconda/textw
usr/lib/anaconda/booty
usr/lib/anaconda/storage
usr/lib/anaconda/storage/devicelibs
usr/lib/anaconda/storage/formats
usr/lib/kernel-wrapper
usr/lib/locale
usr/lib/python?.?
usr/lib/python?.?/site-packages/epdb/*.py
usr/lib/rpm/macros
usr/lib/rpm/rpmpopt
usr/lib/rpm/rpmrc
usr/share/syslinux
usr/lib/yaboot
usr/lib/yum-plugins/blacklist.py*
usr/lib/yum-plugins/fedorakmod.py*
usr/lib/yum-plugins/whiteout.py*
usr/libexec/convertdb1
usr/libexec/nm-crash-logger
usr/libexec/nm-dhcp-client.action
usr/libexec/nm-dispatcher.action
usr/libexec/polkit*
usr/sbin/NetworkManager
usr/sbin/addRamDisk
usr/sbin/anaconda
usr/sbin/chroot
usr/sbin/dcbd
usr/sbin/dcbtool
usr/sbin/ddcprobe
usr/sbin/dmidecode
usr/sbin/efibootmgr
usr/sbin/fcoemon
usr/sbin/fbset
usr/sbin/genhomedircon
usr/sbin/gptsync
usr/sbin/lvm
usr/sbin/prelink
usr/sbin/semodule
usr/sbin/showpart
usr/sbin/smartctl
usr/sbin/sshd
usr/sbin/wpa_passphrase
usr/sbin/wpa_supplicant
usr/sbin/wrapper
usr/sbin/xfs_admin
usr/sbin/xfs_check
usr/sbin/xfs_copy
usr/sbin/xfs_db
usr/share/polkit-1/actions/*
usr/share/X11/XKeysymDB
usr/share/X11/fonts/TTF/GohaTibebZemen.ttf
usr/share/X11/fonts/misc/6x13*
usr/share/X11/fonts/misc/cursor*
usr/share/X11/fonts/misc/fonts*
usr/share/X11/fonts/misc/olcursor*
usr/share/X11/locale
usr/share/X11/rgb*
usr/share/X11/xkb
usr/share/anaconda
usr/share/anaconda/anaconda.conf
usr/share/cracklib
usr/share/dbus-1
usr/share/fontconfig
usr/share/fonts/*/lklug.ttf
usr/share/fonts/lohit*/*
usr/share/fonts/*/lklug.ttf
usr/share/fonts/cjkuni*/uming*.ttc
usr/share/fonts/dejavu/DejaVuSans-Bold.ttf
usr/share/fonts/dejavu/DejaVuSans.ttf
usr/share/fonts/dejavu/DejaVuSansMono.ttf
usr/share/fonts/kacst/KacstFarsi.ttf
usr/share/fonts/kacst/KacstQura.ttf
usr/share/fonts/madan/Madan.ttf
usr/share/fonts/un-core/UnDotum.ttf
usr/share/fonts/*/VL-Gothic-Regular.ttf
usr/share/fonts/smc/Meera*.ttf
usr/share/hwdata/MonitorsDB
usr/share/hwdata/pci.ids
usr/share/hwdata/usb.ids
usr/share/hwdata/videoaliases
usr/share/hwdata/videodrivers
usr/share/locale/*/LC_MESSAGES/anaconda.mo
usr/share/locale/*/LC_MESSAGES/cracklib.mo
usr/share/locale/*/LC_MESSAGES/gtk20.mo
usr/share/locale/*/LC_MESSAGES/libc.mo
usr/share/locale/*/LC_MESSAGES/parted.mo
usr/share/locale/*/LC_MESSAGES/redhat-dist.mo
usr/share/locale/*/LC_MESSAGES/system-config-date.mo
usr/share/locale/*/LC_MESSAGES/system-config-keyboard.mo
usr/share/locale/*/LC_MESSAGES/zenity.mo
usr/share/locale/locale.alias
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/ppc64-utils
usr/share/python-meh/*
usr/share/system-config-date
usr/share/system-config-date/zonetab.py*
usr/share/system-config-keyboard
usr/share/terminfo/l/linux
usr/share/terminfo/v/vt100
usr/share/terminfo/v/vt100-nav
usr/share/terminfo/v/vt320
usr/share/terminfo/v/vt320-w
usr/share/terminfo/x/xterm
usr/share/themes/Atlanta/metacity-1
usr/share/xorg/extramodes
usr/share/xorg/vesamodes
usr/share/zenity
usr/share/zoneinfo
var/lib/polkit-1
var/lib/dbus
var/run/dbus
EOF

if [ $ARCH = s390 -o $ARCH = s390x ]; then
    cat >> $KEEPFILE <<EOF
bin/basename
bin/cat
bin/chmod
bin/chown
bin/cp
bin/cut
bin/date
bin/dmesg
bin/echo
bin/find
bin/gzip
bin/ls
bin/mknod
bin/ping
bin/ping6
bin/ps
bin/sort
bin/tar
bin/uname
bin/vi
lib/modules/ibm
lib/s390-tools/lsznet.raw
lib/s390-tools/znetcontrolunits
lib/security
sbin/arp
sbin/cmsfscat
sbin/cmsfslst
sbin/dasdfmt
sbin/dasdinfo
sbin/dasdview
sbin/fdasd
sbin/lschp
sbin/lscss
sbin/lsdasd
sbin/lsqeth
sbin/lszfcp
sbin/portmap
sbin/qetharp
sbin/qetharp-2.6
sbin/qethconf
sbin/sysctl
usr/bin/dirname
usr/bin/expr
usr/bin/getopt
usr/bin/head
usr/bin/ldd
usr/bin/less
usr/bin/lsscsi
usr/bin/nslookup
usr/bin/printf
usr/bin/scp
usr/bin/strace
usr/bin/tr
usr/bin/wc
usr/bin/xauth
usr/sbin/glibc_post_upgrade
usr/sbin/lsreipl
usr/share/terminfo/a/ansi
usr/share/terminfo/d/dumb
usr/share/terminfo/k/kterm
usr/share/terminfo/s/screen
usr/share/terminfo/v/vt102
usr/share/terminfo/v/vt320
usr/share/terminfo/v/vt320-w
usr/share/terminfo/x/xterm
usr/share/terminfo/x/xterm-color
EOF
fi

# more dogtail stuff...
cat >> $KEEPFILE <<EOF
usr/$LIBDIR/gtk-2.0/modules/libatk-bridge.so
usr/$LIBDIR/gtk-2.0/modules/libgail.so
usr/libexec/bonobo-activation-server
usr/libexec/at-spi-registryd
usr/$LIBDIR/bonobo/servers
usr/libexec/gconfd-2
usr/$LIBDIR/GConf/2/libgconfbackend-xml.so
usr/$LIBDIR/python?.?/site-packages/gtk-2.0/atk.so
usr/$LIBDIR/python?.?/site-packages/gtk-2.0/gconf.so
usr/$LIBDIR/python?.?/site-packages/atspi.so
usr/lib/python?.?/site-packages/dogtail/*.py
EOF

#
# KEEPFILERESCUE is all files to keep from the packages in PACKAGESRESCUE
#
# This defines the files in addition to KEEPFILE that make up
# the install images for NFS and CD/DVD based rescue mode installs.  This
# image is not loaded into memory so it can be considerably larger.
#
# NOTE: hd, ftp, and http rescue mode use and image based on KEEPFILE since
#       it has to be much smaller due to memory usage.
#
KEEPFILERESCUE=${TMPDIR:-/tmp}/keepfilerescue.$$
cat > $KEEPFILERESCUE <<EOF
bin/find
bin/gunzip
bin/gzip
bin/mt
bin/ping
bin/sync
bin/tar
bin/zcat
etc/joe
sbin/arp
sbin/blkid
sbin/depmod
sbin/dmraid
sbin/dmsetup
sbin/dump
sbin/ifconfig
sbin/insmod
sbin/lsmod
sbin/modinfo
sbin/modprobe
sbin/depmod
sbin/netstat
sbin/restore
sbin/rrestore
sbin/rmmod
sbin/route
sbin/mount.cifs
sbin/umount.cifs
usr/bin/bunzip2
usr/bin/bzcat
usr/bin/bzip2
usr/bin/emacs
usr/bin/find
usr/bin/ftp
usr/bin/jmacs
usr/bin/joe
usr/bin/jpico
usr/bin/less
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/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/mzip
usr/bin/open
usr/bin/rcp
usr/bin/rlogin
usr/bin/rsh
usr/bin/rsync
usr/bin/scp
usr/bin/sftp
usr/bin/shred
usr/bin/ssh
usr/bin/termidx
usr/bin/volume_key
usr/bin/xargs
usr/bin/ntfscat
usr/bin/ntfscluster
usr/bin/ntfscmp
usr/bin/ntfsdecrypt
usr/bin/ntfsdump_logfile
usr/bin/ntfsfix
usr/bin/ntfsinfo
usr/bin/ntfsls
usr/bin/ntfsmftalloc
usr/bin/ntfsmove
usr/bin/ntfstruncate
usr/bin/ntfswipe
usr/bin/firstaidkit
usr/sbin/lsusb
usr/sbin/mkntfs
usr/sbin/ntfsclone
usr/sbin/ntfscp
usr/sbin/ntfslabel
usr/sbin/ntfsresize
usr/sbin/ntfsundelete
usr/sbin/mtr
usr/sbin/smartctl
usr/sbin/traceroute
usr/$LIBDIR/firstaidkit/plugins/
usr/lib/python?.?/site-packages/pyfirstaidkit/
usr/bin/whiptail
usr/bin/firstaidkit-qs
EOF

if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
    cat >> $KEEPFILERESCUE <<-EOF
sbin/grub
usr/bin/gpart
usr/share/grub
EOF
fi

echo "Assembling package list..."
RPMS="$PACKAGES $PACKAGESRESCUE"
[ -n "$DEBUG" ] && echo "RPMS are $RPMS"

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

#
# concat KEEPFILE and KEEPFILERESCUE lists
#
cat $KEEPFILERESCUE >> $KEEPFILE

echo `date` "Expanding packages..."
YUMDIR=${TMPDIR:-/tmp}/yumdir.$$
mkdir -p $YUMDIR/var/log
mkdir -p $YUMDIR/var/lib/yum

expandPackageSet $yumconf $YUMDIR "$RPMS" $DEST $KEEPFILE
echo `date` "Done Expanding packages..."

# Dogtail will check this
echo "Creating customized GConf2 settings for root"
mkdir -p $DEST/.gconf/desktop/gnome/interface
touch $DEST/.gconf/desktop/%gconf.xml
touch $DEST/.gconf/desktop/gnome/%gconf.xml
cat > $DEST/.gconf/desktop/gnome/interface/%gconf.xml <<EOF
<?xml version="1.0"?>
<gconf>
        <entry name="accessibility" mtime="1176200664" type="bool" value="true">
        </entry>
</gconf>
EOF

rm -rf $YUMDIR

chown -R root:root $DEST
chmod -R a+rX-w $DEST

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

rm -f $DEST/locales $DEST/locales.list

# fixup joe links
if [ -d "$DESTDIR"/etc/joe ]; then
    ln -fs jpicorc $DEST/etc/joe/picorc
    ln -fs jpicorc $DEST/etc/joe/jnanorc
    ln -fs jpicorc $DEST/etc/joe/nanorc
    ln -fs jmacsrc $DEST/etc/joe/emacsrc
    ln -fs jmacs $DEST/usr/bin/emacs
    ln -fs jpico $DEST/usr/bin/pico
    ln -fs jpico $DEST/usr/bin/nano
fi

# fix up some links for man page related stuff
for file in nroff groff iconv geqn gtbl gpic grefer ; do
    ln -fs /mnt/sysimage/usr/bin/$file $DEST/usr/bin/$file
done

# create selinux config
if [ -e $DEST/etc/selinux/targeted ]; then
  cat > $DEST/etc/selinux/config <<EOF
SELINUX=permissive
SELINUXTYPE=targeted
EOF
fi

echo "Creating libuser.conf"
cat > $DEST/etc/libuser.conf <<EOF
[defaults]
skeleton = /mnt/sysimage/etc/skel
mailspooldir = /mnt/sysimage/var/mail
crypt_style = md5
modules = files shadow
create_modules = files shadow
[files]
directory = /mnt/sysimage/etc
[shadow]
directory = /mnt/sysimage/etc
EOF

sed -i 's|\(installforallkernels\) = 0|\1 = 1|' $DEST/etc/yum/pluginconf.d/fedorakmod.conf

#
# Manual pages in rescue: We dont have man pages in the image, so we point everything (The pages
# and the man scripts to the /mnt/sysimage.  We want the man command to depend only on the
# man.conf file, so we don't use the $MANPATH env variable.  The executables stay unchanged as
# they will be soft links to /mnt/sysimage.
#
echo "Fixing up /etc/man.config to point into /mnt/sysimage"

#
# Lets avoid the lines with MANPATH_MAP for now
#
sed -i "s,^MANPATH[^_MAP][ \t]*,&/mnt/sysimage," $DEST/etc/man.config

#
# Lets change the lines with MANPATH_MAP.  Don't know how much of a difference this will make.
#
sed -i "s,^MANPATH_MAP[ \t]*[a-zA-Z0-9/]*[ \t]*,&/mnt/sysimage," $DEST/etc/man.config

echo "Scrubbing tree..." "$DEST"
mkdir -p $DEST/lib
mkdir -p $DEST/firmware
ln -snf /modules $DEST/lib/modules
ln -snf /firmware $DEST/lib/firmware
cp $DEST/usr/lib/anaconda/raidstart-stub $DEST/usr/bin/raidstart
cp $DEST/usr/lib/anaconda/raidstop-stub $DEST/usr/bin/raidstop
cp $DEST/usr/lib/anaconda/losetup-stub $DEST/usr/bin/losetup
cp $DEST/usr/lib/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives
cp $DEST/usr/lib/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys
cp $DEST/usr/lib/anaconda/mknod-stub $DEST/usr/bin/mknod
mv $DEST/usr/sbin/anaconda $DEST/usr/bin/anaconda
mv $DEST/usr/lib/anaconda-runtime/lib* $DEST/usr/$LIBDIR 2>/dev/null

mv $DEST/etc/yum.repos.d $DEST/etc/anaconda.repos.d

rm -f $DEST/usr/$LIBDIR/libunicode-lite*

find $DEST -type d | xargs chmod 755

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

if [ -f $DEST/bin/gawk ]; then
    ln -sf $DEST/bin/gawk awk
fi

[ -d $DEST/bin ] || die "ERROR: directory missing: $DEST/bin"
[ -d $DEST/sbin ] || die "ERROR: directory missing: $DEST/sbin"
(cd $DEST/bin; find) | (cd $DEST/bin; /bin/cpio --quiet -pdmu $DEST/usr/bin)
(cd $DEST/sbin; find) | (cd $DEST/sbin; /bin/cpio --quiet -pdmu $DEST/usr/sbin)
rm -rf $DEST/bin
rm -rf $DEST/sbin

# Fix relative links like /usr/bin/udevinfo -> ../../sbin/udevadm
for brokenlink in $(find $DEST/usr/{bin,sbin} -follow -lname '*') ; do
    target="$(readlink $brokenlink)"
    for pathbit in bin sbin; do
        # if it starts with "../../sbin/", remove that
        newtarget="${target##../../$pathbit/}"
        # if we removed something, replace it with the proper path
        if [ "$newtarget" != "$target" ]; then
            # make it ../sbin/ instead
            ln -sf "../$pathbit/$newtarget" "$brokenlink"
        fi
    done
done

# copy bootloader files for sparc
if [ $ARCH = sparc -o $ARCH = sparcv9 -o $ARCH = sparc64 ]; then
    mkdir -p $DEST/usr/lib/anaconda-runtime/boot
    [ -d $DEST/boot ] || die "ERROR: directory missing: $DEST/boot"
    (cd $DEST/boot; find -name "*.b") | (cd $DEST/boot; /bin/cpio --quiet -pdmu $DEST/usr/lib/anaconda-runtime/boot)
fi

# copy bootloader file for ppc
if [ $ARCH = ppc -o $ARCH = ppc64 ]; then
    mkdir -p $DEST/usr/lib/anaconda-runtime/boot
    cp -af $DEST/boot/efika.forth $DEST/usr/lib/anaconda-runtime/boot
fi

# copy bootloader file for alpha
if [ $ARCH = alpha ]; then
    mkdir -p $DEST/usr/lib/anaconda-runtime/boot
    cp -af $DEST/boot/bootlx $DEST/usr/lib/anaconda-runtime/boot
fi

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

# copy bootloader files for i386/x86_64
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
    mkdir -p $DEST/usr/lib/anaconda-runtime/boot
    cp -af $DEST/boot/memtest* $DEST/usr/lib/anaconda-runtime/boot
fi

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

find $DEST -name "*.a" | grep -v kernel-wrapper/wrapper.a | xargs rm -rf
find $DEST -name "lib*.la" |grep -v "usr/$LIBDIR/gtk-2.0" | xargs rm -rf

# nuke some python stuff we don't need
for d in idle distutils bsddb lib-old hotshot doctest.py pydoc.py site-packages/japanese site-packages/japanese.pth ; do
    rm -rf $DEST/$d
done

$DEST/usr/lib/anaconda-runtime/scrubtree $DEST

echo "Creating debug dir"
mkdir -p $DEST/usr/lib/debug
mkdir -p $DEST/usr/src/debug

find $DEST -name "*.py" | while read fn; do
    rm -f ${fn}o
    rm -f ${fn}c
    ln -sf /dev/null ${fn}c
done

# some python stuff we don't need for install image
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/distutils/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/lib-dynload/japanese
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/encodings/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/compiler/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/email/test/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/curses/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/pydoc.py