Adventures in tinderbox 2

Submitted by Shane on Sat, 23/06/2012 - 11:42pm

If you stumbled into this post first you may want to have a look over
this previous post
as we are building upon steps covered there.

So far we have got our world binaries built and these are the foundation
of the environments we setup for testing our port builds. From here we create
a tinderbox build. Within tinderbox a build refers to a combination of
world binaries (the tinderbox jails we setup before) and a version of the
ports files. It is probably a rare case but it would appear that you could
setup a build using say netbsd pkgsrc system or similar, the most likely
alternative to the official ports system would be an internal development
branch of the ports source.

The first step is to setup the ports files to be used. A cvs checkout is
shown in the docs and you could adjust the svn usage from yesterday if you
have your own local svn repo (official ports are still in cvs at this point).
The examples in the docs show a source checkout that is unique to your
tinderbox setup. I think using the system installed ports will be enough
for what I want and will bypass the confusion of three copies of the
ports files. Personally I use portsnap to update my system ports tree and
create or update a port there to test and develop it. Then I have a copy
within my home folder that is an svn checkout from my
redports
account that I transfer changes to that I want to keep, and commit as desired
from there. While my personal folder is just the ports I make changes to, I
don't want a third copy just for test builds, so what I will use here is a
user defined update method that will run portsnap anytime I want to
update the ports tree. We have two options here,
1. create a portsTree with no update method leaving us to run portsnap manually as desired.
2. create a portsTree with a user update method. The first option is straight
forward and acceptable for most but I want to look at option 2 here.

Reading the docs you may jump straight in and use a command like
cd /usr/local/tinderbox/scripts
./tc createPortsTree -p FreeBSD -u USER -m /usr/ports
and get errors and no ports tree setup. The docs don't help here so I
went digging through the scripts and found the answer. When you create
a portstree with a user defined update method it looks for the update script
when it is first setup. The solution is simple. If we are creating a
portstree called FreeBSD then we create a file in tinderbox/portstrees/FreeBSD
and call it update.sh and for this example I want it to run portsnap so
I use the following contents -
#!/bin/sh
portsnap fetch update
Then run the createPortsTree command with the -u USER option. Simple and a
good basis of any custom update you want to setup. You could even use
this to run portsnap and then merge files from your personal ports
repo automatically. This setup script is run with the command ./tc updatePortsTree

You may also want to share your local distfiles with tinderbox. Pretty
easy and the one setup is shared across all portstree configs -

The name I used there may raise a few questions but first lets consider what
variations of builds we want to use.

The aim of using tinderbox is to test building under a variety of
conditions, in this case primarily different system versions. To that end
we started by creating 2 jails with different versions of world binaries,
you may have extended that number and I encourage you to do so but I use
two in these examples. From FreeBSD 9.0 we are moving away from a
dependency on gcc as the main compiler and now include clang within the
base system. Being in the early transition of this is a bit awkward as
not all ports build with the old gcc v4.2 that is included with base and
not all ports build with clang either. Well ports changes need to be tested
with each compiler so we may get a full ports build happening on any system install.
One option we have is to specify what version of gcc is used to build our port.
Easy till we get linking issues with something like boost installed with gcc42
and not linking with a gcc46 built port (that is my early guess and may
not be the location of a solution). So anyway I am suggesting that a number
of builds are setup to test building with clang as well as gcc. This will
only apply to 9.0 and higher, 8.3 has just entered beta1 and doesn't appear
to include clang. The other question you may have is that I only put clang
in the name, how does it know to build with clang? It doesn't yet - that comes in a minute.

Now we have four builds setup to test our ports in. As I suggested
before you should also consider having at least an 8-STABLE jail setup and
maybe even a 7-STABLE one as well if not more. As clang is not included in
7 or 8 there is no need to setup two builds for each, I would still use
gcc in the build name though.

At this point you will find a few directories have been created. The first
you will probably see is tinderbox/{BUILDNAME} so if your following along
you will have four there corresponding to each build you setup. The next
ones are inside tinderbox/builds and have the same names as the four we just
looked at. The dirs inside builds contain a Makefile with all the package
dependencies and although you may think make.0 and make.1 are makefiles they
are in fact logs containing the log of the last compile done, each port
compile is run in two phases, and a more than likely empty duds file.
The top level dirs are where all the work is done. For each port you make,
tinderbox will extract the tarball found in the corresponding jail build and
mount the various points needed for portstrees/distfiles/devfs/procfs.
From that you can work out that each build starts up in a unique environment
(it uses chroot) completely isolated for your test make. Each environment is
cleaned up after each test make and the log files will include files left
behind if you get your pkg-plist incorrect.

Now to configuring the compiler to use. When you first test making your
port and look at a log file you may notice that the timestamp at the start
is all wrong. That will be a wrong timezone setting and gets us close to
the compiler settings. First lets set the timezone, so edit the file
tinderbox/scripts/etc/env/GLOBAL and add the following line
(adjusted to match your timezone of course)

export TZ=Australia/Adelaide

You can see that it uses a bash style environment setting. Within the
same folder we want to create a config file for each build we setup using
the name build.{BUILDNAME} and have it contain the CC options that we wish
to use. Before you go thinking about copying all your /etc/make.conf settings
consider the purpose of this - testing against a minimum system config to
ensure your port is as compatible as possible. Those with a custom edited
make.conf need to handle their own port build conflicts with the options
they want to use. So here all we want to do is set the compiler to use.
To make this easy let's make a script, I will put this inside tinderbox/scripts
and lets call it gencompilerenvfiles.sh

