Fix kvm support in Ubuntu
[tools/build.git] / build-recipe-arch
1 #
2 # Arch specific functions.
3 #
4 ################################################################
5 #
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 #
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.
11 #
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.
16 #
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
21 #
22 ################################################################
23
24 recipe_setup_arch() {
25     TOPDIR=/usr/src/packages
26     test "$DO_INIT_TOPDIR" = false || rm -rf "$BUILD_ROOT$TOPDIR"
27     mkdir -p "$BUILD_ROOT$TOPDIR"
28     mkdir -p "$BUILD_ROOT$TOPDIR/OTHER"
29     mkdir -p "$BUILD_ROOT$TOPDIR/SOURCES"
30     mkdir -p "$BUILD_ROOT/$TOPDIR/ARCHPKGS"
31     mkdir -p "$BUILD_ROOT/$TOPDIR/BUILD"
32     chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
33     cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
34     {
35         echo 'source /etc/makepkg.conf'
36         printf '%s=%s\n' \
37             BUILDDIR $TOPDIR/BUILD \
38             PKGDEST $TOPDIR/ARCHPKGS
39     } > $BUILD_ROOT$TOPDIR/makepkg.conf
40 }
41
42 recipe_prepare_arch() {
43     echo "Preparing sources..."
44     if ! _arch_recipe_makepkg -so "2>&1" ">/dev/null" ; then
45         echo "failed to prepare sources"
46         cleanup_and_exit 1
47     fi
48 }
49
50 recipe_build_arch() {
51     _arch_recipe_makepkg -ef < /dev/null && BUILD_SUCCEEDED=true
52 }
53
54 recipe_resultdirs_arch() {
55     echo ARCHPKGS
56 }
57
58 _arch_recipe_makepkg() {
59     chroot $BUILD_ROOT su -lc "source /etc/profile; cd $TOPDIR/SOURCES && makepkg --config ../makepkg.conf $*" $BUILD_USER
60 }