Skip to content

Instantly share code, notes, and snippets.

@bradfa
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfa/ea5860f1adde6b43ef81 to your computer and use it in GitHub Desktop.
Save bradfa/ea5860f1adde6b43ef81 to your computer and use it in GitHub Desktop.
Meroot Notes

What's Aboriginal Doing?

  1. Aboriginal builds a simple cross compiler, basically the same thing musl-cross does.
  2. Aboriginal builds a statically linked native compiler (not actually Canadian, iirc, as target and host are the same) along with make, basically the same thing meroot does now.
  3. Aboriginal builds a rootfs and kernel for the target, meroot builds a busybox rootfs with a few extra tools.
  4. Aboriginal combines the rootfs, kernel, and native compiler with a bunch of other special scripts and QEMU things to make a bootable system that can build things, which isn't really needed if you're going to boot in or chroot if the arch is close enough.

What Should I Do?

  1. Use musl-cross to create a cross compiler.
  2. Build a busybox based rootfs using embedded clfs method.
  3. Expand musl-cross to create a native compiler and make taking clues from Aboriginal, install into rootfs. (Will this gcc delete the /lib/ld symlink issue?)
  4. Chroot in and make sure things work.
  5. PROFIT? (too many steps)

To try first:

  1. Static busybox rootfs, then chroot in and play. (CHECK!)
  2. Static binutils, GCC, make, and m4 into rootfs, then chroot in and play. (CHECK!)
  3. In chroot, build dynamic musl. (CHECK!)
  4. In chroot, bootstrap pkgsrc, which needs gawk it seems... (CHECK!)
  5. In chroot, build stuff from pkgsrc (like gawk, m4, make, gcc, and anything else)
  6. In chroot, delete non-pkgsrc m4, make, gcc, gawk, binutils.

To chroot in, ensure /proc and /dev come from the host, and copy over /etc/resolv.conf

mount -t proc proc /tmp/meroot/proc
mount --rbind /dev /tmp/meroot/dev
cp /etc/resolv.conf /tmp/meroot/etc/

So, in the target, steps are:

  1. source /etc/profile
  2. Build and install dynamically linked musl ./configure --prefix=/ --includedir=/usr/include
  3. Build and install gawk ./configure --prefix=/usr
  4. Get a tarball of pkgsrc and bootstrap it. Use bmake for pkgsrc things.
  5. Pkgsrc install gawk, gcc, m4, binutils
  6. Maybe rebuild busybox dynamically?

To get pacman (was dpkg) working so we can package:

  1. Build and install dynamic musl wget http://www.musl-libc.org/releases/musl-1.1.6.tar.gz, unpack, then ./configure --prefix=/ --includedir=/usr/include && make && make install
  2. Build and install zlib wget http://zlib.net/zlib-1.2.8.tar.gz, unpack, then ./configure --prefix=/usr && make && make install
  3. (NEEDED?) Build and install perl5 wget http://www.cpan.org/src/5.0/perl-5.20.1.tar.gz, unpack, ensure there's no config.sh file around, then sh Configure -Dcc=gcc -Dprefix=/usr -s && make && make install
  4. (NEEDED?) Build and install ncurses wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz, unpack, then ./configure --prefix=/usr --with-shared && make && make install
  5. (FAILS TO BUILD) wget http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_1.17.23.tar.xz, unpack, then ./configure --prefix=/usr --with-zlib --disable-nls
  6. Build and install libarchive wget http://libarchive.org/downloads/libarchive-3.1.2.tar.gz, unpack, then ./configure --prefix=/usr && make && make install

To get slackware pkgtools working

  1. musl
  2. tar-1.13
  3. zlib?
  4. gzip
  5. profit?
  6. core-utils

But, once you have all this, when you try to install the musl package, then at some point (due to how slackware packages don't package up symlinks, their creation happens in the doinst script) more steps have to happen but the musl symlink from /lib/ld to /lib/libc.so is gone so anything which is dynamically linked can't run, which means the symlinks can't be made (ln is from coreutils and is dynamically linked for me right now) or a bunch of other stuff can't happen. This is fun...

So, to fix we have 2 choices:

  1. Static link everything above (tar, gzip, core-utils)
  2. Rewrite some parts of pkgtools to use what busybox (or maybe toybox?) provides (mainly it's the fancy ls --time-style=long-iso, the gzip -9c along with bzip2 -9c which try to get maximal compression and I think some tar options as newer than tar-1.13 is unstable?).

For 2, this is easy to solve for gzip and bzip2, and I think tar from busybox is probably fine. The ls --time-style part I think just makes ls output in a standard format, since ls likes to be human readable with dates so the following cuts may get offset if the date format isn't consistent. Busybox ls -e will output a consistent date format but is not in coreutils version of ls, so check which one is being used and then adapt.

pkgsrc Makefile issues

These steps probably aren't actually needed. It seems that bmake got installed into pkgsrc /usr/pkg/bin somehow.

If a pkgsrc Makefile has any .include <BLAH> it seems that gnu make is barfing with Makefile:3: *** missing separator. Stop. errors. This seems odd...

Apparently bmake is needed, but bmake's make install requires bash, which is annoying...... Maybe in the bootstrap? So maybe my whole "let's build bmake" adventure is for naught? 2. Build and install bash 2.05b ./configure --prefix=/usr --disable-bash-malloc --disable-readline 3. Build and install make (this time without any special exclusions) ./configure --prefix=/usr 4. Build and install bmake ./configure --prefix=/usr then follow the bootstrapping, then make install (needs bash)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment