InterLinked1 / phreakscript

A utility to automate the installation, maintenance, and debugging of Asterisk/DAHDI, while integrating additional patches to provide the richest telephony experience
https://asterisk.phreaknet.org
Apache License 2.0
41 stars 15 forks source link

wanpipe install is broken on Debian #3

Closed InterLinked1 closed 1 year ago

InterLinked1 commented 2 years ago

Formally opening a bug for this: this was discussed via email about a month ago.

Wanpipe installation appears to be broken on Debian, but not Ubuntu. See unary operator expected warnings below:

        ----------------------------------------------------------
                  WANPIPE v7.0.34 Installation Script
            Copyright (c) 1995-2013, Sangoma Technologies Inc.
        ----------------------------------------------------------

Installing WANPIPE Device Drivers: Linux KERNEL

To integrate WANPIPE Multi-Protocol Voice & WAN Router
modules into the Linux kernel, the kernel has to be
updated with latest wanpipe sources.  Install will only
modify existing wanpipe source that is already in the
Kernel.

IMPORTANT:
It is always recommended to say YES to all options
prompted during the install!

        ----------------------------------------------------------
                  WANPIPE v7.0.34 Installation Script
            Copyright (c) 1995-2013, Sangoma Technologies Inc.
        ----------------------------------------------------------

Please specify absolute path name of your linux headers/source directory

Press Enter for Default: /lib/modules/5.10.0-12-amd64/build

#>Setting linux directory to /lib/modules/5.10.0-12-amd64/build

./Setup: line 1350: [: : integer expression expected
./Setup: line 1350: [: : integer expression expected
./Setup: line 1350: [: : integer expression expected
./Setup: line 1360: [: : integer expression expected
./Setup: line 1364: [: : integer expression expected
./Setup: line 1367: [: : integer expression expected

Upgrading WANPIPE kernel documentation ...Done.

Installing WANPIPE include headers ...
ERROR: Directory /lib/modules/5.10.0-12-amd64/build/include/linux not found!
       Corrupted linux headers in /lib/modules/5.10.0-12-amd64/build dir.

ERROR: Failed to upgrade WANPIPE device drivers!

Make sure that following directories exist:
        '/lib/modules/5.10.0-12-amd64/build/net/wanrouter'
        '/lib/modules/5.10.0-12-amd64/build/drivers/net'

Make sure that current kernel image version
matches the kernel version in /lib/modules/5.10.0-12-amd64/build !!!

        ----------------------------------------------------------
                  WANPIPE v7.0.34 Installation Script
            Copyright (c) 1995-2013, Sangoma Technologies Inc.
        ----------------------------------------------------------

WANPIPE KERNEL DRIVER COMPILATION

The next step in WANPIPE installation involves compiling
WANPIPE kernel modules.

This script will compile and install WANPIPE modules
into the currently running linux kernel.

For greater customization you will be prompted to
select which Protocol/Drivers you would like to
build into the WANPIPE kernel modules.

Wanpipe for Asterisk/Dahdi/Zaptel
        Default for Asterisk/Dahdi/Zaptel
Wanpipe for Wan Routing/API
        Default for Wan/IP Routing and Data API
Wanpipe for Asterisk SMG/SS7
        Default for Asterisk SS7
Wanpipe for TDM API
        Default for FreeSwitch and Voice API

Custom Compilation:
------------------
  Customise WANPIPE driver compilation to add only the
  protocols that you need.  This way one can reduce
  the size of the WANPIPE kernel drivers.

Refer to http://wiki.sangoma.com for more info
./Setup: line 1350: [: : integer expression expected
./Setup: line 1350: [: : integer expression expected
./Setup: line 1350: [: : integer expression expected
./Setup: line 1360: [: : integer expression expected
./Setup: line 1364: [: : integer expression expected
./Setup: line 1367: [: : integer expression expected

        ----------------------------------------------------------
                  WANPIPE v7.0.34 Installation Script
            Copyright (c) 1995-2013, Sangoma Technologies Inc.
        ----------------------------------------------------------

Checking for SMP support ...Enabled.

Checking current processor type ...x86_64

./Setup: line 2654: [: -eq: unary operator expected
ERROR: Unsupported Kernel Version 5.10.0-12-amd64
wanpipe install failed: unsupported kernel?
InterLinked1 commented 1 year ago

@brown1d

Adding some of your insights from email a few months ago here, so they don't get lost over time. I've also reported this to Sangoma, but I'd be very surprised if they even understand the issue, let alone do anything about it.

Took defaults for modules:

Press Enter for Default: /lib/modules/5.10.0-14-cloud-amd64/build

And yes it died at:

./Setup: line 1350: [: : integer expression expected

Now On Ubuntu you get these values get populated because the script reads from: /lib/modules/5.15.0-41-generic/build/Makefile as:

# SPDX-License-Identifier: GPL-2.0
VERSION = 5
PATCHLEVEL = 15
SUBLEVEL = 39
EXTRAVERSION =
NAME = Trick or Treat

Now on Debian that just contains:

[root@ip-10-0-0-135:/lib/modules/5.10.0-14-cloud-amd64/build#] more Makefile
include /usr/src/linux-headers-5.10.0-14-common/Makefile

And if you follow that link you find the variables:

# SPDX-License-Identifier: GPL-2.0
VERSION = 5
PATCHLEVEL = 10
SUBLEVEL = 113
EXTRAVERSION =
NAME = Dare mighty things

If you change the source directory to be: /usr/src/linux-headers-5.10.0-14-common

Then it magically works. Fix for this would be to make the shell script follow the include file, which we could do.

Ubuntu just uses a bunch of symbolic links to go from build to /usr/src/linux-headers-X, rather than using a Makefile include. Makefile include’s are a totally reasonable way of doing things, and certainly supported in GNU make. However the Wanpipe installer just tries to parse the variables out of the original Makefile, and does not follow includes. I tried to play last night to see if it was possible to build a Makefile that could be used to extract out only the variables but it does not seem to work right (i.e. use make as the parser, rather than rolling your own).

I see two ways to handle this:

  1. Detect Ubuntu vs Debian, and pass the correct source path. However that’s going to mean we then need to track future changes to either

  2. In Wanpipe installer handle includes, probably by using Recursion. The way the script file works it expects Makefiles to be called “Makefile” which is an assumption, and not unfair, but not always true…

I would go with option 2, as it could be rolled into a single wanpipe patch, and then we don’t have to worry what happens in the future.