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