| 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 |
if [ ! -f "$BUILD_ROOT/usr/share/debootstrap/scripts/$dist" ] |
| 39 |
then |
| 40 |
dist=stable |
| 41 |
fi |
| 42 |
fi |
| 43 |
local myroot=debootstraproot |
| 44 |
test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1 |
| 45 |
if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/dists" ; then |
| 46 |
echo "creating repository for debootstrap..." |
| 47 |
createrepo_debian $BUILD_ROOT/.build.binaries ${arch} ${dist} |
| 48 |
fi |
| 49 |
FULL_PKG_LIST= |
| 50 |
for PKG in $BUILD_ROOT/.build.binaries/*.deb ; do |
| 51 |
PKG="${PKG##*/}" |
| 52 |
FULL_PKG_LIST="$FULL_PKG_LIST,${PKG%.deb}" |
| 53 |
done |
| 54 |
FULL_PKG_LIST="${FULL_PKG_LIST#,}" |
| 55 |
rm -rf "$BUILD_ROOT/$myroot" |
| •56 |
if deb_chroot $BUILD_ROOT dpkg --force-unsafe-io --version >/dev/null 2>&1 ; then |
| 57 |
mkdir -p "$BUILD_ROOT/$myroot/etc/dpkg/dpkg.cfg.d" |
| 58 |
echo force-unsafe-io > "$BUILD_ROOT/$myroot/etc/dpkg/dpkg.cfg.d/force-unsafe-io" |
| 59 |
fi |
| 60 |
|
| •61 |
set -- deb_chroot $BUILD_ROOT debootstrap --keep-debootstrap-dir --no-check-gpg --variant=buildd --arch="${arch}" --include="$FULL_PKG_LIST" "$dist" "$myroot" file:///.build.binaries |
| •62 |
echo "running debootstrap:$(printf ' %q' "$@")..." |
| •63 |
if ! "$@" || ! deb_chroot $BUILD_ROOT dpkg --configure -a; then |
| 64 |
cat $BUILD_ROOT/$myroot/debootstrap/debootstrap.log |
| 65 |
cleanup_and_exit 1 "Failed to setup debootstrap chroot" |
| 66 |
fi |
| 67 |
|
| 68 |
# adapt passwd |
| 69 |
if test $BUILD_USER = abuild ; then |
| 70 |
echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/$myroot/etc/passwd |
| 71 |
echo 'abuild:*:::::::' >>$BUILD_ROOT/$myroot/etc/shadow |
| 72 |
echo 'abuild:*::' >>$BUILD_ROOT/$myroot/etc/gshadow |
| 73 |
echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/$myroot/etc/group |
| 74 |
mkdir -p $BUILD_ROOT/$myroot/home/abuild |
| 75 |
chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/$myroot/home/abuild |
| 76 |
fi |
| 77 |
|
| 78 |
if ! test -e $BUILD_ROOT/$myroot/etc/hosts ; then |
| 79 |
cp $BUILD_ROOT/etc/hosts $BUILD_ROOT/$myroot/etc/hosts |
| 80 |
fi |
| 81 |
|
| •82 |
|
| 83 |
# Hack for glibc build, make localhost. resolve |
| 84 |
echo "127.0.0.2 localhost." >> $BUILD_ROOT/$myroot/etc/hosts |
| 85 |
cat $BUILD_ROOT/$myroot/etc/hosts |
| 86 |
|
| 87 |
# Mount special filesystem in the debootstrap build root |
| 88 |
mount -n -tproc none $BUILD_ROOT/$myroot/proc |
| 89 |
mount -n -tsysfs -o ro none $BUILD_ROOT/$myroot/sys |
| 90 |
mount -n -tdevpts -omode=0620,ptmxmode=0666,gid=5,newinstance, none $BUILD_ROOT/$myroot/dev/pts |
| 91 |
mkdir -p $BUILD_ROOT/$myroot/dev/shm |
| 92 |
mount -n -ttmpfs none $BUILD_ROOT/$myroot/dev/shm |
| 93 |
|
| •94 |
deb_chroot $BUILD_ROOT/$myroot apt-cache gencaches |
| 95 |
|
| 96 |
if ! test -e $BUILD_ROOT/$myroot/etc/hosts ; then |
| 97 |
cp $BUILD_ROOT/etc/hosts $BUILD_ROOT/$myroot/etc/hosts |
| 98 |
fi |
| 99 |
|
| 100 |
# move topdir over |
| 101 |
mv "$BUILD_ROOT/$TOPDIR" "$BUILD_ROOT/$myroot/${TOPDIR%/*}" |
| 102 |
|
| 103 |
# do the build |
| 104 |
dsc_build "$BUILD_ROOT/$myroot" |
| 105 |
|
| 106 |
umount -n $BUILD_ROOT/$myroot/proc/sys/fs/binfmt_misc 2>/dev/null || true |
| 107 |
umount -n $BUILD_ROOT/$myroot/proc |
| 108 |
umount -n $BUILD_ROOT/$myroot/sys |
| 109 |
umount -n $BUILD_ROOT/$myroot/dev/pts |
| 110 |
umount -n $BUILD_ROOT/$myroot/dev/shm |
| 111 |
|
| 112 |
# move topdir back |
| 113 |
mv "$BUILD_ROOT/$myroot/$TOPDIR" "$BUILD_ROOT/${TOPDIR%/*}" |
| 114 |
|
| 115 |
# move result |
| 116 |
dsc_move_build_result |
| 117 |
} |
| 118 |
|
| 119 |
recipe_resultdirs_debootstrap() { |
| 120 |
echo DEBS |
| 121 |
} |
| 122 |
|
| 123 |
recipe_cleanup_debootstrap() { |
| 124 |
: |
| 125 |
} |
| 126 |
|