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