helixarch / debtap

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

Running against a deb creates zst however pacman running into syntax errors in .INSTALL with truncated/missing vars from original preinst file #75

Open ipaqmaster opened 2 years ago

ipaqmaster commented 2 years ago

Hi, using against SentinelAgent_linux_v22_1_2_7.deb to create a zst to install with however many lines contain truncated if or other entire function declarations missing sure why at a glance.

Examples below.

function seen in original preinst of deb file:

upgrade_custom_path() {
        custom_install_path="$1"
        if [ "${custom_install_path}" == "undefined" ]; then
                return
        fi

        if [ -h "$agent_directory" ]; then
                write_log_message "Upgraded agent already installed with custom install path, skipping." 1
                return
        fi

        shopt -s extglob
        stripped_install_path="${custom_install_path%%+(/)}"

        write_log_message "Upgrading agent and moving to '${stripped_install_path}'" 1

        base_dir="${stripped_install_path%/*}"

        if [ -d "${stripped_install_path}" ]; then
                if [ "$(ls -A "${stripped_install_path}")" != "" ]; then
                        write_log_message "ERROR: trying to upgrade to custom install path '${stripped_install_path}' but dest dir is not empty" 1
                        exit 101
                fi

                rmdir "${stripped_install_path}"
                assert "rmdir"
        else
                write_log_message "Creating '${base_dir}'" 1
                mkdir -p "$base_dir"
        fi

        assert_user_access "$user_name" "$base_dir"

        mv "$agent_directory" "${stripped_install_path}"
        if [ $? -ne 0 ]; then
                cp -rp "$agent_directory" "${stripped_install_path}"
                if [ $? -ne 0 ]; then
                        write_log_message "Copying agent dir to the '${stripped_install_path}' failed" 1
                        exit 101
                fi

                rm -rf "$agent_directory"
        fi

        ln -s "${stripped_install_path}" "$agent_directory"
        write_log_message "Symlink created from $agent_directory to ${stripped_install_path}"

        chown -h "${user_name}:${user_name}" "$agent_directory"

        echo "S1_AGENT_CUSTOM_INSTALL_PATH=$stripped_install_path" >> $installation_persistent_configuration
}

Resulting copy in .INSTALL after running with script (Causing bash scripting errors due to missing lines and other bits)

        {
                custom_install_path="$1"
                if [ "${custom_install_path}" == "undefined" ]; then
                        return
                fi

                if [ -h "$agent_directory" ]; then
                        write_log_message "Upgraded agent already installed with custom install path, skipping." 1
                        return
                fi

                shopt -s extglob
        }"

                write_log_message "Upgrading agent and moving to '${stripped_install_path}'" 1

                base_dir="${stripped_install_path%/*}"

                if [ -d "${stripped_install_path}" ]; then
        " != "" ]; then
                                write_log_message "ERROR: trying to upgrade to custom install path '${stripped_install_path}' but dest dir is not empty" 1
                                exit 101
                        fi

                        rmdir "${stripped_install_path}"
                        assert "rmdir"
                else
                        write_log_message "Creating '${base_dir}'" 1
                        mkdir -p "$base_dir"
                fi

                assert_user_access "$user_name" "$base_dir"

                mv "$agent_directory" "${stripped_install_path}"
                if [ $? -ne 0 ]; then
                        cp -rp "$agent_directory" "${stripped_install_path}"
                        if [ $? -ne 0 ]; then
                                write_log_message "Copying agent dir to the '${stripped_install_path}' failed" 1
                                exit 101
                        fi

                        rm -rf "$agent_directory"
                fi

                ln -s "${stripped_install_path}" "$agent_directory"
                write_log_message "Symlink created from $agent_directory to ${stripped_install_path}"

                chown -h "${user_name}:${user_name}" "$agent_directory"

                echo "S1_AGENT_CUSTOM_INSTALL_PATH=$stripped_install_path" >> $installation_persistent_configuration
        }

As visible, the function's declaration at the beginning seems to be truncated and some variables in those if statements are completely empty where if [ "$(ls -A "${stripped_install_path}")" != "" ]; then became " != "" ]; then. I am not entirely sure whether this is intended for creating zst files, or if something has gone wrong during the creation of the .INSTALL file (such as the if statement being truncated)

Please advise