Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue May 12, 2022 · 0 comments

Comments

@ipaqmaster
Copy link

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

@ipaqmaster ipaqmaster changed the title Runring against a deb however pacman running into syntax errors in .INSTALL with truncated/missing vars Running against a deb creates zst however pacman running into syntax errors in .INSTALL with truncated/missing vars from original preinst file May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant