slitaz-dev-tools view oldstuff/tazchroot/tazchroot.conf @ rev 285

mouve tazchroot to oldstuff
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 16 18:37:13 2017 +0100 (2017-03-16)
parents tazchroot/tazchroot.conf@dbcd2b40b915
children
line source
1 # Tazchroot configuration file.
2 # Allows you to build a chrooted cooking environnment using the last
3 # available package version.
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 MIRROR=http://mirror.slitaz.org/packages/cooking/
17 # Default SliTaz paths.
18 LOCALSTATE=/var/lib/tazpkg
19 INSTALLED=$LOCALSTATE/installed
21 # Webserver path.
22 # Defines where the webserver should be located.
23 # You have to use the same setup inside & outside the chroot.
24 # Here we use the default setup.
25 # The host system needs php installed to make it work.
26 # Uncomment the following line to use this option.
27 WEBSERVER="/var/www/vhosts/bb"
29 # Default scripts path (these scripts are added to the
30 # $chroot_dir/usr/bin and can be called with tazchroot script)
31 script_dir="/usr/lib/slitaz/chroot-scripts/tazchroot"
33 # List of directories to mount.
34 # They are mounted to an equivalent location in the chroot.
35 # (one per line)
36 list_dir="$SLITAZ_DIR
37 $WEBSERVER"
39 create_chroot()
40 {
41 # Warning message.
42 echo -en "\\033[1;31mWarning:\\033[0m this script is going to use another packages repository other \
43 than the one you generally use. Please don't install packages until the chroot is created or it will \
44 screw your main system. Don't continue to run this script if you're installing something.
46 Continue to run (type 'yes' to continue) ? " | fold -s; read answer
47 [ "$answer" = yes ] || exit
49 if [ -f "$LOCALSTATE/priotity" ]; then
50 mv $LOCALSTATE/priotity $LOCALSTATE/priority.tmp-bak
51 fi
52 tazpkg add-undigest tmp.$SLITAZ_VERSION.mirror "$MIRROR"
53 echo "tmp.$SLITAZ_VERSION.mirror" > /var/lib/tazpkg/priority
54 tazpkg recharge
56 # Install needed packages.
57 mkdir -p $chroot_dir
58 tazpkg get-install busybox --root="$chroot_dir"
59 tazpkg get-install tazchroot --root="$chroot_dir"
60 tazpkg get-install tazpkg --root="$chroot_dir"
61 tazpkg get-install tazwok --root="$chroot_dir"
63 rm -r $LOCALSTATE/undigest/tmp.$SLITAZ_VERSION.mirror
64 if [ -f "$LOCALSTATE/priotity.tmp-bak" ]; then
65 mv -f $LOCALSTATE/priotity.tmp-bak $LOCALSTATE/priority
66 fi
67 tazpkg recharge
69 echo -e "\\033[1;31mWarning:\\033[0m Your SliTaz repository configuration is now \
70 back to a normal state." | fold -s
71 }
73 mount_chroot()
74 {
75 # resolv.conf is needed to have network access into chroot.
76 cp -a /etc/resolv.conf "$chroot_dir/etc/resolv.conf"
78 # Setup mirror for chroot.
79 echo "$MIRROR" > "$chroot_dir/var/lib/tazpkg/mirror"
81 # Setup release.
82 echo "$SLITAZ_VERSION" > "$chroot_dir/etc/slitaz-release"
84 # Webserver setup.
85 if [ "$WEBSERVER" ]; then
86 mkdir -p /usr/lib/slitaz
87 [ -d /usr/share/slitaz/web-bb ] || [ -L /usr/share/slitaz/web-bb ] ||
88 ln -s $chroot_dir/usr/share/slitaz/web-bb /usr/share/slitaz/web-bb
90 # Make tazwok act as if php/lighttpd were installed into the sandbox.
91 mkdir -p $chroot_dir$INSTALLED/php
92 mkdir -p $chroot_dir$INSTALLED/lighttpd
93 fi
95 # Mount system directories.
96 mount -o bind /proc $chroot_dir/proc
97 mount -o bind /sys $chroot_dir/sys
98 mount -o bind /dev/pts $chroot_dir/dev/pts
99 mount -o bind /dev/shm $chroot_dir/dev/shm
101 # Mount directories of LIST_DIR.
102 # Create them if needed to avoid errors.
103 for dir in $list_dir; do
104 mkdir -p $dir
105 mkdir -p $chroot_dir$dir
106 mount $dir $chroot_dir$dir
107 done
108 }
110 umount_chroot()
111 {
112 # First umount directories of LIST_DIR.
113 for dir in $list_dir; do
114 umount $chroot_dir$dir
115 done
117 # Then umount system directories.
118 umount $chroot_dir/dev/shm
119 umount $chroot_dir/dev/pts
120 umount $chroot_dir/sys
121 umount $chroot_dir/proc
122 }