• Posts
  • RSS
  • ◂◂RSS
  • Contact

  • 32-bit Chroots on Ubuntu LTS 12 and Centos 5

    July 22nd, 2016
    tech  [html]
    Because operating systems are generally backwards compatible, to build binaries that work on several versions of Linux it's best to build them on the oldest version of the OS that's still supported. For Ubuntu this is currently LTS 12, and for CentOS it's 5. While I can get a VM for either of these on Rackspace etc, at this point I can only get 64-bit versions and some people still need 32-bit binaries. So, here's how to make a 32-bit chroot environment for building them.

    Ubuntu
    Derived from jblevins.org/log/ubuntu-chroot.

    $ sudo apt-get install debootstrap dchroot
    $ sudo emacs /etc/schroot/schroot.conf
    [precise_i386]
    description=Ubuntu 12.04 Precise for i386
    directory=/var/chroot/precise_i386
    personality=linux32
    root-users=buildbot
    users=buildbot
    
    $ sudo emacs /etc/schroot/mount-defaults
    comment out the /home line (Cross-mounting
    /home makes moving files much easier.)
    $ sudo debootstrap --variant=buildd --arch i386 precise
    /var/chroot/precise_i386 http://archive.ubuntu.com/ubuntu/
    $ sudo cp /etc/resolv.conf /var/chroot/precise_i386/etc/resolv.conf
    $ sudo cp /etc/apt/sources.list /var/chroot/precise_i386/etc/apt/
    $ pushd /var/chroot/precise_i386/etc
    $ for x in passwd shadow group gshadow hosts sudoers; do
        sudo rm $x; sudo ln /etc/$x;
    done
    $ popd
    $ sudo emacs /etc/fstab
    add:
    /dev /var/chroot/precise_i386/dev none bind 0 0
    proc-chroot /var/chroot/precise_i386/proc proc defaults 0 0
    devpts-chroot /var/chroot/precise_i386/dev/pts devpts defaults 0 0
    none /var/chroot/precise_i386/dev/shm tmpfs rw,nosuid,nodev,noexec 0 0
    $ sudo mount -a
    $ sudo chroot /var/chroot/precise_i386/
    # apt-get update
    # apt-get install gnupg locales dialog emacs wget
    # locale-gen en_US.UTF-8
    # dpkg-reconfigure tzdata
    # dpkg-reconfigure passwd
    # apt-get install sudo
    # mkdir /home/buildbot
    # chown buildbot /home/buildbot
    # exit
    $ sudo emacs /var/chroot/precise_i386/etc/debian_chroot
    precise_i386
    $ schroot -c precise_i386
    now you're in the chroot
    
    CentOS
    I wish there was debootstrap for CentOS.

    $ sudo yum install setarch
    $ sudo mkdir -p /var/chroot/centos_i386/var/lib/rpm \
                    /var/chroot/centos_i386/home/buildbot
    $ sudo cp /etc/rpm/platform  /etc/rpm/platform.real
    $ echo i686-redhat-linux | sudo tee /etc/rpm/platform
    $ sudo rpm --rebuilddb --root=/var/chroot/centos_i386
    $ URL="http://mirror.centos.org/centos/5/os/i386/"
    $ URL+="CentOS/centos-release-5-10.el5.centos.i386.rpm"
    $ wget "$URL"
    $ sudo rpm --root=/var/chroot/centos_i386 --nodeps -i \
           centos-release-5-10.el5.centos.i386.rpm
    $ sudo yum --installroot=/var/chroot/centos_i386/ update
    $ sudo yum --installroot=/var/chroot/centos_i386/ install \
               -y rpm-build yum
    $ sudo mv /etc/rpm/platform.real  /etc/rpm/platform
    $ sudo cp /etc/resolv.conf /var/chroot/centos_i386/etc/resolv.conf
    $ pushd /var/chroot/centos_i386/etc
    $ sudo rm group passwd
    $ for x in passwd shadow group gshadow hosts sudoers; do
        sudo ln /etc/$x;
    done
    $ popd
    (All these mounts should really be put into /etc/fstab.)
    $ sudo mount -t proc proc /var/chroot/centos_i386/proc
    $ sudo mount -t sysfs none /var/chroot/centos_i386/sys
    $ sudo mount --bind /dev /var/chroot/centos_i386/dev
    $ sudo mount -t tmpfs tmpfs /var/chroot/centos_i386/dev/shm
    $ sudo mount --rbind /selinux /var/chroot/centos_i386/selinux
    $ sudo mount --rbind /etc/selinux \
           /var/chroot/centos_i386/etc/selinux
    $ sudo mount --rbind /home/buildbot \
           /var/chroot/centos_i386/home/buildbot
    $ sudo setarch i386 /usr/sbin/chroot \
           /var/chroot/centos_i386/ /bin/bash -l
    # rm /var/lib/rpm/__db.00*
    now you're in the chroot
    

    Comment via: google plus

    Recent posts on blogs I like:

    Collections: Clothing, How Did They Make It? Part I: High Fiber

    This week we are starting the first of a four (?) part look at pre-modern textile production. As with our series on farming and iron, we are going to follow the sequence of production from the growing of fibers all the way to the finished object, with a f…

    via A Collection of Unmitigated Pedantry March 5, 2021

    Austerity is Inefficient

    Working on an emergency timetable for regional rail has made it clear how an environment of austerity requires tradeoffs that reduce efficiency. I already talked about how the Swiss electronics before concrete slogan is not about not spending money but ab…

    via Pedestrian Observations February 27, 2021

    The Troubling Ethics of Writing (A Speech from Ancient Sumer)

    (Translated from a transcript of an ancient Sumerian speech by Uruk's most well-respected Scriptological Ethicist) Writing is a profoundly dangerous technology: Access to writing was initially, and still remains, uneven. What's worse, the rich are m…

    via BLOG - Cullen O'Keefe February 15, 2021

    more     (via openring)


  • Posts
  • RSS
  • ◂◂RSS
  • Contact