Debian Codegraph @

build-recipe-debootstrap

raw ◀ ▶
Source reconstructed at patch state 0 of 4 — not the installed (fully patched) source.
4 Debian patches touch this file
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 if chroot $BUILD_ROOT grep -q '/sid' /etc/debian_version ; then
35 local dist=unstable
36 else
37 local dist=$(chroot $BUILD_ROOT su -c "lsb_release --codename --short")
38 fi
39 local myroot=debootstraproot
40 test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1
41 if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/dists" ; then
42 echo "creating repository for debootstrap..."
43 createrepo_debian $BUILD_ROOT/.build.binaries ${arch} ${dist}
44 fi
45 FULL_PKG_LIST=
46 for PKG in $BUILD_ROOT/.build.binaries/*.deb ; do
47 PKG="${PKG##*/}"
48 FULL_PKG_LIST="$FULL_PKG_LIST,${PKG%.deb}"
49 done
50 FULL_PKG_LIST="${FULL_PKG_LIST#,}"
51 rm -rf "$BUILD_ROOT/$myroot"
52 if chroot $BUILD_ROOT dpkg --force-unsafe-io --version >/dev/null 2>&1 ; then
53 mkdir -p "$BUILD_ROOT/$myroot/etc/dpkg/dpkg.cfg.d"
54 echo force-unsafe-io > "$BUILD_ROOT/$myroot/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
55 fi
56
57 set -- chroot $BUILD_ROOT debootstrap --keep-debootstrap-dir --no-check-gpg --variant=buildd --arch="${arch}" --include="$FULL_PKG_LIST" "$dist" "$myroot" file:///.build.binaries
58 echo "running debootstrap..."
59 if ! "$@" || ! chroot $BUILD_ROOT dpkg --configure -a; then
60 cat $BUILD_ROOT/$myroot/debootstrap/debootstrap.log
61 cleanup_and_exit 1 "Failed to setup debootstrap chroot"
62 fi
63
64 # adapt passwd
65 if test $BUILD_USER = abuild ; then
66 echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/$myroot/etc/passwd
67 echo 'abuild:*:::::::' >>$BUILD_ROOT/$myroot/etc/shadow
68 echo 'abuild:*::' >>$BUILD_ROOT/$myroot/etc/gshadow
69 echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/$myroot/etc/group
70 mkdir -p $BUILD_ROOT/$myroot/home/abuild
71 chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/$myroot/home/abuild
72 fi
73
74 if ! test -e $BUILD_ROOT/$myroot/etc/hosts ; then
75 cp $BUILD_ROOT/etc/hosts $BUILD_ROOT/$myroot/etc/hosts
76 fi
77
78 # Mount special filesystem in the debootstrap build root
79 mount -n -tproc none $BUILD_ROOT/$myroot/proc
80 mount -n -tsysfs -o ro none $BUILD_ROOT/$myroot/sys
81 mount -n -tdevpts -omode=0620,ptmxmode=0666,gid=5,newinstance, none $BUILD_ROOT/$myroot/dev/pts
82 mkdir -p $BUILD_ROOT/$myroot/dev/shm
83 mount -n -ttmpfs none $BUILD_ROOT/$myroot/dev/shm
84
85 chroot $BUILD_ROOT/$myroot apt-cache gencaches
86
87 if ! test -e $BUILD_ROOT/$myroot/etc/hosts ; then
88 cp $BUILD_ROOT/etc/hosts $BUILD_ROOT/$myroot/etc/hosts
89 fi
90
91 # move topdir over
92 mv "$BUILD_ROOT/$TOPDIR" "$BUILD_ROOT/$myroot/${TOPDIR%/*}"
93
94 # do the build
95 dsc_build "$BUILD_ROOT/$myroot"
96
97 umount -n $BUILD_ROOT/$myroot/proc/sys/fs/binfmt_misc 2>/dev/null || true
98 umount -n $BUILD_ROOT/$myroot/proc
99 umount -n $BUILD_ROOT/$myroot/sys
100 umount -n $BUILD_ROOT/$myroot/dev/pts
101 umount -n $BUILD_ROOT/$myroot/dev/shm
102
103 # move topdir back
104 mv "$BUILD_ROOT/$myroot/$TOPDIR" "$BUILD_ROOT/${TOPDIR%/*}"
105
106 # move result
107 dsc_move_build_result
108 }
109
110 recipe_resultdirs_debootstrap() {
111 echo DEBS
112 }
113
114 recipe_cleanup_debootstrap() {
115 :
116 }
117