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

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

RUN=1
PRODUCTPATH="anaconda"

while [ $# -gt 0 ]; do
    case $1 in
	--pkgorder)
	    PKGORDER=$2
	    PKGORDERSTR="--pkgorder $2"
	    shift; shift
	    ;;
	--comp)
	    COMPNAME=$2
	    shift; shift
	    ;;
	--version)
	    VERSION=$2
	    shift; shift
	    ;;
	--release)
	    RELEASESTR=$2
	    shift; shift
	    ;;
        --product)
	    PRODUCTSTR=$2
	    shift; shift
	    ;;
	--prodpath)
	    PRODUCTPATH=$2
	    shift; shift
	    ;;
	--debug)
	    DEBUGSTR="--debug"
	    shift
	    ;;
	--second)
	    RUN=2
	    shift
	    ;;
	--buildinstdir)
	    BUILDINSTDIR=$2
	    shift; shift
	    ;;
	--discs)
	    DISCSTR=$2
	    shift; shift
	    ;;
	*)
	    if [ -n "$DIR" -o ! -d $1/$PRODUCTPATH/RPMS ]; then
		usage
	    fi
	    DIR=$1
	    shift
	    ;;
    esac
done

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

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

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

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

if [ -z "$DISCSTR" ]; then
    DISCSTR="1,2,3"
fi

p=`cd $DIR; /bin/pwd`

if [ -z "$BUILDINSTDIR" ]; then
    BUILDINSTDIR=$p/buildinstall.tree.$$
    rm -rf $BUILDINSTDIR
    mkdir -p $BUILDINSTDIR
fi
TREEDIR=/tmp/treedir.$$

UPD_INSTROOT=$BUILDINSTDIR/upd-instroot
MK_IMAGES=$BUILDINSTDIR/mk-images
MK_STAMP=$BUILDINSTDIR/makestamp.py
BUILDINSTALL=$BUILDINSTDIR/buildinstall

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

firstRun() {
echo "Running buildinstall..."

pushd $BUILDINSTDIR
rpm2cpio $p/$PRODUCTPATH/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd './usr*'
popd

UPD_INSTROOT=./upd-instroot
MK_IMAGES=./mk-images
MK_STAMP=./makestamp.py
BUILDINSTALL=./buildinstall

for f in $UPD_INSTROOT $MK_IMAGES $MK_STAMP $BUILDINSTALL; do
    if [ ! -f $f ]; then
	cp -a $BUILDINSTDIR/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
    else
	cp -a $f* $BUILDINSTDIR/
    fi
done

UPD_INSTROOT=$BUILDINSTDIR/upd-instroot
MK_IMAGES=$BUILDINSTDIR/mk-images
MK_STAMP=$BUILDINSTDIR/makestamp.py
BUILDINSTALL=$BUILDINSTDIR/buildinstall

rm -rf $BUILDINSTDIR/usr

echo "Going to run buildinstall again"
# run it again for the second half
if [ -x /usr/bin/runroot ]; then
    runroot $COMPNAME --onlyone --arch $BUILDARCH "$BUILDINSTALL $DEBUGSTR --buildinstdir $BUILDINSTDIR --second $PKGORDERSTR --comp $COMPNAME --version $VERSION --release '\"$RELEASESTR\"' --product '\"$PRODUCTSTR\"' --prodpath $PRODUCTPATH --discs '\"$DISCSTR\"' $DIR" 
else
    $BUILDINSTALL $DEBUGSTR --buildinstdir $BUILDINSTDIR --second $PKGORDERSTR --comp $COMPNAME --version $VERSION --release "$RELEASESTR" --product "$PRODUCTSTR" --prodpath $PRODUCTPATH --discs "$DISCSTR" $DIR 
fi

rm -rf $BUILDINSTDIR
}

secondRun() {
echo "Building images..."
if [ -x /usr/bin/runroot ]; then
    runroot $COMPNAME --onlyone --arch $BUILDARCH "$UPD_INSTROOT $DEBUGSTR --comp $COMPNAME $p/$PRODUCTPATH/RPMS $TREEDIR/image-template $TREEDIR/instimage"
else
    $UPD_INSTROOT $DEBUGSTR --comp $COMPNAME $p/$PRODUCTPATH/RPMS $TREEDIR/image-template $TREEDIR/instimage
fi

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

echo "Making images..."
if [ -x /usr/bin/runroot ]; then
    runroot $COMPNAME --onlyone --arch $BUILDARCH "cd $BUILDINSTDIR\; ./mk-images $DEBUGSTR $p/$PRODUCTPATH/RPMS $p $TREEDIR/image-template $TREEDIR/instimage $BUILDARCH '\"$PRODUCTSTR\"' $VERSION $PRODUCTPATH"
else
    $MK_IMAGES $DEBUGSTR $p/$PRODUCTPATH/RPMS $p $TREEDIR/image-template $TREEDIR/instimage $BUILDARCH "$PRODUCTSTR" $VERSION $PRODUCTPATH
fi

echo "Writing .discinfo file"
$MK_STAMP --releasestr="$RELEASESTR" --arch=$BUILDARCH --discNum="$DISCSTR" --baseDir=$PRODUCTPATH/base --packagesDir=$PRODUCTPATH/RPMS --pixmapsDir=$PRODUCTPATH/pixmaps --outfile=$p/.discinfo

if [ -x /usr/bin/runroot ]; then
    runroot $COMPNAME --onlyone --arch $BUILDARCH "rm -rf $TREEDIR/image-template $TREEDIR/instimage"
else
    rm -rf $TREEDIR/image-template $TREEDIR/instimage
fi
}

if [ $RUN == 1 ]; then
    firstRun
else
    secondRun
fi