Codec_opus module fails to load

I"m getting the following error message trying in the log file when asterisk tries to load the codec_opus.so module:

[2019-02-07 16:52:32.018] VERBOSE[976] loader.c: Loading codec_opus.so.
[2019-02-07 16:52:32.019] WARNING[976] config_options.c: Cannot update type 'opus' in module 'codec_opus' because it has no existing documentation!
[2019-02-07 16:52:32.019] ERROR[976] codec_opus_config.c: Opus: failed to register sorcery object type 'opus'

I followed the instructions for installing it when building asterisk and see in the output of make install that it got installed:

Installing modules from codecs…
codec_opus: Remote package version 13.0_1.3.0 (263680)
codec_opus: Downloading http://downloads.digium.com/pub/telephony/codec_opus/asterisk-13.0/x86-64/codec_opus-13.0_1.3.0-x86_64.tar.gz to /tmp/tmp.IrZ3LfI3K7/codec_opus-13.0_1.3.0-x86_64.tar.gz
codec_opus: Installing.
codec_opus: Installed.

I can confirm that the documentation files are present:

/var/lib/asterisk/documentation

find thirdparty -type f|xargs ls -l
-rw-r–r-- 1 asterisk asterisk 3660 Dec 11 2017 thirdparty/codec_opus_config-en_US.xml
-rw-r–r-- 1 asterisk asterisk 23456 Dec 11 2017 thirdparty/codec_opus/LICENSE
-rw-r–r-- 1 asterisk asterisk 2498 Dec 11 2017 thirdparty/codec_opus/README

The workaround for me is to install codec_opus_config-en_US.xml into /var/lib/asterisk/documentation root directory, but I don’t understand why the file is not getting picked up from ‘/var/lib/asterisk/documentation/thirdparty/codec_opus_config-en_US.xml’

Is there something that my configuration is missing that registers the thirdparty subdir?

Here are my core settings:

CLI> core show settings

PBX Core settings
Version: 13.24.1
Build Options: OPTIONAL_API
Maximum calls: Not set
Maximum open file handles: 803908
Root console verbosity: 3
Current console verbosity: 0
Debug level: 0
Maximum load average: 0.000000
Minimum free memory: 0 MB
Startup time: 17:19:41
Last reload time: 17:19:41
System: Linux/4.9.125-linuxkit built by root on x86_64 2019-02-07 16:10:35 UTC
System name:
Entity ID: 02:6b:99:25:00:ba
PBX UUID: 4fcb612d-b3ff-4513-892e-e0619c9a57e6
Default language: en
Language prefix: Enabled
User name and group: asterisk/asterisk
Executable includes: Disabled
Transcode via SLIN: Enabled
Transmit silence during rec: Disabled
Generic PLC: Disabled
Generic PLC on equal codecs: Disabled
Min DTMF duration:: 80
Cache media frames: Enabled
RTP dynamic payload types: 96-127

Subsystems
Manager (AMI): Enabled
Web Manager (AMI/HTTP): Enabled
Call data records: Enabled
Realtime Architecture (ARA): Disabled

Directories
Configuration file: /etc/asterisk/asterisk.conf
Configuration directory: /etc/asterisk
Module directory: /usr/lib64/asterisk/modules
Spool directory: /var/spool/asterisk
Log directory: /var/log/asterisk
Run/Sockets directory: /var/run/asterisk
PID file: /var/run/asterisk/asterisk.pid
VarLib directory: /var/lib/asterisk
Data directory: /var/lib/asterisk
ASTDB: /var/lib/asterisk/astdb
IAX2 Keys directory: /var/lib/asterisk/keys
AGI Scripts directory: /var/lib/asterisk/agi-bin

Thanks you so much in advance.

Did you build asterisk from the release tarball or from git/gerrit?

We built the from the asterisk-13.24.1.tar.gz tarball.

Is there a particular dependency I can check on or a flag I can add to configure or menuselect/menuselect that might influence the build to include the thirdparty subdirectory in the searchpath?

