blob: 71641ccb8052a92c53dab8863574b8aeb134f364 (
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
|
#!/bin/bash
#
# buildinstall
#
# Copyright (C) 2007 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/>.
#
die() {
[ -n "$TREEDIR" ] && rm -rf $TREEDIR
[ -n "$BUILDINSTDIR" ] && rm -rf $BUILDINSTDIR
[ -n "$yumconf" ] && rm -rf $yumconf
echo "Aborting buildinstall"
echo "$@"
exit 1
}
usage() {
echo "Usage: buildinstall --version <version> --product <product> --release <comment> [--output outputdir] [--discs <discstring>] <root>" >&2
exit 1
}
PRODUCTPATH="anaconda"
while [ $# -gt 0 ]; do
case $1 in
# general options affecting how we build things
--nogr)
NOGRSTR="--nogr"
shift
;;
--debug)
DEBUGSTR="--debug"
shift
;;
# release information
--version)
VERSION=$2
shift; shift
;;
--release)
RELEASESTR=$2
shift; shift
;;
--product)
PRODUCTSTR=$2
shift; shift
;;
--variant)
VARIANT=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
OUTPUT=$2
shift; shift
;;
--updates)
UPDATES=$2
shift; shift
;;
--mirrorlist)
MIRRORLIST="$MIRRORLIST $2"
shift; shift
;;
*)
if [ -z "$REPO" ]; then
REPO=$1
else
EXTRA_REPOS="$EXTRA_REPOS $1"
fi
shift
;;
esac
done
if [ -z "$PRODUCTSTR" ]; then
usage
fi
if [ -z "$VERSION" ]; then
usage
fi
if [ -z "$REPO" ]; then
usage
fi
if [ -z "$RELEASESTR" ]; then
usage
fi
if [ -z "$BUGURL" ]; then
BUGURL="your distribution provided bug reporting tool."
fi
if [[ "$REPO" =~ ^/ ]]; then
[ -n "$OUTPUT" ] || OUTPUT=$REPO
REPO="file://$REPO"
fi
if [ -z "$OUTPUT" ]; then
usage
fi
if [ ! -d "$OUTPUT" ]; then
mkdir -p $OUTPUT
fi
# The first -release and -logos package we are going to look for is the lowercase
# equivalent of the PRODUCTSTR
export brandpkgname="`echo $PRODUCTSTR | tr '[:upper:]' '[:lower:]'`"
BUILDINSTDIR=$(mktemp -d ${TMPDIR:-/tmp}/buildinstall.tree.XXXXXX)
TREEDIR=$(mktemp -d ${TMPDIR:-/tmp}/treedir.XXXXXX)
CACHEDIR=$(mktemp -d ${TMPDIR:-/tmp}/yumcache.XXXXXX)
yumconf=$(mktemp ${TMPDIR:-/tmp}/yum.conf.XXXXXX)
cat > $yumconf <<EOF
[main]
cachedir=$CACHEDIR
keepcache=0
gpgcheck=0
plugins=0
reposdir=
tsflags=nodocs
[anacondarepo]
name=anaconda repo
baseurl=$REPO
enabled=1
EOF
n=1
for r in $EXTRA_REPOS; do
if [[ $r =~ ^/ ]]; then
r="file://$r"
fi
cat >> $yumconf <<EOF
[anaconda-extrarepo-$n]
name=anaconda extra repo $n
baseurl=$r
enabled=1
EOF
let n++
done
n=1
for l in $MIRRORLIST; do
cat >> $yumconf <<EOF
[anaconda-mirrorlistrepo-$n]
name=anaconda mirrorlist repo $n
mirrorlist=$l
enabled=1
EOF
let n++
done
echo "Running buildinstall..."
pushd $BUILDINSTDIR
BUILDARCH=`repoquery -c $yumconf --qf "%{ARCH}\n" anaconda`
# This is a crappy implementation but x86 is the only place we currently see
# BUILDARCH != BASEARCH (e.g. i586 != i386) so it'll suffice.
BASEARCH=`echo $BUILDARCH | sed -e 's/i.86/i386/'`
yumdownloader -c $yumconf anaconda || exit 1
rpm2cpio anaconda*rpm | cpio --quiet -iumd './usr*'
rm -f anaconda*rpm
popd
UPD_INSTROOT=./upd-instroot
MK_IMAGES=./mk-images
MK_TREEINFO=./maketreeinfo.py
MK_STAMP=./makestamp.py
BUILDINSTALL=./buildinstall
for f in $UPD_INSTROOT $MK_IMAGES $MK_STAMP $MK_TREEINFO $BUILDINSTALL; do
if [ -n "$UPDATES" -a -f $UPDATES/usr/lib/anaconda-runtime/$f ]; then
cp -a $UPDATES/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
elif [ ! -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_TREEINFO=$BUILDINSTDIR/maketreeinfo.py
MK_STAMP=$BUILDINSTDIR/makestamp.py
BUILDINSTALL=$BUILDINSTDIR/buildinstall
if [ -n "$UPDATES" ]; then UPDATES="--updates $UPDATES"; fi
echo "Building images..."
$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH $UPDATES --imgdir $TREEDIR/install $yumconf || die "upd-instroot failed"
echo "Writing .treeinfo file..."
# NOTE --arch must match MK_IMAGES or the resulting treeinfo will be invalid
$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BASEARCH --outfile=$OUTPUT/.treeinfo
# FIXME: need to update mk-images to take the yumconf
echo "Making images..."
$MK_IMAGES $DEBUGSTR $NOGRSTR --imgdir $TREEDIR/install --arch $BASEARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" --output $OUTPUT $yumconf || die "image creation failed"
echo "Writing .discinfo file"
$MK_STAMP --releasestr="$RELEASESTR" --arch=$BASEARCH --discNum="ALL" --outfile=$OUTPUT/.discinfo
rm -rf $TREEDIR $BUILDINSTDIR
rm -f $yumconf
|