How to port IPlinux to a new architecture

preparations

  1. Prepare the chroot
    http://ftp.iplinux.org/contrib/iplinux-bootstrap/iplinux-bootstrap-LATEST.tar.bz2
    tar xf iplinux-bootstrap-LATEST.tar.bz2
    (cd iplinux-bootstrap; ./iplinux-bootstrap iplinux ../ip)
    ./ip/enter
    
  2. Install the development packages
    apt-get update
    apt-get install git-core build-essential toolchain-package debootstrap debhelper pkg-config po4a libncursesw5-dev zlib1g-dev libbz2-dev flex libselinux1-dev libio-string-perl quilt autoconf automake cvs gawk dpatch texinfo sharutils libgmp3-dev libmpfr-dev lsb-release realpath cdbs docbook-to-man dbs bison
    

dpkg

  1. Test dpkg: dpkg-architecture -a<your arch> should emit lots of variables. Check the correctness of variables.
  2. In case dpkg-architecture is not enlightened enough, fix it (see /usr/share/dpkg/*table and commits to dpkg git for the reference) and send patches to mailing list / maintainer / IRC.

toolchain

  1. Create a new directory and clone the binutils-host, linux-libc-dev, gcc-4.3, glibc, and uclibc git repositories into it: (–depth 1 means don't fetch any history, which is huge for the linux kernel)
    mkdir toolchain-build; cd toolchain-build
    
    for i in binutils-host gcc-4.3 glibc uclibc; do
      git clone git://git.iplinux.org/$i.git
    done
    
    git clone --depth 1 git://git.iplinux.org/linux-libc-dev.git
    
  1. Clone the mktpkg tool git:
       git clone git://git.iplinux.org/mktpkg.git
    
  2. In the directory with sources run:
    ./mktpkg/mktpkg -d <arch>
    
  3. See lots of error messages.
  4. Fix the problems, repeat until success.
  5. Send patches to mailing list / maintainer / IRC.

To test the toolchain, you can build a minimalistic rootfs with it:

Get the source code:

mkdir pkg-build; cd pkg-build

for i in apt apt-keys base-files base-passwd busybox dpkg dropbear fakechroot-cross-target-helper ifupdown ncurses netbase perl sysvinit zlib; do
  git clone git://git.openinkpot.org/$i.git
done

Build and cross a few essential libraries:

for i in ncurses zlib ; do
  (cd $i; dpkg-buildpackage -b -us -uc -a<ARCH>)
done

sudo dpkg-cross -i -a <arch> libz1-dev_*.deb libz1_*.deb libncurses5-dev_*.deb libncurses5_*.deb

Build some basic utilities:

for i in apt akt-keys base-files base-passwd busybox dpkg dropbear fakechroot-cross-target-helper ifupdown netbase perl sysvinit; do
  (cd $i; dpkg-buildpackage -b -us -uc -a<ARCH> -d)
done

Now, we use debootstrap to build the rootfs.

Create the repository containing your packages and the toolchain (only the libs are required):

mkdir repo
cd repo
cp ~/pkg-build/*.deb ~/toolchain-build/*.deb .
apt-ftparchive --option=Tree::Architectures=<ARCH> packages . > Packages
mkdir -p dists/zelazny/main/binary-<ARCH>
ln -s ../../../../Packages dists/zelazny/main/binary-<ARCH>/Packages

Build the rootfs:

cd ~
sudo debootstrap --arch=<ARCH> --foreign --components=main zelazny rootfs file:///home/build/repo

profit!

  1. Enjoy your new shiny toolchain and rootfs.