helixarch / debtap

A script for converting .deb packages into Arch Linux packages, focused on accuracy
GNU General Public License v2.0
1.35k stars 78 forks source link

Error converting multiline `if` statement in after_install script #68

Closed v0lk3r closed 2 years ago

v0lk3r commented 3 years ago

I am trying to debtap the perimeter81 client. However the resulting after_install script (in .INSTALL) contains a syntax error. After inspection of the source .deb file I see that the following source snippet:

if [ "${1}" = "configure" -a -z "${2}" ] || \
   [ "${1}" = "abort-remove" ]
then
    # "after install" here
    # "abort-remove" happens when the pre-removal script failed.
    #   In that case, this script, which should be idemptoent, is run
    #   to ensure a clean roll-back of the removal.
    after_install
elif [ "${1}" = "configure" -a -n "${2}" ]
then
    upgradeFromVersion="${2}"
    # "after upgrade" here
    # NOTE: This slot is also used when deb packages are removed,
    # but their config files aren't, but a newer version of the
    # package is installed later, called "Config-Files" state.
    # basically, that still looks a _lot_ like an upgrade to me.
    after_upgrade "${2}"
elif echo "${1}" | grep -E -q "(abort|fail)"
then
    echo "Failed to install before the post-installation script was run." >&2
    exit 1
fi

is transformed into this:

    if [ "${1}" = "configure" -a -z "${2}" ] || \
    then
        # "after install" here
        #   In that case, this script, which should be idemptoent, is run
        #   to ensure a clean roll-back of the removal.
        after_install
    elif [ "${1}" = "configure" -a -n "${2}" ]
    then
        upgradeFromVersion="${2}"
        # "after upgrade" here
        # NOTE: This slot is also used when deb packages are removed,
        # but their config files aren't, but a newer version of the
        # package is installed later, called "Config-Files" state.
        # basically, that still looks a _lot_ like an upgrade to me.
        after_upgrade "${2}"
    then
        echo "Failed to install before the post-installation script was run." >&2
        exit 1
    fi
helixarch commented 2 years ago

Fixed in 3.5.0