Creating FreeBSD ports
Anton Berezin
tobez@tobez.org
A bit of meaningless statistics
Probably the best beer^W^Wlargest collection in the world.
Old technology - a bunch of Makefiles
Infrastructure - include makefiles - ~19000 lines
Relatively well documented
The FreeBSD Porter's Handbook
http://www.freebsd.org/doc/en/books/porters-handbook/
The most important include file: Mk/bsd.port.mk
If you are serious - read it, too!
If all else fails, going through it will answer your questions
Makefile - how to build it
distinfo - what files constitute a distro
pkg-plist - what files it contains
files/patch-* - FreeBSD-specific patches
src/* - when the port is self-contained
COMMENT (an inode-saving device)
Overriding built-in targets
post and/or pre stage targets
pre-something:/post-something:
Most useful: post-patch: and post-install:
ports-mgmt/portlint helps
So you have an idea for a port
First thing - make sure it is not already there!
Sometimes it may lurk in a non-obvious place
Sometimes it might be non-obviously named
Is there a PR open for it?
http://www.freebsd.org/cgi/query-pr-summary.cgi?query
Use a similar existing port as a starting point
For non-obvious things, try to find a port that already does a similar thing
Try to follow existing conventions
mailing list freebsd-ports@freebsd.org
Most of the ports I do these days have a p5- prefix
If I am bored, I just pick one at random
First we'll go for a simple one
Make sure the software builds OK by hand
cp -pr p5-Text-CSV p5-Text-LooseCSV
mkdir /var/tmp/$(make -V PORTNAME)
mtree -U -f $(make -V MTREE_FILE) -d -e -p /var/tmp/$(make -V PORTNAME)
make depends PREFIX=/var/tmp/$(make -V PORTNAME)
make install PREFIX=/var/tmp/$(make -V PORTNAME)
/usr/ports/Tools/scripts/plist -Md -m $(make -V MTREE_FILE) /var/tmp/$(make -V PORTNAME) > pkg-plist
%%SITE_PERL%% and %%PERL_ARCH%%
shar `find p5-Text-LooseCSV` >/tmp/port.shar
http://www.freebsd.org/doc/en/books/porters-handbook/porting-submitting.html
Only *then* bug a committer you know on IRC
Quite a bit of all this can be automated
Quite a bit of it *is* automated (many times over)
Do not skimp on the manual steps the first few times
Then you are back to basics
So - understand the basics
We'll go now for Perl6-GatherTake
This one has dependencies
As we can see examining Makefile.PL
Do we have a port for Coro?
Pitfall: different Perl versions
Ergo, Perl6-GatherTake wants it, too
Also included in perl5.8 itself
Proceed with manual build
but we'll put it in lang anyway
ports/devel is sort of a backup place
ls /usr/ports/devel|wc -l
cp -pr p5-Perl6-Subs p5-Perl6-GatherTake
Let's put some whitespace!
mkdir /var/tmp/$(make -V PORTNAME)
mtree -U -f $(make -V MTREE_FILE) -d -e -p /var/tmp/$(make -V PORTNAME)
make depends PREFIX=/var/tmp/$(make -V PORTNAME)
make install PREFIX=/var/tmp/$(make -V PORTNAME)
/usr/ports/Tools/scripts/plist -Md -m $(make -V MTREE_FILE) /var/tmp/$(make -V PORTNAME) > pkg-plist
%%SITE_PERL%% and %%PERL_ARCH%%
pkg_delete p5-Perl6-GatherTake-0.0.3
shar `find p5-Perl6-GatherTake` >/tmp/port.shar
Ok, let's try something else
hmm, this englab thing is interesting
so we'll make the library port first
real patch or post-patch:
cp configure configure.orig
diff configure{.orig,} >patch-linuxisms
mkdir /var/tmp/$(make -V PORTNAME)
mtree -U -f $(make -V MTREE_FILE) -d -e -p /var/tmp/$(make -V PORTNAME)
make depends PREFIX=/var/tmp/$(make -V PORTNAME)
make PREFIX=/var/tmp/$(make -V PORTNAME)
questions so far, while it builds?
make install PREFIX=/var/tmp/$(make -V PORTNAME)
/usr/ports/Tools/scripts/plist -Md -m $(make -V MTREE_FILE) /var/tmp/$(make -V PORTNAME) > pkg-plist
No more slides for this port
Just walk through the port creation
Pitfall: different FreeBSD versions
Pitfall: different gcc versions
Pitfall: different architectures
testing, testing, testing
Thank you.
Thank you!
Any questions?