summaryrefslogtreecommitdiffstats
path: root/scripts/buildinstall
blob: 2206629ed9aaec9d0bf871aedbacc88b46aef4dc (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
#!/bin/bash

usage() {
	echo "Usage: buildinstall [--comp <component>] [--pkgorder <file>] [--version <version>] [--release <comment>] <root>" >&2
	exit 1
}

COMPNAME=dist-7.0

while [ $# -gt 0 ]; do
    case $1 in
	--pkgorder)
	    PKGORDER=$2
	    shift; shift
	    ;;
	--comp)
	    COMPNAME=$2
	    shift; shift
	    ;;
	--version)
	    VERSION=$2
	    shift; shift
	    ;;
	--release)
	    RELEASESTR=$2
	    shift; shift
	    ;;
	*)
	    if [ -n "$DIR" -o ! -d $1/RedHat/RPMS ]; then
		usage
	    fi
	    DIR=$1
	    shift
	    ;;
    esac
done

if [ -z "$VERSION" ]; then
    VERSION=7.1
fi

if [ -z "$DIR" ]; then
    usage
fi

if [ -z "$RELEASESTR" ]; then
    usage
fi

p=`cd $DIR; /bin/pwd | sed 's,/md1/,/,g'`

BUILDINSTDIR=$p/buildinstall.tree.$$

rm -rf $BUILDINSTDIR
mkdir -p $BUILDINSTDIR

UPD_INSTROOT=./upd-instroot
MK_IMAGES=./mk-images

BUILDARCH=`rpm -qp --qf "%{ARCH}" $p/RedHat/RPMS/anaconda-runtime-[0-9]*`

if [ ! -f $UPD_INSTROOT ]; then
    cd $BUILDINSTDIR
    rpm2cpio $p/RedHat/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd ./usr/lib/anaconda-runtime/upd-instroot usr/lib/anaconda-runtime/upd-instroot
    mv usr/lib/anaconda-runtime/upd-instroot .
    rm -rf usr
else
    cp -a $UPD_INSTROOT $BUILDINSTDIR/upd-instroot
fi
UPD_INSTROOT=$BUILDINSTDIR/upd-instroot

if [ ! -f $MK_IMAGES ]; then
    cd $BUILDINSTDIR
    rpm2cpio $p/RedHat/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd ./usr/lib/anaconda-runtime/mk-images* usr/lib/anaconda-runtime/mk-images*
    mv usr/lib/anaconda-runtime/mk-images* .
    rm -rf usr
else
    cp $MK_IMAGES* $BUILDINSTDIR/
fi
MK_IMAGES=$BUILDINSTDIR/mk-images

echo "Building images..."
$UPD_INSTROOT --comp $COMPNAME $p/RedHat/RPMS $p/image-template $p/RedHat/instimage

# XXX hack - msw
if [ $BUILDARCH = "sparc" ]; then
    BUILDARCH=sparc64
fi

if [ -n "$PKGORDER" -a -x $p/RedHat/instimage/usr/lib/anaconda-runtime/pkgorder ]; then
    echo "Getting package order..."
    if [ -x /usr/bin/runroot ]; then
	runroot --quiet $COMPNAME --onlyone --arch $BUILDARCH \
	    "PYTHONPATH=$p/RedHat/instimage/usr/lib/anaconda $p/RedHat/instimage/usr/lib/anaconda-runtime/pkgorder $p $BUILDARCH" > $PKGORDER
    else
	PYTHONPATH=$p/RedHat/instimage/usr/lib/anaconda $p/RedHat/instimage/usr/lib/anaconda-runtime/pkgorder $p $BUILDARCH > $PKGORDER
    fi
fi

if [ -x /usr/bin/runroot ]; then
    runroot $COMPNAME --onlyone --arch $BUILDARCH "cd $BUILDINSTDIR\; ./mk-images $p/RedHat/RPMS $p $p/image-template $BUILDARCH $VERSION"
else
    $MK_IMAGES $p/RedHat/RPMS $p $p/image-template $BUILDARCH $VERSION
fi

MK_STAMP=./makestamp.py
echo "Writing .discinfo file"
if [ ! -f $MK_STAMP ]; then
    cd $BUILDINSTDIR
    rpm2cpio $p/RedHat/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd ./usr/lib/anaconda-runtime/makestamp* usr/lib/anaconda-runtime/makestamp*
    mv usr/lib/anaconda-runtime/makestamp* .
    rm -rf usr
else
    cp $MK_STAMP* $BUILDINSTDIR/
fi
MK_STAMP=$BUILDINSTDIR/makestamp.py

$MK_STAMP --releasestr="$RELEASESTR" --arch=$BUILDARCH --discNum="1,2,3" --baseDir=RedHat/base --packagesDir=RedHat/RPMS --pixmapsDir=RedHat/pixmaps --outfile=$p/.discinfo

rm -rf $BUILDINSTDIR
rm -rf $p/image-template $p/RedHat/instimage