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