slitaz-dev-tools view tazchroot/tazchroot.conf @ rev 29

Fix tazchroot default config
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sat Mar 05 19:52:15 2011 +0100 (2011-03-05)
parents 557aa406a8de
children 5de4cfa5296c
line source
1 # Tazchroot configuration file
2 # Allow you to build a chrooted cooking environnment using the last
3 # version available of packages.
5 # Use SliTaz version:
6 SLITAZ_VERSION=cooking
8 # SLITAZ_DIR (it's mounted on chroot)
9 SLITAZ_DIR=/home/slitaz
11 # Chroot path:
12 chroot_dir=$SLITAZ_DIR/$SLITAZ_VERSION/sandbox
14 # Online repository path:
15 # Actually Pankso provide a mirror of packages being cooked on tank,
16 # waiting for having them on http://mirror.slitaz.org/packages/cooking
17 MIRROR=http://people.slitaz.org/~pankso/packages/
19 # Default SliTaz paths.
20 LOCALSTATE=/var/lib/tazpkg
21 INSTALLED=$LOCALSTATE/installed
23 # Webserver path;
24 # Define where the webserver should be located.
25 # You have to use the same setup inside & outside the chroot.
26 # Here we use the default setup.
27 # The host system needs php installed to make it works.
28 # Uncomment to following line to use this option.
29 WEBSERVER="/var/www/vhosts/bb"
31 # Default scripts path (theses scripts are added in the
32 # $chroot_dir/usr/bin and can be called with tazchroot script)
33 script_dir="/usr/lib/slitaz/chroot-scripts/tazchroot"
35 # List of directories to mount.
36 # They are mounted to an equivalent location into chroot.
37 # (one per line)
38 list_dir="$SLITAZ_DIR
39 $WEBSERVER"
41 create_chroot()
42 {
43 # Warning message.
44 echo -en "\\033[1;31mWarning:\\033[0m this script is going to use another packages repository than \
45 the one you generally use. Please don't install packages until chroot is created or it will \
46 screw you're main system.
47 Don't continue to run this script if you're installing something.
49 Continue to run (type 'yes' to continue) ? " | fold -s; read answer
50 [ "$answer" = yes ] || exit
52 if [ -f "$LOCALSTATE/priotity" ]; then
53 mv $LOCALSTATE/priotity $LOCALSTATE/priority.tmp-bak
54 fi
55 tazpkg add-undigest tmp.$SLITAZ_VERSION.mirror "$MIRROR"
56 echo "tmp.$SLITAZ_VERSION.mirror" > /var/lib/tazpkg/priority
57 tazpkg recharge
59 # Install needed packages.
60 mkdir -p $chroot_dir
61 tazpkg get-install busybox --root="$chroot_dir"
62 tazpkg get-install tazchroot --root="$chroot_dir"
63 tazpkg get-install tazpkg --root="$chroot_dir"
64 tazpkg get-install tazwok --root="$chroot_dir"
65 tazpkg get-install libtaz --root="$chroot_dir"
67 rm -r $LOCALSTATE/undigest/tmp.$SLITAZ_VERSION.mirror
68 if [ -f "$LOCALSTATE/priotity.tmp-bak" ]; then
69 mv -f $LOCALSTATE/priotity.tmp-bak $LOCALSTATE/priority
70 fi
71 tazpkg recharge
73 echo -e "\\033[1;31mWarning:\\033[0m You're SliTaz repository configuration is now \
74 back to normal state." | fold -s
75 }
77 mount_chroot()
78 {
79 # resolv.conf is needed to have network access into chroot.
80 cp -a /etc/resolv.conf "$chroot_dir/etc/resolv.conf"
82 # Setup mirror for chroot.
83 echo "$MIRROR" > "$chroot_dir/var/lib/tazpkg/mirror"
85 # Setup release.
86 echo "$SLITAZ_VERSION" > "$chroot_dir/etc/slitaz-release"
88 # Webserver setup.
89 if [ "$WEBSERVER" ]; then
90 mkdir -p /usr/lib/slitaz
91 [ -d /usr/share/slitaz/web-bb ] || [ -L /usr/share/slitaz/web-bb ] ||
92 ln -s $chroot_dir/usr/share/slitaz/web-bb /usr/share/slitaz/web-bb
94 # Make tazwok act as php/lighttpd were installed into the sandbox.
95 mkdir -p $chroot_dir$INSTALLED/php
96 mkdir -p $chroot_dir$INSTALLED/lighttpd
97 fi
99 # Mount system directories
100 mount -t proc proc $chroot_dir/proc
101 mount -t sysfs sysfs $chroot_dir/sys
102 mount -t devpts devpts $chroot_dir/dev/pts
103 mount -t tmpfs shm $chroot_dir/dev/shm
105 # Mount directories of LIST_DIR.
106 # Create them if needed to avoid errors.
107 for dir in $list_dir; do
108 mkdir -p $dir
109 mkdir -p $chroot_dir$dir
110 mount $dir $chroot_dir$dir
111 done
112 }
114 umount_chroot()
115 {
116 # First umount directories of LIST_DIR.
117 for dir in $list_dir; do
118 umount $chroot_dir$dir
119 done
121 # Then umount system directories.
122 umount $chroot_dir/dev/shm
123 umount $chroot_dir/dev/pts
124 umount $chroot_dir/sys
125 umount $chroot_dir/proc
126 }