1

I am trying to convert the "MegaRAID Storage Manager" RPM packages to debian dep packages. I'm using the alien package therefor as explained here:

https://hosting-tutorials.co.uk/tutorials/linux/installing-megaraid-storage-manager-on-debian

This is the package I try to convert: https://docs.broadcom.com/docs-and-downloads/17.05.06.00_MSM_Linux-x64.zip

The package "lib-utils2_1.00-12_all" converts fine to .deb but the "MegaRAID_Storage_Manager-17.05.06-00.noarch.rpm" not:

# alien --scripts *.rpm
lib-utils2_1.00-12_all.deb generated

Package build failed. Here's the log:
dh binary
   dh_update_autotools_config
   dh_autoreconf
   create-stamp debian/debhelper-build-stamp
   dh_testroot
   dh_prep
   debian/rules override_dh_auto_install
make[1]: Entering directory '/root/MSM/disk/MegaRAID_Storage_Manager-17.05.06'
mkdir -p debian/megaraid-storage-manager
# Copy the packages's files.
find . -maxdepth 1 -mindepth 1 -not -name debian -print0 | \
        sed -e s#'./'##g | \
        xargs -0 -r -i cp -a ./{} debian/megaraid-storage-manager/{}
make[1]: Leaving directory '/root/MSM/disk/MegaRAID_Storage_Manager-17.05.06'
   dh_installdocs
   dh_installchangelogs
   dh_perl
   dh_usrlocal
dh_usrlocal: error: Cannot generate a correct shell script for /usr/local/MegaRAID Storage Manager due to shell metacharacters
make: *** [debian/rules:7: binary] Error 25

I don't know how to fix the error "Cannot generate a correct shell script for /usr/local/MegaRAID Storage Manager due to shell metacharacters" and will be appreciate for any help.

The hosts I tried are Debian 10 and Debian 11, all amd64 arch and running the "bash" shell. I also tried the "sh" shell.

cmks
  • 161
  • 5

2 Answers2

2

TL;DR: spaces and other metacharacters are not supported for directories that will land in /usr/local.

/usr/local/MegaRAID Storage Manager contains spaces. Obviously this package doesn't follow good practices in the *nix world (blame LSI/Broadcom).

You could instead alien-convert to a tar or extract directly using rpm2cpio, figure out how install scripts are used and fit to see how to reuse them, optionally see if it's possible to rename the directory with spaces if any reference to it can be easily replaced too, and build directly a binary package using dpkg-deb -b which won't be affected by such problem, but will have created a package which doesn't comply with Debian policy.

explanations below...


The Debian policy mandates that nothing should be installed by a package in /usr/local except some directories by an indirect method:

9.1.2. Site-specific programs

As mandated by the FHS, packages must not place any files in /usr/local, either by putting them in the file system archive to be unpacked by dpkg or by manipulating them in their maintainer scripts.

However, the package may create empty directories below /usr/local so that the system administrator knows where to place site-specific files. These are not directories in /usr/local, but are children of directories in /usr/local. These directories (/usr/local/*/dir/) should be removed on package removal if they are empty.

Note that this applies only to directories below /usr/local, not in /usr/local.

[...]

So this package can't be compliant anyway, for example the file /usr/local/MegaRAID Storage Manager/startmonitorhelp.sh is not compliant: it's a file packaged somewhere in /usr/local.

alien uses the dh_usrlocal build helper to automatically convert (still compliant) directories for addition in maintainer scripts (ie on Debian preinst, postinst etc. scripts that are archived separately in the .deb ar archive and will be stored in /var/lib/dpkg/info/ later) which will then perform a few mkdir commands on installation:

dh_usrlocal is a debhelper program that can be used for building packages that will provide a subdirectory in /usr/local when installed.

It finds subdirectories of usr/local in the package build directory, and removes them, replacing them with maintainer script snippets (unless -n is used) to create the directories at install time, and remove them when the package is removed, in a manner compliant with Debian policy. These snippets are inserted into the maintainer scripts by dh_installdeb.

The content of the /usr/bin/dh_usrlocal perl script includes:

          # Detect some obvious cases of "this will not end
          # well".  We rely on what "while read dir ... ; do"
          # can handle for correctness.
          if ($fn =~ m{[\s!'"\$()*#;<>?@\[\]\\`|]}) {
                  error("Cannot generate a correct shell script for $fn due to shell metacharacters");
          }

\s which means any space in PCRE is part of the forbidden metacharacters and triggers the error when parsing /usr/local/MegaRAID Storage Manager.

A.B
  • 9,037
  • 2
  • 19
  • 37
0

Have you found any solution or workaround? I'm struggling with MSM for some days without any chance to have remote configuration enabled in Debian11.