PKGBUILD

From PacBSD Wiki
Jump to: navigation, search


For general information about how PKGBUILDs work, see the ArchLinux PKGBUILD wiki entry here.

Packaging for PacBSD[edit]

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[edit]

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[edit]

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
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[edit]

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[edit]

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[edit]

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[edit]

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[edit]

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[edit]

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[edit]

To make it easier to update patches in the PKGBUILD, we highly recommend using the following convention for ports patches

port_patches=(
        port patch files listed here
)

source=(
        original sources here
        "${port_patches[@]}"
)

  for _patch in "${port_patches[@]}"; do
    msg "Patching port patch $_patch"
    patch -p0 -i "${srcdir}/$_patch"
  done

Linux Binaries[edit]

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[edit]

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[edit]

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[edit]

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
  • 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!

See Also[edit]