Wednesday, February 6, 2008

NanoBSD - part 1

Wow, where do I start. Last year, I picked up a few Soekris net4521 boards from the Orlando Hamcation. The guy didn't know what he had and sold them to me for $10 each. Nice. I tinkered around with them a little bit last year and got some help with kernel, world, and package building for the NanoBSD image from Bruce Mah. I had built up a nice image on a 512MB CF card and played for a bit, but then life came charging back in and I had to shelve the project for a while.

Now I am back, and here is some stuff to chew on. First, here is a short shell script that I wrote and dropped into /usr/src/tools/tools/nanobsd to evaluate the packages in /usr/src/tools/tools/nanobsd/Pkg and determine if there were any missing dependencies before starting the image building process.

#!/bin/sh
#
# make packages for /usr/src/tools/tools/nanobsd/Pkg:
# if the port is already installed:
# cd /usr/src/tools/tools/nanobsd/Pkg && pkg_create -vyb netcat-1.10_2
# if the port is not installed:
# cd /usr/ports/net/netcat && make package && mv \
# /usr/ports/packages/All/dnsmasq-2.38.tbz /usr/src/tools/tools/nanobsd/Pkg/
#
#
# next, run this script to ensure that you aren't missing any deps for the packages
# you want in your image.
#
# after that, you can run `sh nanobsd.sh -c nanobsd-soekris.conf` to build a new image
#
# or, if you are just adding/removing packages to the existing image, you can
# run `sh nanobsd.sh -b -c nanobsd-soekris.conf` to save the time of building world
# and kernel.
#

cd /usr/src/tools/tools/nanobsd

rm -f pkg_deps.list

cd /usr/src/tools/tools/nanobsd/Pkg

for each in *.tbz;
do
pkg_info -r ${each} | grep Dependency | cut -d' ' -f2 | while read dep
do
/bin/ls -1 | grep ${dep} >/dev/null || echo "${each} needs ${dep}" >>/usr/src/tools/tools/nanobsd/temp.$$
done
done

cd /usr/src/tools/tools/nanobsd

[ -f temp.$$ ] && (cat temp.$$ | sort | uniq >pkg_deps.list && rm -f temp.$$)

That works pretty well. After ensuring that my package list was good to go, I started the build process and it went well. Much thanks need to go to Poul-Henning Kamp for his work on the NanoBSD infrastructure, it's just simply wonderful.

Right now, I am using a Soekris net4521 as my firewall, running off of a little 12v DC wall-wart, instead of the old power-sucking 400w AC-powered tower that I was using. Saving power and money, which are good things, and now I have moved from using IPFW/IP6FW on that old tower to using PF on this Soekris. More about using PF later!

No comments: