Get rid of tabs
[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 --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  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 # # not sure this one's a good idea, -- weasel 20080829
43 # ##echo 'DPkg::Post-Invoke { "(sleep 1; apt-get clean) &"; };' > /etc/apt/apt.conf.d/local-cleanup
44 #
45 #*) deploy a policy-rc.d script:
46  apt-get update &&
47  apt-get install policyrcd-script-zg2 &&
48  cat > /usr/local/sbin/policy-rc.d << EOF &&
49 #!/bin/sh
50
51 # policy-rc.d script for chroots.
52 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
53
54 while true; do
55   case "$1" in
56     -*)         shift ;;
57     makedev)    exit 0;;
58     *)
59       echo "Not running services in chroot."
60       exit 101
61       ;;
62   esac
63 done
64 EOF
65  chmod +x /usr/local/sbin/policy-rc.d
66
67 #*) install and setup locales and install libnss-db
68   apt-get install locales-all
69
70 #  (if locales-all is not feasible on the machine because of say
71 #   disk constraints then install just locales and enable at
72 #   least "en_US.UTF-8 UTF-8" and "en_US ISO-8859-1".)
73 #
74 #*) setup nsswitch.conf to properly use the ldap stuff
75   apt-get install libnss-db &&
76   sed -i -e 's/^passwd:[[:space:]]\+compat$/passwd:         compat db/;
77              s/^group:[[:space:]]\+compat$/group:          db compat/;
78              s/^shadow:[[:space:]]\+compat$/shadow:         compat db/' \
79     /etc/nsswitch.conf
80 #
81 #
82 # *)
83    apt-get install vim fakeroot devscripts gdb zsh dialog tcsh debfoster
84 #  edit the sources.list in the chroot and add contrib/non-free to the
85 #  primary source, a security updates source, and deb-src entries for both.
86 #  It should end up looking something like
87    (
88    echo "deb     http://$MIRROR/debian $DIST main contrib non-free"
89    echo "deb-src http://$MIRROR/debian $DIST main contrib non-free"
90    if [ "$DIST" != "sid" ] ; then
91      echo "deb     http://security.debian.org $DIST/updates main contrib non-free"
92      echo "deb-src http://security.debian.org $DIST/updates main contrib non-free"
93    fi
94    ) > /etc/apt/sources.list
95    apt-get update && apt-get upgrade
96 #
97 # *)
98   mount /proc && debfoster && umount /proc
99 #
100 # *)
101 #  exit the chroot
102   exit
103 }}}
104
105 * edit /etc/fstab on the system root and add entries to mount /proc and /home
106 in the chroot, there will be existing ones for the other chroots, just copy and
107 adjust. Then mount them (from the system root).
108 {{{
109   :e.g:
110   :  proc-etch  /srv/albeniz.debian.org/chroot/etch/proc proc defaults,nosuid,nodev,noexec 0 0
111   :  proc-lenny /srv/albeniz.debian.org/chroot/lenny/proc proc defaults,nosuid,nodev,noexec 0 0
112   :  proc-sid   /srv/albeniz.debian.org/chroot/sid/proc proc defaults,nosuid,nodev,noexec 0 0
113   :
114   :  home /srv/albeniz.debian.org/chroot/etch/home none bind,defaults
115   :  home /srv/albeniz.debian.org/chroot/lenny/home none bind,defaults
116   :  home /srv/albeniz.debian.org/chroot/sid/home none bind,defaults
117   :
118   :  devpts-etch  /srv/albeniz.debian.org/chroot/etch/dev/pts devpts defaults,noexec,nosuid 0 0
119   :  devpts-lenny /srv/albeniz.debian.org/chroot/lenny/dev/pts devpts defaults,noexec,nosuid 0 0
120   :  devpts-sid   /srv/albeniz.debian.org/chroot/sid/dev/pts devpts defaults,noexec,nosuid 0 0
121   :
122   :  shm-etch  /srv/albeniz.debian.org/chroot/etch/dev/shm tmpfs defaults,nosuid,nodev 0 0
123   :  shm-lenny /srv/albeniz.debian.org/chroot/lenny/dev/shm tmpfs defaults,nosuid,nodev 0 0
124   :  shm-sid   /srv/albeniz.debian.org/chroot/sid/dev/shm tmpfs defaults,nosuid,nodev 0 0
125   :
126   :  tmp /srv/albeniz.debian.org/chroot/etch/tmp none bind,defaults
127   :  tmp /srv/albeniz.debian.org/chroot/lenny/tmp none bind,defaults
128   :  tmp /srv/albeniz.debian.org/chroot/sid/tmp none bind,defaults
129 }}}
130
131 * edit /etc/dchroot.conf in the system root, add an entry for $DIST, and
132 update the stable and testing pointers
133
134 * run ud-replicate so the new chroot is setup (this would happen via cron eventually, this is just to speed things up)
135 {{{
136   ud-replicate
137 }}}
138
139 * as a normal user, test that the new chroot works: "dchroot $DIST", test that the stable and testing pointers work.
140
141 -- taggart 2007,  slightly modified by weasel 2007, 2008, ported to wiki 2010.