[ci] Enable IRC notifications from travis
[xapian.git] / xapian-maintainer-tools / debian / create-chroot
blob76301b5258841be9deab814e467e705371aed40c
1 #!/bin/sh
2 # Create a chroot for a specified Debian or Ubuntu distribution
3 # suitable for package building.
5 # Copyright (C) 2006,2007,2009 Olly Betts
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 # Requires these packages installed: dchroot debootstrap dpkg-dev perl
23 # You can use the new chroot interactively like so:
24 # sudo dchroot -c etch-i386
26 CHROOT_BASE_PATH=/chroot
28 #DEBIAN_MIRROR=http://ftp.de.debian.org/debian
29 DEBIAN_MIRROR=http://debian.ihug.co.nz/debian
31 #UBUNTU_MIRROR=http://gb.archive.ubuntu.com/ubuntu
32 UBUNTU_MIRROR=http://nz2.archive.ubuntu.com/ubuntu
34 DCHROOT_CONF=/etc/dchroot.conf
36 set -e
37 if [ 1 != $# -a 2 != $# ] ; then
38 echo "Usage: $0 DISTRO [arch]"
39 echo "e.g. $0 etch i386"
40 exit 1
43 DISTRO=$1
45 _C=
46 #if [ sid = "$DISTRO" ] ; then
47 # _C=-c
48 #fi
50 if [ 2 = $# ] ; then
51 DEBIAN_BUILD_ARCH=$2
52 export DEBIAN_BUILD_ARCH
53 DEBIAN_HOST_ARCH=$2
54 export DEBIAN_HOST_ARCH
55 # DEBIAN_BUILDARCH=$2
56 # export DEBIAN_BUILDARCH
59 eval "`dpkg-architecture|grep ^DEBIAN_BUILD_ARCH=`"
60 distro_arch=$DISTRO-$DEBIAN_BUILD_ARCH
61 chroot_path=$CHROOT_BASE_PATH/$distro_arch
63 if test -f "$DCHROOT_CONF" ; then
64 # If DCHROOT_CONF exists then remove any existing entry for this chroot.
65 perl -ni -e 'print unless /^\Q'"$distro_arch"'\E\b/' "$DCHROOT_CONF"
68 case $DISTRO in
69 sid|lenny|squeeze)
70 mkdir "$chroot_path"
71 mirror=$DEBIAN_MIRROR
72 # Need to specify --mirror to allow running on Ubuntu.
73 debootstrap --variant=buildd --arch $DEBIAN_BUILD_ARCH "$DISTRO" "$chroot_path" "$mirror"
75 dapper|hardy|intrepid|jaunty|karmic|lucid)
76 pkg_for_distros_up_to=intrepid
77 pkg=debootstrap_1.0.10_all.deb
78 if [ ! -f /usr/share/debootstrap/scripts/$DISTRO ] && \
79 [ ! -f /usr/lib/debootstrap/scripts/$DISTRO ] ; then
80 cat <<END
81 Your debootstrap installation doesn't know how to bootstrap a $DISTRO chroot.
82 You can fix this something like this (this should work for distros up to and
83 including $pkg_for_distros_up_to):
85 wget $UBUNTU_MIRROR/pool/main/d/debootstrap/$pkg
86 ar x $pkg data.tar.gz
87 tar zxvf data.tar.gz ./usr/share/debootstrap/scripts/$DISTRO
88 mv -i ./usr/share/debootstrap/scripts/$DISTRO /usr/share/debootstrap/scripts
89 rm data.tar.gz
90 rm $pkg
91 END
92 exit 1
94 mkdir "$chroot_path"
95 VARIANT=
96 case $DISTRO in
97 # intrepid) ;;
99 VARIANT=--variant=buildd ;;
100 esac
101 debootstrap $VARIANT --arch $DEBIAN_BUILD_ARCH "$DISTRO" "$chroot_path" "$UBUNTU_MIRROR"
102 # Need universe for (e.g.) python 2.1 and 2.2 on breezy
103 echo "deb $UBUNTU_MIRROR $DISTRO universe" >> "$chroot_path/etc/apt/sources.list"
106 echo "Don't know about codename '$DISTRO' yet"
107 exit 1
108 esac
110 echo "$distro_arch $chroot_path" >> "$DCHROOT_CONF"
112 dchroot -c "$distro_arch" -- $_C 'apt-get -y --force-yes update'
113 # gnupg is needed for signed packages in newer distros.
114 dchroot -c "$distro_arch" -- $_C 'apt-get -y --force-yes install build-essential gnupg python'