2 # mock specific functions.
4 ################################################################
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 or 3 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program (see the file COPYING); if not, write to the
19 # Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 ################################################################
25 recipe_setup_spec "$@"
28 recipe_prepare_mock() {
29 recipe_prepare_spec "$@"
33 test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1
34 if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/repodata" ; then
35 echo "creating repository for mock..."
36 chroot $BUILD_ROOT createrepo --no-database --basedir /.build.binaries -o /.build.binaries /.build.binaries
38 MOCK_CHROOT_SETUP_CMD="$(queryconfig --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" substitute mock:chroot_setup_cmd)"
39 test -z "$MOCK_CHROOT_SETUP_CMD" && MOCK_CHROOT_SETUP_CMD="groupinstall buildsys-build"
40 echo "config_opts['root'] = 'build'" > $BUILD_ROOT/etc/mock/build.cfg
41 echo "config_opts['target_arch'] = '${BUILD_ARCH%%:*}'" >> $BUILD_ROOT/etc/mock/build.cfg
42 echo "config_opts['plugin_conf']['ccache_enable'] = False" >> $BUILD_ROOT/etc/mock/build.cfg
43 echo "config_opts['chroot_setup_cmd'] = '$MOCK_CHROOT_SETUP_CMD'" >> $BUILD_ROOT/etc/mock/build.cfg
44 cat >> $BUILD_ROOT/etc/mock/build.cfg <<-'EOF'
45 config_opts['yum.conf'] = """
47 cachedir=/var/cache/yum
50 logfile=/var/log/yum.log
59 baseurl=file:///.build.binaries
62 touch $BUILD_ROOT/etc/resolv.conf
64 echo "building src rpm..."
66 test "$DO_INIT" = true || MOCK_INIT_ARG=--no-clean
67 if chroot $BUILD_ROOT /usr/bin/mock -r build $MOCK_INIT_ARG --buildsrpm --spec "$TOPDIR/SOURCES/$RECIPEFILE" --sources "$TOPDIR/SOURCES" ; then
69 for i in "$BUILD_ROOT/var/lib/mock/build/result/"*src.rpm ; do
70 test -s "$i" && BUILT_SRPM="${i##*/}"
72 if test -n "$BUILT_SRPM" ; then
73 mkdir -p "$BUILD_ROOT/$TOPDIR/SRPMS"
74 mv "$BUILD_ROOT/var/lib/mock/build/result/$BUILT_SRPM" "$BUILD_ROOT/$TOPDIR/SRPMS/$BUILT_SRPM"
75 echo "building binary rpms..."
76 if chroot $BUILD_ROOT /usr/bin/mock -v -r build --rebuild --no-clean "$TOPDIR/SRPMS/$BUILT_SRPM" ; then
78 # move result over to TOPDIR
79 rm -f "$TOPDIR/SRPMS/$BUILT_SRPM"
80 for i in "$BUILD_ROOT/var/lib/mock/build/result/"*.rpm ; do
84 if test "$a" = src -o "$a" = nosrc ; then
85 mkdir -p "$BUILD_ROOT/$TOPDIR/SRPMS"
86 mv $i "$BUILD_ROOT/$TOPDIR/SRPMS/."
88 mkdir -p "$BUILD_ROOT/$TOPDIR/RPMS/$a"
89 mv $i "$BUILD_ROOT/$TOPDIR/RPMS/$a/."
97 recipe_resultdirs_mock() {