My top-level build process is essentially as follows:

contrib/scripts/install_prereq install
./bootstrap.sh
./configure  --libdir=/usr/lib64 --with-pjproject-bundled
make menuselect.makeopts
menuselect/menuselect --disable BUILD_NATIVE --enable codec_opus menuselect.makeopts
make
make DESTDIR=$RPM_BUILD_ROOT install
make DESTDIR=$RPM_BUILD_ROOT config

# install auto log rotate scripts
make DESTDIR=$RPM_BUILD_ROOT install-logrotate

Thanks.

I’ve been trying it multiple ways and can’t get it to fail. I wonder if it’s related to DESTDIR. Let me try that.
Are these commands being run from a spec file? If so, can you try running them directly from the command line without DESTDIR? Can you share the spec file?

I’d be happy to share our spec file, and I will try out shortly running the commands on a clean box directly later on without DESTDIR set.

For more context if it’s relevant, we are running this build in a Centos7 docker container. It’s been a very organic process to get it up and running as this is not our wheelhouse, but it’s worked for us to produce RPMs we use in our production systems.

Maybe I’m shooting myself in the foot somewhere in the files section of the spec file not picking up files I need?

#
# Followed these links that helped me build out the spec file
#
# http://rpm.org/max-rpm-snapshot/s1-rpm-build-creating-spec-file.html
# http://www.thegeekstuff.com/2015/02/rpm-build-package-example

# http://backreference.org/2011/09/17/some-tips-on-rpm-conditional-macros/
%if %{?_source_qualifier:0}%{!?_source_qualifier:1}
# use empty source qualifier
%define _source_qualifier %{nil}
%endif

# Default shell is /bin/sh, and I *think* some of the build scripts we run are assuming bash
%define _buildshell        /bin/bash

Summary: Asterisk (Custom Edition)
Name: ss-asterisk
Version: %{_version}
Release: %{_release}
License: GPLv2
Source: https://artifactrepo/misc/asterisk/asterisk-%{_version}%{_source_qualifier}.tar.gz
Vendor: Custom

Requires:      /usr/sbin/groupadd
Requires:      /usr/sbin/useradd

# Ran into this bug which required a later version of asterisk
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211707
# Here's how to specify it https://stackoverflow.com/questions/36760111/how-do-i-specify-a-requirement-for-a-minimum-version-of-openssl-in-rpm-spec-file
Requires: openssl >= 1:1.0.2

# Account for package name change
Obsoletes:	asterisk-ss
# Take into account this won't work with the original asterisk rpms
Conflicts:	asterisk

%description
Custom private rpm build of asterisk (includes bundled pjproject)
%prep
# http://rpm.org/max-rpm-snapshot/s1-rpm-inside-macros.html
# Add a -D below if you don't want rpmbuild to blow away the
# previous run
%setup -n asterisk-%{_version}%{_source_qualifier}

%build
contrib/scripts/install_prereq install
./bootstrap.sh
./configure  --libdir=/usr/lib64 --with-pjproject-bundled

# details on configuring options/modules
#https://wiki.asterisk.org/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Optionsa

# turned off build native as we ran into the same issue outlined below
# https://community.asterisk.org/t/asterisk-13-1-startup-failed-please-assist/48989
make menuselect.makeopts
menuselect/menuselect --disable BUILD_NATIVE --enable codec_opus menuselect.makeopts

make

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

# need to create these dirs, otherwise make config will fail
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d

make DESTDIR=$RPM_BUILD_ROOT install
make DESTDIR=$RPM_BUILD_ROOT config

# install auto log rotate scripts
make DESTDIR=$RPM_BUILD_ROOT install-logrotate

# useful for understanding the directories/files of asterisk
# http://www.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/asterisk-CHP-3-SECT-12.html
%files
%dir %attr(0755, asterisk, asterisk) "/etc/asterisk"
%attr(0755, root, root) "/etc/logrotate.d/asterisk"
%attr(0755, root, root) "/etc/rc.d/init.d/asterisk"
%attr(0644, root, root) "/etc/sysconfig/asterisk"

