Coder Social home page Coder Social logo

mchroot's Introduction

Creating a cross-compile chroot environment using Gentoo.

1. Create destination directory.  Referenced as <chroot> below.
    Ex. /esw/powerpc64-gcc-20130412

2. Configure portage options.

    <chroot>/etc/make.conf:
        MAKEOPTS="-j5"
        CFLAGS="-O2 -pipe"
        CXXFLAGS="${CFLAGS}"

    <chroot>/etc/portage/make.profile/parent:
        gentoo:default/linux/amd64
        # OR
        gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
        gentoo:funtoo/1.0/linux-gnu/build/current
        gentoo:funtoo/1.0/linux-gnu/flavor/minimal

    <chroot>/etc/portage/package.use/net-misc:
        net-misc/curl ssl

    <chroot>/etc/portage/package.use/sys-devel:
        sys-devel/binutils multitarget

3. Install 'system'.

    cd <chroot>
    ROOT=`pwd` PORTAGE_CONFIGROOT=`pwd` emerge @system --jobs

4. Install cross-compiler and extra packages.

    cp /etc/resolv.conf <chroot>/etc/resolv.conf
    unshare -m /bin/bash
    mount -n --bind /dev <chroot>/dev
    mount -n --bind /proc <chroot>/proc
    mkdir <chroot>/usr/portage
    mount -n --bind /usr/portage <chroot>/usr/portage
    chroot <chroot> /bin/bash

    emerge crossdev dwarves --jobs
    emerge strace                       # optional

    mkdir /usr/local/portage
    crossdev powerpc64-unknown-linux-gnu --ov-output /usr/local/portage

    exit
    exit

5. Install mchroot and wrappers.

    cd /tmp
    git clone http://github.com/williamspatrick/mchroot
    cd mchroot
    gcc mchroot.c -Os -static -o mchroot

    mkdir <chroot>/wrappers
    cp mchroot mchroot_wrapper.sh jail_wrapper.sh <chroot>/wrappers
    
    cd <chroot>/wrappers
    chmod u+s mchroot
    /tmp/mchroot/create_wrapper_links.sh

6. Configure mchroot

    Add file systems you wish to bind-mount into the chroot to 
    <chroot>/.mchroot.cfg with one mount path per line.

    <chroot>/.mchroot.cfg:
        /dev
        /proc
        /tmp
        /home
        (...etc...)

mchroot's People

Contributors

williamspatrick avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.