]> git.donarmstrong.com Git - neurodebian.git/blob - tools/nd_adddist
VM: adjusted for new VB exposing mounted host directories under /media
[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 mkdir -p ${cowbuilderroot}/cow
30
31 for a in i386 amd64; do
32   echo "Building $a base path..."
33   cow="${cowbuilderroot}/cow/${family}-${dist}-${a}.cow"
34   if [ -d "$cow" ]; then
35     echo "${cow} exists. Ignoring arch."
36     continue
37   fi
38   if [ "${family:0:3}" = "nd+" ]; then
39   echo "Including NeuroDebian repository..."
40     cowbuilder --create --basepath ${cow} $opts \
41                --components "$components" \
42                --mirror "$mirror" \
43                --debootstrapopts --arch=$a \
44                --othermirror "deb http://neuro.debian.net/debian $dist main contrib non-free"
45     # deploy our key manually since archive with package is not yet
46     # available at this point
47     mkdir -p ${cow}/etc/apt/trusted.gpg.d
48     cp --preserve=mode {,${cow}}/etc/apt/trusted.gpg.d/neurodebian-archive-keyring.gpg
49     # Old ubuntus might not have capability to ready from that key yet,
50     # so we would need to manually add it
51     if [ $dist = 'karmic' ] || [ $dist = 'hardy' ]; then
52         chroot ${cow} bash -c "apt-get install -y --force-yes gnupg \
53         && /usr/bin/apt-key add /etc/apt/trusted.gpg.d/neurodebian-archive-keyring.gpg \
54         && /usr/bin/apt-get update"
55     fi
56   else
57     cowbuilder --create --basepath ${cow} $opts \
58                --components "$components" \
59                --mirror "$mirror" \
60                --debootstrapopts --arch=$a
61   fi
62 done