PKGBUILD
For general information about how PKGBUILDs work, see the
ArchLinux PKGBUILD wiki entry
here.
Contents
Packaging for PacBSD
In general, when writing a PKGBUILD for PacBSD, both the Ports tree's patches and Makefile should be checked. If ports-patches fail to apply, this is usually because you're building a version newer than ports. If ArchLinux patches fail to apply, they might be conflicting with ports patches.
It is generally a good idea to let the ports system's modifications take precedence over the ArchLinux PKGBUILDs since the ports are FreeBSD specific.
When taking over patches from the ArchLinux package, make sure they aren't linux-specific! (Dont' be fooled by names like 'patch-linux-3.8', they might still be valid...)
Differences
We are trying to keep the required changes between PKGBUILDs are small as we can and thus switched over to using /usr as our prefix, instead of /usr/local. We are also keeping ArchLinux's default pkgconfig and font directories. Only packages which otherwise conflict with the freebsd-world package will be installed to /usr/local, and others, like GNU make and GNU m4 get a --program-prefix=g much like in ports, and exist as /usr/bin/gmake and /usr/bin/gm4
Packages provided by World
Note that FreeBSD's world comes with a few packages you should not list as dependency in your PKGBUILD, unless you explicitly require a newer version. Also note that you should not include glibc as dependency which some original ArchLinux packages do.
amd bind9 bsnmp bzip2 clang com_err compiler-rt cvs dialog diff dtc ee expat file flex gcc gcclibs gdb gdtoa gnu-sort gperf groff gzip ipfilter krb5 less libarchive libbegemot libc++ libc-pwcache libc-vis libcxxrt libpcap libreadline libstdc++ lukemftpd |
mknod mtree ncurses netcat ngatm ntp nvi ofed one-true-awk openbsm openpam openresolv openssl opie pam_modules pf pnpinfo readline sendmail sh smbfs tcp_wrappers tcpdump tcsh telnet texinfo tnftp top traceroute tzcode tzdata wpa xz zlib (... possibly others?) |
Port Hacks and Tips
The following will assist in making PKGBUILDS for PacBSD to make sure programs work / compile as expected. These should be applied to the PKGBUILD after patches and before configure.
libtool
In some cases, it is best to use the libtool script provided in /usr/bin/libtool as opposed to one that ship their own script. Sometimes the ones included in source directories messes up library naming. You can add the following before configure in PKGBUILDS to fix this. Generally have this set if the ports have: USE_AUTOTOOLS = libtool in the Makefile.
sed -i '' -e "/^ltmain=/!s|\$$ac_aux_dir/ltmain.sh|/usr/share/libtool/config/ltmain.sh|g" \ -e "/^LIBTOOL=/s|\$$\(top_builddir\)/libtool|/usr/bin/libtool|g" \ ${srcdir}/${pkgname}-${pkgver}/aclocal.m4 find ${srcdir}/${pkgname}-${pkgver} -name "Makefile.in" | xargs sed -i '' -e 's|^LIBTOOL[ ]*=.*|LIBTOOL=/usr/bin/libtool|g'
arch-detection
In some cases, the configure script might check the host-arch (error out on "unsupported host" or something similar). In that case just add this before ./configure
sed -i '' -e "s|amd64-\*-freebsd\*|x86_64-*-freebsd*|g" \ -e "s|i386-\*-freebsd\*|i686-*-freebsd*|g" \ ./configure
Gnomehack
If a port uses the gnome hack, it may be worth adding the following command to your PKGBUILD to make sure the applications link against -pthread instead of -lpthread:
find ${srcdir}/${pkgname}-${pkgver} -name "configure" -type f | xargs sed -i '' -e 's|-lpthread|-pthread|g'
fam
When a port has USE_FAM set in the Makefile, have the PKGBUILD depend on gamin. Some dependencies that aren't needed on Archlinux are required on ArchBSD, this is mostly due to stuff being took care of by systemd and the likes.
Port Dependencies
Most of the time no changes need to be made, the following is still worth knowing:
You can get a list of dependencies for the PKGBUILD you're working on by visit the port directory: /usr/port/category/pkgname and running the following.
For a list of run depends that the port uses:
make -V RUN_DEPENDS
For a list of build depends that the port uses:
make -V BUILD_DEPENDS
Port Patches
To make it easier to update patches in the PKGBUILD, any port patches that needs to be applied should be placed in a files subdirectory of the package directory. With this makepkg
will automatically detect the patches when ran and include and apply them for you.
In cases where directory containing the program's source code does not follow the packagename-version
convention, or the source code is in a subdirectory, then makepkg
will fail to apply the patches. This can be resolved by manually telling makepkg
where to apply the patches by setting the patchdir
variable in PKGBUILD file to the correct path.
pkgname=nss pkgver=3.32 pkgrel=1 pkgdesc="Mozilla Network Security Services" arch=(i386 amd64) url="http://www.mozilla.org/projects/security/pki/nss/" license=('MPL' 'GPL') _nsprver=4.12 depends=("nspr>=${_nsprver}" 'sqlite' 'zlib' 'sh' 'p11-kit') makedepends=('perl' 'python2' 'binutils' 'docbook-xsl' 'xmlto') options=('!strip' '!makeflags' 'staticlibs') patchdir=("nss-$pkgver/nss") source=("https://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/NSS_${pkgver//./_}_RTM/src/${pkgname}-${pkgver}.tar.gz" certdata2pem.py bundle.sh nss.pc.in nss-config.in nss-config.xml) sha256sums=('35c6f381cc96bb25e4f924469f6ba3e57b3a16e0c2fb7e295a284a00d57ed335' '512b12a2f13129be62c008b4df0153f527dd7d71c2c5183de99dfa2a1c49dd8a' '3bfadf722da6773bdabdd25bdf78158648043d1b7e57615574f189a88ca865dd' 'f2208c4f70373ff9b60f53d733f8071d4e390c384b776dfc04bf26c306882faf' 'e44ac5095b4d88f24ec7b2e6a9f1581560bd3ad41a3d198596d67ef22f67adb9' '98ace873c63e8e870286bce3ed53249aa2655cc1f53e7049061476e650ab06f1')
In this example makepkg
will apply the patches in ${srcdir}/nss-$pkgver/nss rather than ${srcdir}/nss-${pkgver}
Linux Binaries
You need to brand linux binaries to work with the linux base. Add the following to the PKGBUILD to do this.
find ${pkgdir}/compat/linux/{bin,sbin,usr/bin,usr/sbin} -type f -print0 \ | xargs -0 brandelf -t Linux
sed
In PacBSD -i option requires presence of '' even if empty.
A command sed -i -e "s/rt/tr/g"
would become in ArchBSD sed -i'' -e "s/rt/tr/g"
Architectures
When going through the ports system's Makefile you may notice it taking additional architectures into account, like sparc64 or ia64. PacBSD currently only targets i386 and amd64.
If you need architecture specific settings, use the $CARCH variable.
Converting a PKGBUILD
When starting with an ArchLinux PKGBUILD, the following steps are usually necessary:
- Fix up install commands: The -D switch means something entirely different here!
- Turn
install -Dm644 license.txt ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
- into
install -dm755 ${pkgdir}/usr/share/licenses/${pkgname}
install -m644 license.txt ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
- Turn
- Translate sed commands, or simply replace 'sed' with 'gsed': ArchLinux PKGBUILDs assume gsed behavior.
- Copy and add port's patches as required BEWARE: patch-Makefile.in or similar might do ugly freebsd-patching! Beware of makefile-patches!
- Check ArchLinux and port's packages for linux/ports specific changes and remove if necessary
- Translate commands from the port's post-patch section and possibly others.
- Compare ./configure parameters between ArchLinux and ports and use ones which make sense!
- Test!