add note about naming conventions
[mirror/dsa-wiki.git] / input / howto / dchroot.creole
1
2 == HOWTO set up a porting dchroot on a debian.org machine ==
3
4 The script 'upgrade-porter-chroots' has expectations about naming conventions
5 for new porter chroots.  The current list it searches for are:
6
7 lenny squeeze wheezy sid \
8 lenny_i386 squeeze_i386 wheezy_i386 sid_i386 \
9 lenny_amd64 squeeze_amd64 wheezy_amd64 sid_amd64 \
10 sid_s390x \
11
12 Please make sure that new chroots meet the expectations of the script, or update
13 the script accordingly (it lives in the debian.org.git repo)
14
15
16
17 This example is for setting up a $DIST dchroot on paer.debian.org,
18 adjust accordingly.
19
20 Do the following as root:
21
22 {{{
23   echo -n 'Dist: ' && read DIST && export DIST &&
24   echo -n 'Mirror: ' && read MIRROR && export MIRROR 
25 }}}
26
27
28 * create the chroot
29 {{{
30   cd /srv/chroot &&
31   mkdir $DIST &&
32   debootstrap --keyring /usr/share/keyrings/debian-archive-keyring.gpg --include="apt" --variant=buildd $DIST ./$DIST http://$MIRROR/debian &&
33   cp /etc/hosts $DIST/etc/
34 }}} 
35
36 * enter the chroot and create the chroot tag:
37 {{{
38 chroot $DIST
39 echo $DIST > /etc/debian_chroot
40
41 # change root's .bashrc:
42  grep -q debian.chroot /etc/bash.bashrc || patch /root/.bashrc << 'EOF'
43 @@ -3,2 +3,6 @@
44  export PS1='\h:\w\$ '
45 +if [ -e /etc/debian_chroot ]; then
46 +       debian_chroot=$(cat /etc/debian_chroot)
47 +       PS1="[$debian_chroot] $PS1"
48 +fi
49  umask 022
50 EOF
51 #
52 #*)
53  echo 'Acquire::PDiffs "false";' > /etc/apt/apt.conf.d/local-pdiff
54  echo 'APT::Install-Recommends 0;' > /etc/apt/apt.conf.d/local-recommends
55  echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/local-no-lang
56 # # not sure this one's a good idea, -- weasel 20080829
57 # ##echo 'DPkg::Post-Invoke { "(sleep 1; apt-get clean) &"; };' > /etc/apt/apt.conf.d/local-cleanup
58 #
59 #*) deploy a policy-rc.d script:
60  apt-get update &&
61  apt-get install policyrcd-script-zg2 &&
62  cat > /usr/local/sbin/policy-rc.d << EOF &&
63 #!/bin/sh
64
65 # policy-rc.d script for chroots.
66 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
67
68 while true; do
69   case "$1" in
70     -*)         shift ;;
71     makedev)    exit 0;;
72     *)
73       echo "Not running services in chroot."
74       exit 101
75       ;;
76   esac
77 done
78 EOF
79  chmod +x /usr/local/sbin/policy-rc.d
80
81 #*) install and setup locales and install libnss-db
82   apt-get install locales-all
83
84 #  (if locales-all is not feasible on the machine because of say
85 #   disk constraints then install just locales and enable at
86 #   least "en_US.UTF-8 UTF-8" and "en_US ISO-8859-1".)
87 #
88 #*) setup nsswitch.conf to properly use the ldap stuff
89   # [dchroot]: apt-get install libnss-db &&
90   # sed -i -e 's/^passwd:\[[:space:]]\+compat$/passwd:         compat db/;
91   #            s/^group:\[[:space:]]\+compat$/group:          db compat/;
92   #            s/^shadow:\[[:space:]]\+compat$/shadow:         compat db/' \
93   #   /etc/nsswitch.conf
94 #
95 #
96 # *)
97    apt-get install vim fakeroot devscripts gdb zsh dialog tcsh debfoster
98 #  edit the sources.list in the chroot and add contrib/non-free to the
99 #  primary source, a security updates source, and deb-src entries for both.
100 #  It should end up looking something like
101    (
102    echo "deb     http://$MIRROR/debian $DIST main contrib non-free"
103    echo "deb-src http://$MIRROR/debian $DIST main contrib non-free"
104    if [ "$DIST" != "sid" ] ; then
105      echo "deb     http://security.debian.org $DIST/updates main contrib non-free"
106      echo "deb-src http://security.debian.org $DIST/updates main contrib non-free"
107    fi
108    ) > /etc/apt/sources.list
109    apt-get update && apt-get upgrade
110 #
111 # *)
112   mount -t proc none /proc && debfoster ; umount /proc
113 #
114 # *)
115 #  exit the chroot
116   exit
117 }}}
118
119 * [dchroot only] edit /etc/fstab on the system root and add entries to mount /proc and /home
120 in the chroot, there will be existing ones for the other chroots, just copy and
121 adjust. Then mount them (from the system root).
122 {{{
123   :e.g:
124   :  proc-etch  /srv/albeniz.debian.org/chroot/etch/proc proc defaults,nosuid,nodev,noexec 0 0
125   :  proc-lenny /srv/albeniz.debian.org/chroot/lenny/proc proc defaults,nosuid,nodev,noexec 0 0
126   :  proc-sid   /srv/albeniz.debian.org/chroot/sid/proc proc defaults,nosuid,nodev,noexec 0 0
127   :
128   :  home /srv/albeniz.debian.org/chroot/etch/home none bind,defaults
129   :  home /srv/albeniz.debian.org/chroot/lenny/home none bind,defaults
130   :  home /srv/albeniz.debian.org/chroot/sid/home none bind,defaults
131   :
132   :  devpts-etch  /srv/albeniz.debian.org/chroot/etch/dev/pts devpts defaults,noexec,nosuid 0 0
133   :  devpts-lenny /srv/albeniz.debian.org/chroot/lenny/dev/pts devpts defaults,noexec,nosuid 0 0
134   :  devpts-sid   /srv/albeniz.debian.org/chroot/sid/dev/pts devpts defaults,noexec,nosuid 0 0
135   :
136   :  shm-etch  /srv/albeniz.debian.org/chroot/etch/dev/shm tmpfs defaults,nosuid,nodev 0 0
137   :  shm-lenny /srv/albeniz.debian.org/chroot/lenny/dev/shm tmpfs defaults,nosuid,nodev 0 0
138   :  shm-sid   /srv/albeniz.debian.org/chroot/sid/dev/shm tmpfs defaults,nosuid,nodev 0 0
139   :
140   :  tmp /srv/albeniz.debian.org/chroot/etch/tmp none bind,defaults
141   :  tmp /srv/albeniz.debian.org/chroot/lenny/tmp none bind,defaults
142   :  tmp /srv/albeniz.debian.org/chroot/sid/tmp none bind,defaults
143 }}}
144
145 * [schroot] set up /etc/schroot/chroot.d/ correctly.
146   [dchroot]: edit /etc/dchroot.conf in the system root, add an entry for $DIST, and update the stable and testing pointers
147
148 * [dchroot]: run ud-replicate so the new chroot is setup (this would happen via cron eventually, this is just to speed things up)
149 {{{
150   ud-replicate
151 }}}
152
153 * as a normal user, test that the new chroot works: "dchroot $DIST" or "schroot $DIST", test that the stable and testing pointers work.