Modifying a FreeBSD port
Installing software on FreeBSD is made easier by the ports
system; a
collection of Makefiles and patches that contains instructions on how to build
programs and libraries.
E.g. building and installing the mpv
media player is done in the following way:
# cd /usr/ports/multimedia/mpv # make install clean
This first checks if all the requisites are available and installs them if
not.
Then it builds and installs mpv
itself.
In this article I want to explain how to create and file a bug report for a port.
Recently I tried to use the pulseaudio
sound server with mpv
, the
build failed:
Checking for SDL (1.x) : disabled Checking for OSS (implementation from opensound.com) : no Checking for OSS (platform-specific OSS implementation) : yes Checking for OSS (emulation on top of SunAudio) : oss-audio-native found Checking for OSS audio output : yes Checking for audio select() : yes Checking for RSound audio output : no Checking for sndio audio input/output : no Checking for PulseAudio audio output : no You manually enabled the feature 'pulse', but the autodetection check failed. *** Error code 1
Since I know that pulseaudio is installed and running, there must be something wrong with the port.
First I create two copies of the port, and try to build the software:
> mkdir ~/tmp/ports > cd ~/tmp/ports > cp -Rp /usr/ports/multimedia/mpv . > cp -Rp mpv mpv.orig > cd mpv > make
When the build fails, I look into the work directory to find mentions of pulseaudio:
> cd work/mpv-player-mpv-88f247c/ > grep '[Pp]ulse' * README.md:- Audio output development headers (libasound, pulseaudio) old-configure: opt_yes_no _pulse "Pulseaudio audio output" old-configure:check_pkg_config "PulseAudio" $_pulse PULSE 'libpulse >= 1.0' old-makefile:SOURCES-$(PULSE) += audio/out/ao_pulse.c wscript: 'name': '--pulse', wscript: 'desc': 'PulseAudio audio output', wscript: 'func': check_pkg_config('libpulse', '>= 1.0') wscript_build.py: ( "audio/out/ao_pulse.c", "pulse" ), wscript_build.py.bak: ( "audio/out/ao_pulse.c", "pulse" ),
The last match from the wscript
file caught my eye, since the installed
version of pulseaudio is:
> pkg info -x pulse pulseaudio-0.9.23_2
At this point I could try and update the pulseaudio port, but the simplest fix
is to patch wscript
and see if that works:
> cp wscript wscript.orig > gvim wscript > diff -u wscript.orig wscript --- wscript.orig 2014-08-23 11:02:47.000000000 +0200 +++ wscript 2014-08-23 11:05:06.000000000 +0200 @@ -468,7 +468,7 @@ }, { 'name': '--pulse', 'desc': 'PulseAudio audio output', - 'func': check_pkg_config('libpulse', '>= 1.0') + 'func': check_pkg_config('libpulse', '>= 0.9') }, { 'name': '--portaudio', 'desc': 'PortAudio audio output',
To make this patch apply automatically in the build process, it has to be put
in the files
subdirectory of the port. Since that doesn’t exist yet for
mpv
, it is created first:
> mkdir ../../files > diff -u wscript.orig wscript >../../files/patch-wscript
With this change, the build works fine:
> cd ../.. > make clean ===> Cleaning for mpv-0.5.0_1,1 > make ... Waf: Leaving directory `/home/rsmith/tmp/ports/mpv/work/mpv-player-mpv-88f247c/build' 'build' finished successfully (18.027s) ===> Staging for mpv-0.5.0_1,1 ... ====> Compressing man pages (compress-man)
After installing and trying the modified port, it turned out that it works correctly.
The next step is to create a diff between the unmodified and the modified port:
> make clean > cd .. > diff -ruN mpv.orig mpv >patch-mpv > cat patch-mpv diff -ruN mpv.orig/files/patch-wscript mpv/files/patch-wscript --- mpv.orig/files/patch-wscript 1970-01-01 01:00:00.000000000 +0100 +++ mpv/files/patch-wscript 2014-08-23 11:07:30.000000000 +0200 @@ -0,0 +1,11 @@ +--- wscript.orig 2014-08-23 11:02:47.000000000 +0200 ++++ wscript 2014-08-23 11:05:06.000000000 +0200 +@@ -468,7 +468,7 @@ + }, { + 'name': '--pulse', + 'desc': 'PulseAudio audio output', +- 'func': check_pkg_config('libpulse', '>= 1.0') ++ 'func': check_pkg_config('libpulse', '>= 0.9') + }, { + 'name': '--portaudio', + 'desc': 'PortAudio audio output',
This patch is then submitted to FreeBSD’s bugzilla. It is listed as
bug 192941. It has the above mentioned patch attached. Note that the
description starts with the word [patch]
to let the maintainers know that
the bug report contains a solution to the problem. The name and directory of
the port are also part of the description.
For comments, please send me an e-mail.
Related articles
- Writing speed on FreeBSD 13.1-p2 amd64 with ZFS
- FreeBSD 13.1 install on a Lenovo IdeaPad 5
- Gnumeric build fix for FreeBSD
- Writing speed on FreeBSD 12.1-STABLE amd64
- Cleaning up old port configurations