#!/bin/sh CHROOT_BUILD=/home/chroot-build CHROOT_CLEAN=/home/chroot-clean chroot_build () { local CHROOT="$1" if [ ! -d "$CHROOT/proc/1" ]; then echo "Mounting virtual filesystems..." mount -t proc proc $CHROOT/proc mount -t sysfs sysfs $CHROOT/sys mount -t devpts devpts $CHROOT/dev/pts mount -t tmpfs shm $CHROOT/dev/shm mount -o bind /home/slitaz $CHROOT/home/slitaz if [ ! -d $CHROOT/var/cache/tazpkg ]; then mkdir -p $CHROOT/var/cache/tazpkg fi mount -o bind /var/cache/tazpkg $CHROOT/var/cache/tazpkg chroot $CHROOT ./chroot_script.sh #until [ "$ps" = "2" ]; do # echo "Waiting for the end of all other chroot processes..." # ps=$(ps | grep `basename $0` | grep -v grep | grep -v basename | wc -l) # sleep 1 #done umount -l $CHROOT/var/cache/tazpkg umount -l $CHROOT/home/slitaz umount -l $CHROOT/dev/shm umount -l $CHROOT/dev/pts umount -l $CHROOT/sys umount -l $CHROOT/proc else echo "The chroot is already mounted" fi } chroot_create () { local CHROOTDIR="$1" mkdir -p $CHROOTDIR tazpkg get-install busybox --root"$CHROOTDIR" echo "No" | tazpkg get-install bash --root="$CHROOTDIR" tazpkg get-install slitaz-toolchain --root="$CHROOTDIR" tazpkg get-install tazwok --root="$CHROOTDIR" tazpkg get-install lzma --root="$CHROOTDIR" tazpkg get-install tazbb --root="$CHROOTDIR" #tazpkg get-install gettext --root="$CHROOTDIR" mkdir -p $CHROOTDIR/home/slitaz cat /etc/resolv.conf > $CHROOTDIR/etc/resolv.conf chroot $CHROOTDIR tazpkg recharge --root="$CHROOTDIR" } if [ -d $CHROOT_BUILD ]; then rm -R $CHROOT_BUILD fi if [ ! -d $CHROOT_CLEAN ]; then chroot_create $CHROOT_CLEAN if [ ! -f $CHROOT_CLEAN/chroot_script.sh ]; then cat > $CHROOT_CLEAN/chroot_script.sh << "EOF" #!/bin/sh LC_ALL=C /bin/sh --login EOF chmod +x "$CHROOT_CLEAN/chroot_script.sh" fi fi if [ -d $CHROOT_CLEAN ]; then cp -a $CHROOT_CLEAN $CHROOT_BUILD fi if [ -d $CHROOT_BUILD ]; then chroot_build $CHROOT_BUILD fi