Score:1

Converting RPM packages for debian fails "due to shell metacharacters"

in flag

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.

Score:2
cl flag
A.B

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.

Score:0
us flag

After spending way too much time trying to workaround the above problems, realized there is an

rpm package that can be installed

Then just ran:
rpm -i MegaRAID_Storage_Manager-17.05.06-00.noarch.rpm --nodeps
/etc/init.d/vivaldiframeworkd start

It seems to be working, I got two messages in the system log, at least:

Jan 10 21:03:21 Xba MR_MONITOR[214454]: <MRMON044> Controller ID:  0   Time established since power on:   Time   2023-01-08, 05:11:32      33  Seconds
Jan 10 21:03:51 Xba MR_MONITOR[214454]: <MRMON044> Controller ID:  0   Time established since power on:   Time   2023-01-10, 21:03:51      255169  Seconds

Now need to install xterm and xpra so I can try running su -c /usr/local/MegaRAID Storage Manager/startupui.sh... is that what you all do too?

Well, I couldn't get it started with the latest java 17 installed, so I installed java 11 and had a bit more success... You'll want to add the following to /etc/init.d/msm_profile:

JRE_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
export JRE_HOME

The MSM window would open but then the X session would terminate as soon as I logged in ... it could be problems on my end with my GTK libraries or something.  I'll try and get more logs later.  I tried giving it the old java 8 version too, from Adoptium.  In that case I used:

JRE_HOME="/usr/lib/jvm/jdk8u352-b08-jre"
export JRE_HOME

but it hasn't helped.  Now when I run startupui.sh I'm just seeing a black window, have tried restarting the vivaldi framework too (actually that's required anytime you change the java version since it uses /etc/init.d/msm_profile to start up).

Hopefully you have better luck than I, let us know how it goes!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.