# We don't really need header files in binary dist
%exclude /usr/include/asterisk.h
%exclude /usr/include/asterisk

%attr(0755, root, root) "/usr/lib64/asterisk"
%attr(0755, root, root) "/usr/lib64/libasterisk*.*\.*"
# seems we can't specify attributes for linked files
/usr/lib64/libasterisk*.so
%attr(0755, root, root) "/usr/sbin/asterisk"
%attr(0755, root, root) "/usr/sbin/astcanary"
%attr(0755, root, root) "/usr/sbin/astdb2bdb"
%attr(0755, root, root) "/usr/sbin/astdb2sqlite3"
%attr(0755, root, root) "/usr/sbin/astgenkey"
%attr(0755, root, root) "/usr/sbin/astversion"
%attr(0755, root, root) "/usr/sbin/autosupport"
%attr(0755, root, root) "/usr/sbin/safe_asterisk"
# seems we can't specify attributes for linked files
/usr/sbin/rasterisk

%doc %attr(0644, root, root) "/usr/share/man/man8/*.gz"

# TODO - I think at least some of these have to
# be configuration files
%dir %attr(0755, asterisk, asterisk) /var/lib/asterisk
%dir %attr(0755, asterisk, asterisk) /var/lib/asterisk/agi-bin
%docdir %attr(0755, asterisk, asterisk) /var/lib/asterisk/documentation
%attr(0644, asterisk, asterisk) /var/lib/asterisk/documentation/*
%exclude /var/lib/asterisk/firmware
%dir %attr(0755, asterisk, asterisk) /var/lib/asterisk/images
%attr(0644, asterisk, asterisk) /var/lib/asterisk/images/*
%dir %attr(0755, asterisk, asterisk) /var/lib/asterisk/scripts
%attr(0755, asterisk, asterisk) /var/lib/asterisk/scripts/*
%exclude /var/lib/asterisk/scripts/*.pyc
%exclude /var/lib/asterisk/scripts/*.pyo
%dir %attr(0755, asterisk, asterisk) /var/lib/asterisk/rest-api
%attr(0644, asterisk, asterisk) /var/lib/asterisk/rest-api/*
%dir %attr(0755, asterisk, asterisk) /var/lib/asterisk/static-http
%attr(0644, asterisk, asterisk) /var/lib/asterisk/static-http/*

%defattr(0644, asterisk, asterisk, 0775)
/var/lib/asterisk/sounds
/var/lib/asterisk/moh
/var/spool/asterisk
/var/log/asterisk
/var/run/asterisk

%pre -p /bin/sh
/usr/sbin/groupadd -r asterisk -g 991 &>/dev/null || :
/usr/sbin/useradd  -r -s /sbin/nologin -u 600 -d /var/lib/asterisk -M \
                               -g asterisk -c 'Asterisk User' asterisk &>/dev/null || :
%post -p /bin/sh
if [ $1 -eq 1 ] ; then
	/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%preun -p /bin/sh
if [ "$1" -eq "0" ]; then
	# Package removal, not upgrade
	/bin/systemctl --no-reload disable asterisk.service > /dev/null 2>&1 || :
	/bin/systemctl stop asterisk.service > /dev/null 2>&1 || :
fi
%postun -p /bin/sh
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart asterisk.service >/dev/null 2>&1 || :
fi

the build is kicked off like so:

rpmbuild -ba ${target_dir}/SPECS/asterisk-ss.spec --define '_version 18.24.1' --define '_release 1'

Thanks.

I ran the above build instructions on a brand new centos7 instance (not a docker container) and then started up asterisk with my configuration and it worked as expected – codec_opus.so got loaded without complaining about not finding the documentation xml file.

Weird.

So, something is different between the rpm package I’m building up and the direct build from source. Nothing is obvious to me. I did a comparison of the before and after the install and the the files I install from the rpm are the same files that get installed from the direct build.

I’ll have to do more digging. Thanks for the tip.