File: build-recipe-mock

package info (click to toggle)
obs-build 20180831-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 2,396 kB
  • sloc: perl: 10,030; sh: 3,142; ansic: 284; makefile: 151; python: 35
file content (104 lines) | stat: -rw-r--r-- 3,572 bytes parent folder | download | duplicates (2)
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
#
# mock 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_mock() {
    recipe_setup_spec "$@"
}

recipe_prepare_mock() {
    recipe_prepare_spec "$@"
}

recipe_build_mock() {
    test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1
    if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/repodata" ; then
	echo "creating repository for mock..."
	chroot $BUILD_ROOT createrepo --no-database --basedir /.build.binaries -o /.build.binaries /.build.binaries
    fi
    MOCK_CHROOT_SETUP_CMD="$(queryconfig --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" substitute mock:chroot_setup_cmd)"
    test -z "$MOCK_CHROOT_SETUP_CMD" && MOCK_CHROOT_SETUP_CMD="groupinstall buildsys-build"
    echo "config_opts['root'] = 'build'" > $BUILD_ROOT/etc/mock/build.cfg
    echo "config_opts['target_arch'] = '${BUILD_ARCH%%:*}'" >> $BUILD_ROOT/etc/mock/build.cfg
    echo "config_opts['plugin_conf']['ccache_enable'] = False" >> $BUILD_ROOT/etc/mock/build.cfg
    echo "config_opts['chroot_setup_cmd'] = '$MOCK_CHROOT_SETUP_CMD'" >> $BUILD_ROOT/etc/mock/build.cfg
    cat >> $BUILD_ROOT/etc/mock/build.cfg <<-'EOF'
	config_opts['yum.conf'] = """
	[main]
	cachedir=/var/cache/yum
	debuglevel=1
	reposdir=/dev/null
	logfile=/var/log/yum.log
	obsoletes=1
	gpgcheck=0
	assumeyes=1
	syslog_ident=mock
	syslog_device=

	[build]
	name=build
	baseurl=file:///.build.binaries
	"""
	EOF
    touch $BUILD_ROOT/etc/resolv.conf
    BUILD_SUCCEEDED=false
    echo "building src rpm..."
    MOCK_INIT_ARG=
    test "$DO_INIT" = true || MOCK_INIT_ARG=--no-clean
    if chroot $BUILD_ROOT /usr/bin/mock -r build $MOCK_INIT_ARG --buildsrpm --spec "$TOPDIR/SOURCES/$RECIPEFILE" --sources "$TOPDIR/SOURCES" ; then
	BUILT_SRPM=
	for i in "$BUILD_ROOT/var/lib/mock/build/result/"*src.rpm ; do
	    test -s "$i" && BUILT_SRPM="${i##*/}"
	done
	if test -n "$BUILT_SRPM" ; then
	    mkdir -p "$BUILD_ROOT/$TOPDIR/SRPMS"
	    mv "$BUILD_ROOT/var/lib/mock/build/result/$BUILT_SRPM" "$BUILD_ROOT/$TOPDIR/SRPMS/$BUILT_SRPM"
	    echo "building binary rpms..."
	    if chroot $BUILD_ROOT /usr/bin/mock -v -r build --rebuild --no-clean "$TOPDIR/SRPMS/$BUILT_SRPM" ; then
		BUILD_SUCCEEDED=true
		# move result over to TOPDIR
		rm -f "$TOPDIR/SRPMS/$BUILT_SRPM"
		for i in "$BUILD_ROOT/var/lib/mock/build/result/"*.rpm ; do
		    a="${i%.rpm}"
		    a="${a##*/}"
		    a="${a##*.}"
		    if test "$a" = src -o "$a" = nosrc ; then
			mkdir -p "$BUILD_ROOT/$TOPDIR/SRPMS"
			mv $i "$BUILD_ROOT/$TOPDIR/SRPMS/."
		    else
			mkdir -p "$BUILD_ROOT/$TOPDIR/RPMS/$a"
			mv $i "$BUILD_ROOT/$TOPDIR/RPMS/$a/."
		    fi
		done
	    fi
	fi
    fi
}

recipe_resultdirs_mock() {
    echo RPMS SRPMS
}

recipe_cleanup_mock() {
    echo RPMS SRPMS
}