slitaz-dev-tools annotate 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
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
slaxemulator@11 63 rm -r $LOCALSTATE/undigest/tmp.$SLITAZ_VERSION.mirror
slaxemulator@11 64 if [ -f "$LOCALSTATE/priotity.tmp-bak" ]; then
slaxemulator@11 65 mv -f $LOCALSTATE/priotity.tmp-bak $LOCALSTATE/priority
slaxemulator@11 66 fi
slaxemulator@11 67 tazpkg recharge
slaxemulator@11 68
paul@31 69 echo -e "\\033[1;31mWarning:\\033[0m Your SliTaz repository configuration is now \
paul@31 70 back to a normal state." | fold -s
slaxemulator@11 71 }
slaxemulator@11 72
slaxemulator@11 73 mount_chroot()
slaxemulator@11 74 {
slaxemulator@11 75 # resolv.conf is needed to have network access into chroot.
slaxemulator@11 76 cp -a /etc/resolv.conf "$chroot_dir/etc/resolv.conf"
slaxemulator@11 77
slaxemulator@11 78 # Setup mirror for chroot.
slaxemulator@11 79 echo "$MIRROR" > "$chroot_dir/var/lib/tazpkg/mirror"
slaxemulator@11 80
slaxemulator@11 81 # Setup release.
slaxemulator@11 82 echo "$SLITAZ_VERSION" > "$chroot_dir/etc/slitaz-release"
slaxemulator@11 83
slaxemulator@11 84 # Webserver setup.
gokhlayeh@29 85 if [ "$WEBSERVER" ]; then
gokhlayeh@29 86 mkdir -p /usr/lib/slitaz
gokhlayeh@29 87 [ -d /usr/share/slitaz/web-bb ] || [ -L /usr/share/slitaz/web-bb ] ||
gokhlayeh@29 88 ln -s $chroot_dir/usr/share/slitaz/web-bb /usr/share/slitaz/web-bb
slaxemulator@11 89
paul@31 90 # Make tazwok act as if php/lighttpd were installed into the sandbox.
gokhlayeh@29 91 mkdir -p $chroot_dir$INSTALLED/php
gokhlayeh@29 92 mkdir -p $chroot_dir$INSTALLED/lighttpd
gokhlayeh@29 93 fi
gokhlayeh@29 94
paul@31 95 # Mount system directories.
gokhlayeh@32 96 mount -o bind /proc $chroot_dir/proc
gokhlayeh@32 97 mount -o bind /sys $chroot_dir/sys
gokhlayeh@32 98 mount -o bind /dev/pts $chroot_dir/dev/pts
gokhlayeh@32 99 mount -o bind /dev/shm $chroot_dir/dev/shm
slaxemulator@11 100
slaxemulator@11 101 # Mount directories of LIST_DIR.
slaxemulator@11 102 # Create them if needed to avoid errors.
slaxemulator@11 103 for dir in $list_dir; do
slaxemulator@11 104 mkdir -p $dir
slaxemulator@11 105 mkdir -p $chroot_dir$dir
slaxemulator@11 106 mount $dir $chroot_dir$dir
slaxemulator@11 107 done
slaxemulator@11 108 }
slaxemulator@11 109
slaxemulator@11 110 umount_chroot()
slaxemulator@11 111 {
slaxemulator@11 112 # First umount directories of LIST_DIR.
slaxemulator@11 113 for dir in $list_dir; do
slaxemulator@11 114 umount $chroot_dir$dir
slaxemulator@11 115 done
slaxemulator@11 116
slaxemulator@11 117 # Then umount system directories.
slaxemulator@11 118 umount $chroot_dir/dev/shm
slaxemulator@11 119 umount $chroot_dir/dev/pts
slaxemulator@11 120 umount $chroot_dir/sys
slaxemulator@11 121 umount $chroot_dir/proc
slaxemulator@11 122 }