This page was exported from phaq
[ http://phaq.phunsites.net ] Export date: Thu Apr 25 17:33:41 2024 / +0000 GMT |
Hi again. My last post covered the installation of FreeBSD on the Raspberry Pi. Here's part 2 of my series on that topic. As I pointed out last time there's currently only few experimental packages around, and yet, those few repositories out there are far from being complete. So it's about time to see how to build packages for the Raspberry Pi on FreeBSD. As the Pi isn't very fast, it's a good thing to look into cross-compiling packages. I'm using a VM which runs FreeBSD 10.2 amd64 to achieve this. The VM has 4 cores and 8 GiB RAM, which should be more than enough for compile runs at decent speed. As we're using a dedicated build machine, our whole build dependencies will be compiled from scratch as well. This is required anyway because we need poudriere-devel, which has cross-compile support. poudriere-devel is available as pre-compiled package for x86 platforms, but does not include qemu build support. So that's why we gonna build it ourselves, along with other tools. Enable and Prepare ZFSFirst you'll need to enable ZFS as poudriere demands it. Add this line to /etc/rc.conf:
Then restart ZFS daemon:
Afterwards a ZFS pool should be initialized. I decided to call mine build and mount it beneath /build because I don't like cluttering /usr/local with my poudriere stuff. Nedless to say that you need to have plenty of free space. I gave it some 250 GiB as a start.
Software Dependencies
Then install poudriere-devel like this. Make sure to check the qemu option once the config dialog is shown. Additionally you should install subversion. I'm not in the need for it as I use an existing snapshot, but it comes to good use later on if we should need to update the sources.
Configure poudriereTo use poudriere, edit the configuration file at /usr/local/etc/poudriere.conf and set these values:
Now let poudriere fetch the ports tree and give it a proper name. I used the name of p09_2015. You're free to call it whatever you like. Since I usually have multiple ports tree for several releases around, I make them bear a date-specific name.
Before you can actually start building the ports, we must register a handler for ARMv6 binaries. This is done using the binmiscctl utility. Be sure to check out the manpage for the proper syntax, which in our case should be:
Same once again as an image, just in case Wordpress would rip my code apart ;-) To keep the change persistent, copy the above line to the file /etc/rc.local. Create it if necessary. If you don't register the handler properly, poudriere will produce an error.
Building a Jail from a SnapshotRight, you can use a snapshot, extract it and then feed it to poudriere in order to create the jail.
Now attach it to a md loopback device in order to mount it.
mdconfig will return a device name, ie. md0. Then mount the root filesystem into /mnt. It is utterly important to copy over the qemu-arm-static binary from your host's /usr/local/bin directory into /mnt/usr/local/bin. Yes, it's true, your x86 static binary belongs in there, otherwise the jail will terribly fail at startup. The emulator must exist within the jail in order for the emulation to work! Afterwards the contents of /mnt is to be tar'ed up.
Now let poudriere create the jail from the previously created tar file:
Finally, have poudriere build a port, shells/bash in this example, to see if it works.
If everything goes smooth, you should see something like this: Check out top, which should expose may child processes for qemu indicating that it actually works. last pid: 36214; load averages: 2.02, 0.92, 0.47 up 0+06:55:35 02:50:03 So this is it on how to build packages for armv6 via cross-compiling. Of course this is not yet the end of the story, since we're building a single package here. There's two more ways on how to invoke poudriere. You can have poudriere build from a list of ports listed in a file. The file has the basic format of category/portname, i.e. editors/vim-lite Run poudriere like this to process all ports in the file:
Alternatively you could build the whole ports tree if you pass the -a argument. poudriere bulk -j My next blog will cover how to expose the package repository created by poudriered via http, so stay tuned. Know IssuesHere's some known issues I came along during the setup. Error: Unable to execute id(1) in jail. Emulation or ABI wrong.If poudriere bails out with this message, then emulation is indeed not working. Reasons include:
If you doubt that the emulation actually works, you can easily test it without poudriere. Make sure that your ARM snapshot is mounted at /mnt as described above. Copy the qemu-arm-static binary over to /mnt/usr/local/bin/qemu-arm-static as described. Then run this command:
If you don't get an error it does work. You can double check by issueing this command:
If everything really works, you should get the uname output indicating that it runs on ARM. Doing the same on your host would indicate running on x86. Further ReadingNow that you have mastered a successful package build, you'll notice that it's not really faster than compiling natively on the Raspberry Pi. Sure, a centralized build and package repository is still better, because you don't go through the tedious package build for each device. If you want to get faster results, you'll need to install a cross-compile toolchain into your poudriere jail. Be sure to read how to use host cross-compiler with poudriere if you're interested in this. |
Powered by [ Universal Post Manager ] plugin. HTML saving format developed by gVectors Team www.gVectors.com |