[Home]

Summary:ASTERISK-27606: BuildSystem: declare -A assumes shell Bash.
Reporter:Alexander Traud (traud)Labels:
Date Opened:2018-01-22 03:12:11.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Core/BuildSystem
Versions:13.19.0 15.2.0 Frequency of
Occurrence
Related
Issues:
is related toASTERISK-27593 [patch] BuildSystem: In OpenBSD, xmlstarlet is xml.
Environment:OpenBSD 6.2 FreeBSD 11.1Attachments:
Description:Makefiles specify which shell they are going to start in the environment. That shell then executes the commands within the Makefile. Normally, this shell is _sh_, which is the default shell of the platform. Some scripts within Asterisk require the specific shell _bash_, for example the script {{./build_tools/download_externals}}. In that case, the header of the that script declares a shift to _bash_.

However, {{./Makefile.moddir_rules}} uses {{declare -A}}. The parameter A is not available in all shells, for example this fails in the latest OpenBSD 6.2 and FreeBSD 11.1. That part of the script is guarded by a check for the shell _bash_. However, when {{declare -A}} is executed, the default shell has not shifted to _bash_ yet. Therefore {{declare -A}} fails.

In case of OpenBSD, Asterisk continues with {{gmake install}} and simply does not install any external module. In FreeBSD, {{gmake install}} fails, one has to uninstall _bash_ via {{pkg delete bash}} as root.

*Steps to reproduce*, for example in FreeBSD 11.1
# pkg install gmake
# pkg install libedit jansson e2fsprogs-libuuid sqlite3 libxml2
# fetch --no-verify-peer http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
# tar \-zxf asterisk\-*
# cd asterisk-*
# ./configure --without-pjproject-bundled
# gmake
# gmake install
Comments:By: Alexander Traud (traud) 2018-01-22 04:07:17.903-0600

ASTERISK-27593 revealed this issue but is not the cause because the fix for that was correct.

By: George Joseph (gjoseph) 2018-01-22 06:58:10.793-0600

Alexander, are you going to work this one?


By: Alexander Traud (traud) 2018-01-22 08:32:50.075-0600

I looked into it but failed and have no idea left currently. My first idea was to to do {{bash -c 'declare -A …'}}. However, I am not sure how to put the rest of the commands into the same shell. The next idea would be to use {{bash -c 'declare -Ag …'}} to create not local but global variables. Another idea was to replace the whole code. To be honest, I do not understand how it works, yet. For some reason that array is always empty for me. So, if you
A) take over or
B) just an starting point which I could go for/test,
that would be more than welcome.