XFix gbs full build error: binary not found
[tools/build.git] / build-recipe-debootstrap
1 #
2 # debootstrap 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_debootstrap() {
25     recipe_setup_dsc "$@"
26 }
27
28 recipe_prepare_debootstrap() {
29     recipe_prepare_dsc "$@"
30 }
31
32 recipe_build_debootstrap() {
33     local arch=$(chroot $BUILD_ROOT su -c "dpkg-architecture -qDEB_BUILD_ARCH")
34     local dist=$(chroot $BUILD_ROOT su -c "lsb_release --codename --short")
35     local myroot=debootstraproot
36     test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1
37     if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/dists" ; then
38         echo "creating repository for debootstrap..."
39         createrepo_debian $BUILD_ROOT/.build.binaries ${arch} ${dist}
40     fi
41     FULL_PKG_LIST=
42     for PKG in $BUILD_ROOT/.build.binaries/*.deb ; do
43         PKG="${PKG##*/}"
44         FULL_PKG_LIST="$FULL_PKG_LIST,${PKG%.deb}"
45     done
46     FULL_PKG_LIST="${FULL_PKG_LIST#,}"
47     rm -rf "$BUILD_ROOT/$myroot"
48     if chroot $BUILD_ROOT dpkg --force-unsafe-io --version >/dev/null 2>&1 ; then
49         mkdir -p "$BUILD_ROOT/$myroot/etc/dpkg/dpkg.cfg.d"
50         echo force-unsafe-io > "$BUILD_ROOT/$myroot/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
51     fi
52     set -- chroot $BUILD_ROOT debootstrap --keep-debootstrap-dir --no-check-gpg --variant=buildd --arch="${arch}" --include="$FULL_PKG_LIST" "$dist" "$myroot" file:///.build.binaries
53     echo "running debootstrap..."
54     if ! "$@" || ! chroot $BUILD_ROOT dpkg --configure -a; then
55         cat $BUILD_ROOT/debootstrap/debootstrap.log
56         echo "Failed to setup debootstrap chroot"
57         cleanup_and_exit 1
58     fi
59
60     # adapt passwd
61     if test $BUILD_USER = abuild ; then
62         echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/$myroot/etc/passwd
63         echo 'abuild:*::' >>$BUILD_ROOT/$myroot/etc/gshadow
64         echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/$myroot/etc/group
65         mkdir -p $BUILD_ROOT/$myroot/home/abuild
66         chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/$myroot/home/abuild
67     fi
68
69     # move topdir over
70     mv "$BUILD_ROOT/$TOPDIR" "$BUILD_ROOT/$myroot/${TOPDIR%/*}"
71
72     # do the build
73     dsc_build "$BUILD_ROOT/$myroot"
74
75     # move topdir back
76     mv "$BUILD_ROOT/$myroot/$TOPDIR" "$BUILD_ROOT/${TOPDIR%/*}"
77
78     # move result
79     dsc_move_build_result
80 }
81
82 recipe_resultdirs_debootstrap() {
83     echo DEBS
84 }
85