This is the old SliTaz forum - Please use the main forum.slitaz.org

Testing build_deps with a minimal chrooted environnment
  • GokhlayehGokhlayeh March 2010
    Hi,

    I use a minimal chroot (tazwok + slitaz-toolchain) to verify build_deps of receipts. I build the chroot in my home USB in live session to save ram. I also use a script to remove all packages installed during cooking at exit, because I want to keep a minimal environnment for testing build_deps.

    Create the chroot in /home/chroot :
    mkdir /home/chroot
    # You can mount a device to /home/chroot
    # with mountbox or mount
    tazpkg get-install busybox --root="/home/chroot"
    echo "No" | tazpkg get-install bash --root="/home/chroot"
    tazpkg get-install slitaz-toolchain --root="/home/chroot"
    tazpkg get-install tazwok --root="/home/chroot"
    tazpkg get-install tazpkg --root="/home/chroot"
    tazpkg get-install lzma --root="/home/chroot"
    mkdir /home/chroot/home/slitaz


    Note : you can keep theses lines in a script file if needed. Just add #!/bin/sh in first line and make executable with :
    chmod +x script_file


    Add a script file to delete unwanted packages when exiting chroot :
    cat > /home/chroot/chroot_script.sh << "EOF"<br />#!/bin/sh
    /bin/sh --login
    for pkg in $(cat /var/log/tazpkg.log | grep -v Removed | sed 's/\(.*\)\(- Installed - \)\(.*\)\( (.*\)/\3/'); do
    echo "y" | tazpkg remove $pkg
    done
    rm /var/log/tazpkg.log

    EOF
    chmod +x "/home/chroot/chroot_script.sh"


    Note: /bin/sh --login log you in the chrooted environnment. The commands after that line auto-remove packages added when cooking at exit. You can hack this file to execute various automated actions when entering and exiting chroot.

    Add a script to mount and umount chroot :

    cat > /usr/bin/tazchroot << "EOF"<br />#!/bin/sh
    cat /etc/resolv.conf > /home/chroot/etc/resolv.conf
    if [ ! -d "/home/chroot/proc/1" ]; then
    echo "Mounting virtual filesystems..."
    mount -t proc proc /home/chroot/proc
    mount -t sysfs sysfs /home/chroot/sys
    mount -t devpts devpts /home/chroot/dev/pts
    mount -t tmpfs shm /home/chroot/dev/shm
    mount /home/slitaz /home/chroot/home/slitaz
    chroot /home/chroot ./chroot_script.sh
    until [ "$ps" = "2" ]; do
    echo "Waiting for the end of all other chroot process..."
    ps=$(ps | grep `basename $0` | grep -v grep | grep -v basename | wc -l)
    sleep 1
    done
    umount /home/chroot/home/slitaz
    umount /home/chroot/dev/shm
    umount /home/chroot/dev/pts
    umount /home/chroot/sys
    umount /home/chroot/proc
    else
    echo "The chroot is already mounted"
    fi
    EOF
    chmod +x /usr/bin/tachroot


    Note : This script mount /home/slitaz in you're chroot, so you can use tazwok as if it is on you're normal environnment.

    Hope this help.
  • jozeejozee March 2010
    I also wrote a similar script to keep things clean. Your's looks better. Maybe you also add this to "http://doc.slitaz.org/en:guides:start".

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

SliTaz Social