pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Automate pkgsrc chroot in Debian



Hello,

I would like to share my bit of chrooted pkgsrc experience in Debian.

--------
#!/bin/bash

## dpcr.sh
## create basic Debian chroot capable of bootstrapping pkgsrc
##
##
## SYNOPSIS
##
## dpcr.sh <command> <dir>
## available commands:
## mk    -    create a system;
## bp    -    bootstrap pkgsrc;
## cr    -    mount necessary filesystems and chroot.
##
##
## SETTINGS
##
PKGSRC=/path/to/pkgsrc.tar.gz    # Path to pkgsrc package;
DEBIAN=wheezy            # Debian release.

case "$1" in
mk)
## From http://binsh.ru/2010/01/20/debian-chroot.html.
    mkdir "$2"
    debootstrap --include=ed,vim,gcc,build-essential $DEBIAN "$2"
    echo "$2" > $2/etc/debian_chroot
## Not needed in wheezy:
#    sed -i 's/^\(export PS1.*\)$/#\1/g' "$2"/root/.bashrc
    mount -t devpts devpts "$2"/dev/pts
    mount -t proc proc "$2"/proc
    sleep 1
    chroot "$2" apt-get update
    for i in {0..2}
    do
        sync
        sleep 1
    done
    umount "$2"/dev/pts "$2"/proc
    ;;
bp)
    pushd "$2"/usr
    tar -xzf "$PKGSRC"
    popd
    pushd "$2"/usr/pkgsrc/bootstrap
    echo "#!/bin/bash
cd /usr/pkgsrc/bootstrap
export SH=/bin/bash
export NOGCCERROR=yes
./bootstrap
exit 0" > bootstrap-dpcr.sh
    chmod +x bootstrap-dpcr.sh
    popd
## If NOGCCERROR is not set, the following happens:
## ftp.c: In function 'unmappedaddr':
## ftp.c:149:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
## cc1: all warnings being treated as errors
## *** Error code 1
##
## Stop.
## bmake: stopped in /home/mike/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/libfetch
## *** Error code 1
##
## Stop.
## bmake: stopped in /home/mike/pkgsrc/pkgtools/pkg_install
## *** Error code 1
##
## Stop.
## bmake: stopped in /home/mike/pkgsrc/pkgtools/pkg_install
## ===> exited with status 1
## aborted.
    mount -t devpts devpts "$2"/dev/pts
    mount -t proc proc "$2"/proc
    sleep 1
    chroot "$2" /usr/pkgsrc/bootstrap/bootstrap-dpcr.sh
    for i in {0..2}
    do
        sync
        sleep 1
    done
    umount "$2"/dev/pts "$2"/proc
    ;;

cr)
    mount -t devpts devpts "$2"/dev/pts
    mount -t proc proc "$2"/proc
    sleep 1
    chroot "$2"
    for i in {0..2}
    do
        sync
        sleep 1
    done
    umount "$2"/dev/pts "$2"/proc
    ;;
*)
    echo unknown command: "$1"
    echo "Synopsis:
$0 <command> <dir>
creates basic Debian chroot capable of bootstrapping pkgsrc.
Commands:
mk   -       create a system;
bp   -       bootstrap pkgsrc;
cr   -       mount necessary filesystems and chroot."
    exit 1
    ;;
esac
exit 0
--------

Greetings,

Mike.



Home | Main Index | Thread Index | Old Index