]> git.donarmstrong.com Git - neurodebian.git/blob - tools/nd_adddist
Also for stats report which repo and which job number use our setup
[neurodebian.git] / tools / nd_adddist
1 #!/bin/bash
2
3 family=$1
4 dist=$2
5
6 set -e
7
8 if [ -z "$family" ]; then
9   echo "You need to provide a distribution family ('debian', 'ubuntu'); prefix with 'nd+' to enable the NeuroDebian repository."
10   exit 1
11 fi
12
13 if [ -z "$dist" ]; then
14   echo "You need to provide a distribution codename (e.g. 'lenny', 'squeeze')."
15   exit 1
16 fi
17
18
19 . /etc/neurodebian/cmdsettings.sh
20
21 # common options
22 opts="--distribution $dist --debootstrap debootstrap --aptcache $aptcache"
23
24 if echo $family | grep -q ubuntu; then
25     # Use ubuntu's keyring since otherwise debootstrap would fail
26     opts+=" --debootstrapopts --keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg"
27 fi
28
29 if echo $family | grep -q debian; then
30     # Use debian keyring since otherwise debootstrap would fail (on Ubuntu)
31     opts+=" --debootstrapopts --keyring=/usr/share/keyrings/debian-archive-keyring.gpg"
32 fi
33
34 mkdir -p ${cowbuilderroot}/cow
35
36 for a in i386 amd64; do
37   echo "Building $a base path..."
38   cow="${cowbuilderroot}/cow/${family}-${dist}-${a}.cow"
39   if [ -d "$cow" ]; then
40     echo "${cow} exists. Ignoring arch."
41     continue
42   fi
43   if [ "${family:0:3}" = "nd+" ]; then
44   echo "Including NeuroDebian repository..."
45     # If it has updates -- enable them
46     if wget -q -O/dev/null $mirror/dists/$dist-updates; then
47       updates_apt="deb $mirror $dist-updates $components |"
48       updates_apt+="#deb-src $mirror $dist-updates $components |"
49     else
50       updates_apt=""
51     fi
52     cowbuilder --create --basepath ${cow} $opts \
53                --components "$components" \
54                --mirror "$mirror" \
55                --debootstrapopts --arch=$a \
56                --othermirror "${updates_apt}deb http://neuro.debian.net/debian $dist main contrib non-free | deb http://neuro.debian.net/debian data main contrib non-free"
57     # deploy our key manually since archive with package is not yet
58     # available at this point
59     mkdir -p ${cow}/etc/apt/trusted.gpg.d
60     cp --preserve=mode {,${cow}}/etc/apt/trusted.gpg.d/neurodebian-archive-keyring.gpg
61     # Old ubuntus might not have capability to read from that key yet,
62     # so we would need to manually add it
63     if [ $dist = 'karmic' ] || [ $dist = 'hardy' ]; then
64         chroot ${cow} bash -c "apt-get install -y --force-yes gnupg \
65         && /usr/bin/apt-key add /etc/apt/trusted.gpg.d/neurodebian-archive-keyring.gpg \
66         && /usr/bin/apt-get update"
67     fi
68   else
69     cowbuilder --create --basepath ${cow} $opts \
70                --components "$components" \
71                --mirror "$mirror" \
72                --debootstrapopts --arch=$a
73   fi
74 done