Skip to content

Removing all lines containing #! or set -e (instead of lines that only begin with those) results in syntax errors if the postinst script relies on those characters #111

@toazd

Description

@toazd

Goto https://www.stepbible.org/downloads.jsp and download the "Linux (deb)". debtap -Q file.deb. Now, try to pacman -U file.zst and you will get errors in the output:


$ sudo pacman -U ./stepbible-26.1.2-1-any.pkg.tar.zst 
loading packages...
resolving dependencies...
looking for conflicting packages...

Package (1)  New Version  Net Change

stepbible    26.1.2-1     546.71 MiB

Total Installed Size:  546.71 MiB

:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                                                                  [--------------------------------------------------------] 100%
(1/1) checking package integrity                                                                [--------------------------------------------------------] 100%
(1/1) loading package files                                                                     [--------------------------------------------------------] 100%
(1/1) checking for file conflicts                                                               [--------------------------------------------------------] 100%
:: Processing package changes...
(1/1) installing stepbible                                                                      [--------------------------------------------------------] 100%
/tmp/alpm_Cb2l2v/.INSTALL: line 55: unexpected EOF while looking for matching `"'
/usr/bin/bash: line 1: post_install: command not found
error: command failed to execute correctly

Make sure you also pacman -Rns stepbible because it did not install correctly.

The source postinst script is as follows:

#!/bin/sh
I4J_INSTALL_LOCATION="/opt/step"
cd "$I4J_INSTALL_LOCATION"
if [ "$1" = "configure" ]; then
ln -sf "$I4J_INSTALL_LOCATION/step" /usr/local/bin/
/bin/echo -e "#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=STEP
Exec=/bin/sh \"$I4J_INSTALL_LOCATION/step\" %U
StartupWMClass=install4j-com-tyndalehouse-step-server-STEPTomcatServer
Icon=$I4J_INSTALL_LOCATION/.install4j/step.png
" > "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop"
xdg-desktop-menu install --mode system "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" 2>/dev/null
cp "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" "$I4J_INSTALL_LOCATION/step.desktop"
chmod +x "$I4J_INSTALL_LOCATION/step.desktop"

if [ -d "$I4J_INSTALL_LOCATION/jre/lib" ]; then
  old_pwd200=`pwd`
  cd "$I4J_INSTALL_LOCATION/jre"
  for pack_file in lib/*.jar.pack
  do
    if [ -f "$pack_file" ]; then
      jar_file=`echo "$pack_file" | awk '{ print substr($0,1,length($0)-5) }'`
      bin/unpack200 -r "$pack_file" "$jar_file" > /dev/null 2>&1
    fi
  done
  for pack_file in lib/ext/*.jar.pack
  do
    if [ -f "$pack_file" ]; then
      jar_file=`echo "$pack_file" | awk '{ print substr($0,1,length($0)-5) }'`
      bin/unpack200 -r "$pack_file" "$jar_file" > /dev/null 2>&1
    fi
  done
  bin/java -Xshare:dump >/dev/null 2>&1
  cd "$old_pwd200"
fi
sh /opt/step/post-install.sh
fi
exit 0

The .INSTALL that debtap creates is as follows:

post_install() {
	I4J_INSTALL_LOCATION="/opt/step"
	cd "$I4J_INSTALL_LOCATION"
	if [ "$1" = "configure" ]; then
	ln -sf "$I4J_INSTALL_LOCATION/step" /usr/bin/
	[Desktop Entry]
	Type=Application
	Name=STEP
	Exec=/usr/bin/sh \"$I4J_INSTALL_LOCATION/step\" %U
	StartupWMClass=install4j-com-tyndalehouse-step-server-STEPTomcatServer
	Icon=$I4J_INSTALL_LOCATION/.install4j/step.png
	" > "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop"
	xdg-desktop-menu install --mode system "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" 2>/dev/null
	cp "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" "$I4J_INSTALL_LOCATION/step.desktop"
	chmod +x "$I4J_INSTALL_LOCATION/step.desktop"

	if [ -d "$I4J_INSTALL_LOCATION/jre/lib" ]; then
	  old_pwd200=`pwd`
	  cd "$I4J_INSTALL_LOCATION/jre"
	  for pack_file in lib/*.jar.pack
	  do
	    if [ -f "$pack_file" ]; then
	      jar_file=`echo "$pack_file" | awk '{ print substr($0,1,length($0)-5) }'`
	      bin/unpack200 -r "$pack_file" "$jar_file" > /dev/null 2>&1
	    fi
	  done
	  for pack_file in lib/ext/*.jar.pack
	  do
	    if [ -f "$pack_file" ]; then
	      jar_file=`echo "$pack_file" | awk '{ print substr($0,1,length($0)-5) }'`
	      bin/unpack200 -r "$pack_file" "$jar_file" > /dev/null 2>&1
	    fi
	  done
	  bin/java -Xshare:dump >/dev/null 2>&1
	  cd "$old_pwd200"
	fi
	sh /opt/step/post-install.sh
	fi
}

post_upgrade() {
	post_install
}

pre_remove() {
	I4J_INSTALL_LOCATION="/opt/step"
	cd "$I4J_INSTALL_LOCATION"
	if [ "$1" = "upgrade" ] || [ "$1" = "remove" ]; then


	rm "/usr/bin/step" 2>/dev/null
	xdg-desktop-menu uninstall --mode system "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" 2>/dev/null
	rm "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop"
	rm "$I4J_INSTALL_LOCATION/step.desktop"
	rm -Rf "$I4J_INSTALL_LOCATION/jre/lib"
	fi
}

According to GTP-5.3 the problem is:

Root cause: the filter used during maintainer-script parsing removed any line containing #! anywhere, not just real shebang lines. In your sample, that deleted this embedded line inside an echo string:

#!/usr/bin/env xdg-open

That removed the opening quote context and produced the .INSTALL syntax error (unexpected EOF while looking for matching '"').

And the fix is (only remove #! and set -e lines when the tokens appear at the start of a line):

--- a/debtap_fix
+++ b/debtap_fix
@@ -3078,7 +3078,7 @@
-	grep -iv '#!\|set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrms\|--slave\|remove_source\|update_manager\|lintian' preinst | while read -r line; do
+	grep -iv '^[[:blank:]]*#!\|^[[:blank:]]*set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrms\|--slave\|remove_source\|update_manager\|lintian' preinst | while read -r line; do
@@ -3101,7 +3101,7 @@
-	grep -iv '#!\|set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrm\|--slave\|remove_source\|update_manager\|lintian' postinst | while read -r line; do
+	grep -iv '^[[:blank:]]*#!\|^[[:blank:]]*set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrm\|--slave\|remove_source\|update_manager\|lintian' postinst | while read -r line; do
@@ -3134,7 +3134,7 @@
-	grep -iv '#!\|set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrms\|--slave\|remove_source\|update_manager\|lintian' prerm | while read -r line; do
+	grep -iv '^[[:blank:]]*#!\|^[[:blank:]]*set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrms\|--slave\|remove_source\|update_manager\|lintian' prerm | while read -r line; do
@@ -3157,7 +3157,7 @@
-	grep -iv '#!\|set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrms\|--slave\|remove_source\|update_manager\|lintian' postrm | while read -r line; do
+	grep -iv '^[[:blank:]]*#!\|^[[:blank:]]*set -e\|automatically\|added\|generated\|apt \|apt-get \|aptitude \|debian-policy\|debconf\|dh_installdeb\|debhelper\|preinst\|postinst\|prerm\|postrms\|--slave\|remove_source\|update_manager\|lintian' postrm | while read -r line; do

Testing after the fix produces a working .INSTALL file:

post_install() {
	I4J_INSTALL_LOCATION="/opt/step"
	cd "$I4J_INSTALL_LOCATION"
	if [ "$1" = "configure" ]; then
	ln -sf "$I4J_INSTALL_LOCATION/step" /usr/bin/
	/bin/echo -e "#!/usr/bin/env xdg-open
	[Desktop Entry]
	Type=Application
	Name=STEP
	Exec=/usr/bin/sh \"$I4J_INSTALL_LOCATION/step\" %U
	StartupWMClass=install4j-com-tyndalehouse-step-server-STEPTomcatServer
	Icon=$I4J_INSTALL_LOCATION/.install4j/step.png
	" > "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop"
	xdg-desktop-menu install --mode system "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" 2>/dev/null
	cp "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" "$I4J_INSTALL_LOCATION/step.desktop"
	chmod +x "$I4J_INSTALL_LOCATION/step.desktop"

	if [ -d "$I4J_INSTALL_LOCATION/jre/lib" ]; then
	  old_pwd200=`pwd`
	  cd "$I4J_INSTALL_LOCATION/jre"
	  for pack_file in lib/*.jar.pack
	  do
	    if [ -f "$pack_file" ]; then
	      jar_file=`echo "$pack_file" | awk '{ print substr($0,1,length($0)-5) }'`
	      bin/unpack200 -r "$pack_file" "$jar_file" > /dev/null 2>&1
	    fi
	  done
	  for pack_file in lib/ext/*.jar.pack
	  do
	    if [ -f "$pack_file" ]; then
	      jar_file=`echo "$pack_file" | awk '{ print substr($0,1,length($0)-5) }'`
	      bin/unpack200 -r "$pack_file" "$jar_file" > /dev/null 2>&1
	    fi
	  done
	  bin/java -Xshare:dump >/dev/null 2>&1
	  cd "$old_pwd200"
	fi
	sh /opt/step/post-install.sh
	fi
}

post_upgrade() {
	post_install
}

pre_remove() {
	I4J_INSTALL_LOCATION="/opt/step"
	cd "$I4J_INSTALL_LOCATION"
	if [ "$1" = "upgrade" ] || [ "$1" = "remove" ]; then


	rm "/usr/bin/step" 2>/dev/null
	xdg-desktop-menu uninstall --mode system "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop" 2>/dev/null
	rm "$I4J_INSTALL_LOCATION/.install4j/install4j_1udpy2q-step.desktop"
	rm "$I4J_INSTALL_LOCATION/step.desktop"
	rm -Rf "$I4J_INSTALL_LOCATION/jre/lib"
	fi
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions