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