Pretty straight forward if you know some shell scripting, if it's a bit
beyond what you know it simply gets a list of dirs from within builds and
outputs three lines to a corresponding config file for each one. The script
won't touch files that already exist, so delete them if you want a clean
slate or adjust if you want to add to existing files. The first loop uses grep
to get clang named builds the second gcc. Is it overkill specifying gcc
for the gcc builds - yep - but it keeps things consistent and also gets the
CC setting output to the log file to remove any confusion when looking over
them later, or more to the point when you get someone else to look
over them for some help.

Now your all setup to use tinderbox to test your ports building. While the
docs say you can do an adhoc build with just the tinderbuild command I find
that not to be the case, the two command you use are

The first time you build a port it may take a while - it will build each
dependency needed, basically running make package-recursive for your port.
Next time it will just pkg_add each dependancy and build the port you ask it to.
The -nullfs option is needed if you setup the nullfs mount for portstree as
shown above (or maybe it is for distfiles?). This adds some more dirs for you as well.

tinderbox/packages/{BUILDNAME} will contain all the packages created by that build.
You will find a folder for each category containing links to the corresponding
package inside the All dir.

tinderbox/logs/{BUILDNAME} will contain log files of each port compiled for that build.

tinderbox/errors/{BUILDNAME} will contain copies of the log files that had
errors - this is probably all your really interested in.

That's about all you need to get up and running with tinderbox. I think
I will do one more post covering some housekeeping and other notes. To
close off I'll show a script I use to automate running any number of ports
inside every build you have configured, I save it in tinderbox/scripts and call it testbuilds.sh

11286 comments

I'm amazed, I have to admit. Seldom do I encounter a blog that's both educative
and amusing, and without a doubt, you have hit the nail on the head.
The problem is something that too few folks are speaking intelligently about.
I'm very happy I found this during my search for something relating to this.

Woah! I'm really enjoying the template/theme of this
site. It's simple, yet effective. A lot of times it's very difficult to get that "perfect balance" between superb usability and visual appeal.
I must say that you've done a amazing job with this.
In addition, the blog loads extremely fast for
me on Chrome. Excellent Blog!

Howdy! I know this is somewhat off topic but I was wondering which blog platform are you using for this
site? I'm getting tired of Wordpress because I've had issues with hackers and I'm looking at
alternatives for another platform. I would be great if you could point me
in the direction of a good platform.

You really make it seem so easy with your presentation but I
find this matter to be really something which I think I would never understand.
It seems too complex and very broad for me. I'm
looking forward for your next post, I'll try to get the hang of it!

I'm extremely pleased to find this web site. I wanted to
thank you for your time for this particularly wonderful read!!
I definitely enjoyed every bit of it and i also have you book marked
to look at new things in your web site.

Greetings I am so grateful I found your blog page, I really found you by mistake, while I was researching on Google for something else, Anyways I am here now
and would just like to say kudos for a marvelous post and a all round entertaining blog (I also love the
theme/design), I don't have time to go through it all at the minute but I
have book-marked it and also added your RSS feeds, so when I have time I will be back to read a great deal more,
Please do keep up the great job.

You really make it seem so easy with your presentation but I find this matter to be really something which
I think I would never understand. It seems too complicated and
extremely broad for me. I am looking forward for your next post, I will try to get the hang of it!

After I originally commented I seem to have clicked the -Notify me when new comments are added- checkbox and
now every time a comment is added I recieve four emails with the same comment.
Perhaps there is a means you are able to remove me
from that service? Appreciate it!

I really love your site.. Pleasant colors & theme. Did you make this web site yourself?
Please reply back as I'm trying to create my own website and would love to
find out where you got this from or just what the theme
is named. Cheers!

Wonderful beat ! I wish to apprentice even as you amend your
web site, how could i subscribe for a blog site?
The account aided me a applicable deal. I have been tiny bit familiar of this your broadcast offered brilliant clear concept

Hi, Neat post. There is a problem along with your web site in internet explorer,
would test this? IE still is the marketplace chief and a huge
part of other folks will omit your excellent writing because of this problem.

I think that what you wrote made a great deal of sense. But,
what about this? what if you added a little information? I am
not saying your content is not solid, but what if you
added a post title that grabbed folk's attention? I mean Add new comment |
Shaneware.biz is kinda vanilla. You might glance at Yahoo's home page and watch how
they create post titles to get viewers interested.
You might add a video or a picture or two to grab people excited about everything've got to say.
Just my opinion, it might bring your blog a little livelier.

I have been exploring for a little for any high-quality articles or weblog posts in this sort of space .
Exploring in Yahoo I finally stumbled upon this site.
Studying this information So i'm satisfied to exhibit that I have an incredibly good uncanny feeling I discovered exactly what I needed.
I so much indisputably will make certain to do not disregard this website and give it a glance regularly.

Hey there! This post could not be written any better!
Reading this post reminds me of my old room mate!
He always kept chatting about this. I will forward this write-up to him.
Fairly certain he will have a good read. Thanks for sharing!

Please let me know if you're looking for a article author for your
blog. You have some really great articles and I feel I
would be a good asset. If you ever want to take some of the
load off, I'd really like to write some content
for your blog in exchange for a link back to mine.
Please blast me an e-mail if interested. Kudos!