magic to build package on different FreeBSD versions
Sometimes you may need to build some packages for older/newer versions of FreeBSD. That is simple if you use jail and other mechanisms.
In order to be successful, you need a “Full jail” say ordinary jail, installed with binary that is built from the target version of FreeBSD. For instance, build a 6.0 userland by sync’ing code to -HEAD.
Secondly, you need to replace two files in the jail: uname(1) and sysctl(1). What you have to do is to use sed to replace both FreeBSD version and __FreeBSDVersion (say, kern.osreldate), according to porters' handbook.
My uname returns:
build6# uname -a
FreeBSD build6.freebsdchina.org 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Thu Feb 24 18:54:19 CST 2005 email@example.com:/usr/obj/usr/src/sys/FORKTEST i386
While the old one returns:
build6# _uname -a
FreeBSD build6.freebsdchina.org 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #0: Thu Feb 24 18:54:19 CST 2005 firstname.lastname@example.org:/usr/obj/usr/src/sys/FORKTEST i386
The script is quite straightforward:
build6# cat /usr/bin/uname
/usr/bin/_uname $* | sed -e s/5.4/6.0/g -e s/PRERELEASE/CURRENT/g
Note you have to change the script to reflect *your* system. Of course these scripts can be improved to automagically use 5.4 and CURRENT, PRERELEASE, or whatever automatically, but here I don’t want to introduce another problem :-)
Now you can build packages for different version of FreeBSD!