Debian Codegraph @

build-recipe-debootstrap

raw ◀ ▶
Source reconstructed at patch state 1 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
79 # Hack for glibc build, make localhost. resolve
80 echo "127.0.0.2 localhost." >> $BUILD_ROOT/$myroot/etc/hosts
81 cat $BUILD_ROOT/$myroot/etc/hosts
82
83 # Mount special filesystem in the debootstrap build root
84 mount -n -tproc none $BUILD_ROOT/$myroot/proc
85 mount -n -tsysfs -o ro none $BUILD_ROOT/$myroot/sys
86 mount -n -tdevpts -omode=0620,ptmxmode=0666,gid=5,newinstance, none $BUILD_ROOT/$myroot/dev/pts
87 mkdir -p $BUILD_ROOT/$myroot/dev/shm
88 mount -n -ttmpfs none $BUILD_ROOT/$myroot/dev/shm
89
90 chroot $BUILD_ROOT/$myroot apt-cache gencaches
91
92 if ! test -e $BUILD_ROOT/$myroot/etc/hosts ; then
93 cp $BUILD_ROOT/etc/hosts $BUILD_ROOT/$myroot/etc/hosts
94 fi
95
96 # move topdir over
97 mv "$BUILD_ROOT/$TOPDIR" "$BUILD_ROOT/$myroot/${TOPDIR%/*}"
98
99 # do the build
100 dsc_build "$BUILD_ROOT/$myroot"
101
102 umount -n $BUILD_ROOT/$myroot/proc/sys/fs/binfmt_misc 2>/dev/null || true
103 umount -n $BUILD_ROOT/$myroot/proc
104 umount -n $BUILD_ROOT/$myroot/sys
105 umount -n $BUILD_ROOT/$myroot/dev/pts
106 umount -n $BUILD_ROOT/$myroot/dev/shm
107
108 # move topdir back
109 mv "$BUILD_ROOT/$myroot/$TOPDIR" "$BUILD_ROOT/${TOPDIR%/*}"
110
111 # move result
112 dsc_move_build_result
113 }
114
115 recipe_resultdirs_debootstrap() {
116 echo DEBS
117 }
118
119 recipe_cleanup_debootstrap() {
120 :
121 }
122