blob: 735b57e9a2eaf0a5e877675bf18f01042364fa01 (
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
|
#
# spec specific functions.
#
################################################################
#
# Copyright (c) 1995-2014 SUSE Linux Products GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or 3 as
# published by the Free Software Foundation.
#
# 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 (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
################################################################
recipe_setup_spec() {
TOPDIR=`chroot $BUILD_ROOT su -c "rpm --eval '%_topdir'" - $BUILD_USER`
if test -z "$TOPDIR"; then
echo "Error: TOPDIR empty"
cleanup_and_exit 1
fi
if [ "$NO_TOPDIR_CLEANUP" = false ]; then
rm -rf "$BUILD_ROOT$TOPDIR"
for i in BUILD RPMS/`uname -m` RPMS/i386 RPMS/noarch SOURCES SPECS SRPMS BUILDROOT OTHER ; do
mkdir -p $BUILD_ROOT$TOPDIR/$i
done
fi
chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
mkdir -p $BUILD_ROOT$TOPDIR/SOURCES
cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
}
recipe_prepare_spec() {
args=()
if test -n "$RELEASE"; then
args=(--release "$RELEASE")
fi
rawcfgmacros=.rpmmacros
test "$BUILDTYPE" = debbuild && rawcfgmacros=.debmacros
# fixup specfile
CHANGELOGARGS=
test -n "$CHANGELOG" -a -f "$BUILD_ROOT/.build-changelog" && CHANGELOGARGS="--changelog $BUILD_ROOT/.build-changelog"
substitutedeps "${args[@]}" --root "$BUILD_ROOT" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1
# fix rpmrc if we are compiling for i686
test -f $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 && mv $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 $BUILD_ROOT/usr/lib/rpm/rpmrc
if test -e $BUILD_ROOT/usr/lib/rpm/rpmrc -a "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
mv $BUILD_ROOT/usr/lib/rpm/rpmrc $BUILD_ROOT/usr/lib/rpm/rpmrc_i586
sed -e 's/^buildarchtranslate: athlon.*/buildarchtranslate: athlon: i686/' -e 's/^buildarchtranslate: i686.*/buildarchtranslate: i686: i686/' < $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 > $BUILD_ROOT/usr/lib/rpm/rpmrc
fi
if test "$DO_BUILD" = false ; then
cleanup_and_exit 0
fi
# extract macros from configuration
queryconfig rawmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_ROOT/root/$rawcfgmacros
if test -n "$BUILD_DEBUG" && test "$BUILDTYPE" != debbuild ; then
echo '
%prep %{?!__debug_package:%{?_build_create_debug:%?_build_insert_debug_package}}%%prep
%package %{?!__debug_package:%{?_build_create_debug:%?_build_insert_debug_package}}%%package
%_build_insert_debug_package \
%global __debug_package 1 \
%undefine _enable_debug_packages \
%debug_package
' >> $BUILD_ROOT/root/$rawcfgmacros
fi
if test -n "$BUILD_JOBS" ; then
cat >> $BUILD_ROOT/root/$rawcfgmacros <<-EOF
%jobs $BUILD_JOBS
%_smp_mflags -j$BUILD_JOBS
EOF
fi
test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/$rawcfgmacros $BUILD_ROOT/home/abuild/$rawcfgmacros
# extract optflags from configuration
queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" optflags ${BUILD_DEBUG:+debug} > $BUILD_ROOT/root/.rpmrc
test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc
if test -z "$ABUILD_TARGET"; then
ABUILD_TARGET=$(queryconfig target --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" )
test -z "$ABUILD_TARGET" || echo "build target is $ABUILD_TARGET"
fi
# report specfile changes
if test -f $BUILD_ROOT/.spec.new ; then
if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE $BUILD_ROOT/.spec.new ; then
echo -----------------------------------------------------------------
echo "I have the following modifications for $RECIPEFILE:"
sed -e "/^%changelog/q" $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE > $BUILD_ROOT/.spec.t1
sed -e "/^%changelog/q" $BUILD_ROOT/.spec.new > $BUILD_ROOT/.spec.t2
diff $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2
rm -f $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2
mv $BUILD_ROOT/.spec.new $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE
else
rm -f $BUILD_ROOT/.spec.new
fi
fi
}
recipe_build_spec() {
test -z "$BUILD_RPM_BUILD_STAGE" && BUILD_RPM_BUILD_STAGE=-ba
rpmbuild=rpmbuild
test -x $BUILD_ROOT/usr/bin/rpmbuild || rpmbuild=rpm
test "$BUILDTYPE" = debbuild && rpmbuild=debbuild
# XXX: move _srcdefattr to macro file?
rpmbopts=("--define" "_srcdefattr (-,root,root)")
if test "$DO_CHECKS" != true ; then
if chroot "$BUILD_ROOT" "$rpmbuild" --nocheck --help >/dev/null 2>&1; then
rpmbopts[${#rpmbopts[@]}]="--nocheck"
else
echo "warning: --nocheck is not supported by this $rpmbuild version"
fi
fi
if test "$rpmbuild" == "rpmbuild" ; then
# use only --nosignature for rpm v4
rpmbopts[${#rpmbopts[@]}]="--nosignature"
fi
if test -n "$ABUILD_TARGET" ; then
rpmbopts[${#rpmbopts[@]}]="--target=$ABUILD_TARGET"
fi
if test -n "$BUILD_DEBUG" ; then
rpmbopts[${#rpmbopts[@]}]='--define'
rpmbopts[${#rpmbopts[@]}]="_build_create_debug 1"
fi
if test -n "$DISTURL" ; then
rpmbopts[${#rpmbopts[@]}]='--define'
rpmbopts[${#rpmbopts[@]}]="disturl $DISTURL"
fi
if test -n "$RSYNCDONE" ; then
rpmbopts[${#rpmbopts[@]}]='--define'
rpmbopts[${#rpmbopts[@]}]="RSYNCDONE 1"
fi
# su involves a shell which would require even more
# complicated quoting to bypass than this
if test "$SHORT_CIRCUIT" = false ; then
rpmbopts[${#rpmbopts[@]}]="$BUILD_RPM_BUILD_STAGE"
toshellscript $rpmbuild \
"${definesnstuff[@]}" \
"${rpmbopts[@]}" \
"$TOPDIR/SOURCES/$RECIPEFILE" \
> $BUILD_ROOT/.build.command
else
rpmbopts[${#rpmbopts[@]}]='--short-circuit'
buildopts="-bc -bi -bb -bs"
cmds=""
echo "#!/bin/sh -x" >$BUILD_ROOT/.build.command
echo "set -e" >>$BUILD_ROOT/.build.command
for opt in $buildopts
do
shellquote $rpmbuild \
"${definesnstuff[@]}" \
"${rpmbopts[@]}" $opt \
"$TOPDIR/SOURCES/$RECIPEFILE" \
>> $BUILD_ROOT/.build.command
echo >>$BUILD_ROOT/.build.command
[ "$opt" == "$BUILD_RPM_BUILD_STAGE" ] && break
done
fi
chmod 755 $BUILD_ROOT/.build.command
check_exit
if test -n "$RUN_SHELL"; then
chroot $BUILD_ROOT su -
else
chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true
fi
}
recipe_resultdirs_spec() {
echo RPMS SRPMS
}
recipe_unpack_srcrpm() {
test -n "$LIST_STATE" || echo "processing src rpm $SRCDIR/$RECIPEFILE ..."
MYSRCDIR="$BUILD_ROOT/.build-srcdir"
rm -rf "$MYSRCDIR"
mkdir -p "$MYSRCDIR"
cd $MYSRCDIR || cleanup_and_exit 1
$BUILD_DIR/unrpm -q $SRCDIR/$RECIPEFILE || {
echo "could not unpack $RECIPEFILE."
cleanup_and_exit 1
}
for RECIPEFILE in *.spec ; do : ; done
}
# post build functions... move somewhere else?
recipe_check_file_owners() {
echo "... checking for files with abuild user/group"
BADFILE=
while read un gn fn ; do
if test "$un" = abuild -o "$gn" = abuild -o "$un" = ${ABUILD_UID} -o "$gn" = ${ABUILD_GID} ; then
echo " $un $gn $fn"
BADFILE=true
fi
done < <(rpm -qp --qf '[%{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]' $RPMS)
if test -n "$BADFILE" ; then
echo "please fix your filelist (e.g. add defattr)"
cleanup_and_exit 1
fi
}
recipe_run_rpmlint() {
if ! test -x "$BUILD_ROOT/opt/testing/bin/rpmlint" ; then
return
fi
LINT_RPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/RPMS \
\( -name "*-debuginfo-*" -o -name "*-debugsource-*" \
-o -name "*-32bit-*" -o -name "*-64bit-*" \
-o -name "*-x86-*" -o -name "*-ia32-*" \) -prune \
-o -type f -name '*.rpm' -print))
SRPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/SRPMS -type f -name "*.rpm"))
echo
echo "RPMLINT report:"
echo "==============="
rpmlint_logfile=$TOPDIR/OTHER/rpmlint.log
rm -f "$BUILD_ROOT$rpmlint_logfile"
ret=0
mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
chroot $BUILD_ROOT su -s /opt/testing/bin/rpmlint "$BUILD_USER" -- \
--info ${LINT_RPM_FILE_LIST[*]#$BUILD_ROOT} \
${SRPM_FILE_LIST[*]#$BUILD_ROOT} > >(tee "$BUILD_ROOT$rpmlint_logfile") 2>&1 || ret=1
echo
umount -n $BUILD_ROOT/proc 2>/dev/null || true
if test "$ret" = 1 ; then
cleanup_and_exit 1
fi
}
recipe_compare_oldpackages() {
if test -x "$BUILD_ROOT/usr/lib/build/same-build-result.sh" ; then
echo "... comparing built packages with the former built"
mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
if chroot $BUILD_ROOT /usr/lib/build/same-build-result.sh /.build.oldpackages "$TOPDIR/RPMS" "$TOPDIR/SRPMS"; then
chroot $BUILD_ROOT touch /.build/.same_result_marker
# XXX: dirty build service hack. fix bs_worker. Search for
# 'same_result_marker' for traces of a first try to get rid of this
if test -n "$REASON" -a -n "$DISTURL" ; then
exitcode=2
fi
fi
umount -n $BUILD_ROOT/proc 2>/dev/null || true
fi
}
recipe_create_deltarpms() {
if test -x "$BUILD_ROOT/usr/bin/makedeltarpm" -a -x $BUILD_ROOT/usr/lib/build/mkdrpms ; then
echo "... creating delta rpms"
ds=("$BUILD_ROOT/$TOPDIR"/RPMS/* "$BUILD_ROOT$TOPDIR/SRPMS")
chroot $BUILD_ROOT /usr/lib/build/mkdrpms /.build.oldpackages "${ds[@]#$BUILD_ROOT}"
fi
}
|