summaryrefslogtreecommitdiff
path: root/build-recipe-debootstrap
blob: 62ab7d5b323553fe6717a89be4fd5d48a0f4dcd0 (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
#
# debootstrap 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_debootstrap() {
    recipe_setup_dsc "$@"
}

recipe_prepare_debootstrap() {
    recipe_prepare_dsc "$@"
}

recipe_build_debootstrap() {
    local arch=$(chroot $BUILD_ROOT su -c "dpkg-architecture -qDEB_BUILD_ARCH")
    local dist=$(chroot $BUILD_ROOT su -c "lsb_release --codename --short")
    local myroot=debootstraproot
    test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1
    if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/dists" ; then
	echo "creating repository for debootstrap..."
	createrepo_debian $BUILD_ROOT/.build.binaries ${arch} ${dist}
    fi
    FULL_PKG_LIST=
    for PKG in $BUILD_ROOT/.build.binaries/*.deb ; do
	PKG="${PKG##*/}"
	FULL_PKG_LIST="$FULL_PKG_LIST,${PKG%.deb}"
    done
    FULL_PKG_LIST="${FULL_PKG_LIST#,}"
    rm -rf "$BUILD_ROOT/$myroot"
    set -- chroot $BUILD_ROOT debootstrap --keep-debootstrap-dir --no-check-gpg --variant=buildd --arch="${arch}" --include="$FULL_PKG_LIST" "$dist" "$myroot" file:///.build.binaries
    echo "running debootstrap..."
    if ! "$@" || ! chroot $BUILD_ROOT dpkg --configure -a; then
        cat $BUILD_ROOT/debootstrap/debootstrap.log
        echo "Failed to setup debootstrap chroot"
        cleanup_and_exit 1
    fi

    # adapt passwd
    if test $BUILD_USER = abuild ; then
	echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/$myroot/etc/passwd
	echo 'abuild:*::' >>$BUILD_ROOT/$myroot/etc/gshadow
	echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/$myroot/etc/group
	mkdir -p $BUILD_ROOT/$myroot/home/abuild
	chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/$myroot/home/abuild
    fi

    # move topdir over
    mv "$BUILD_ROOT/$TOPDIR" "$BUILD_ROOT/$myroot/${TOPDIR%/*}"

    # do the build
    dsc_build "$BUILD_ROOT/$myroot"

    # move topdir back
    mv "$BUILD_ROOT/$myroot/$TOPDIR" "$BUILD_ROOT/${TOPDIR%/*}"

    # move result
    dsc_move_build_result
}

recipe_resultdirs_debootstrap() {
    echo DEBS
}