PackageMaker's “Result Script” requirement never fails

I am trying to use the “Result from Script” requirement to check if a particular process is running so that I can tell the user before starting the installation. My script is a shell script that returns 1 for failure and 0 for success. The problem I am facing is that regardless of my return value, the installer thread interprets it as a failure. I do not use an incredibly simple script:

#!/bin/bash
echo "script starting">> /tmp/myfile
true

(the echo must assure itself that the script is essentially working). I tried to replace the last line with a lot of things (output 0, output 1, "true", "TRUE"), but nothing leads to passing the test.

I also discovered the following JavaScript code that is added to the .dist distribution when I activate this requirement.

<installation-check script="pm_install_check();"/>
<script>function pm_install_check() {
    if(!(system.run('path/to/script/myscript.sh') == true)) {
        my.result.title = 'Title';
        my.result.message = 'Message';
        my.result.type = 'Fatal';
        return false;
    }
    return true;
}
</script>

As far as I can tell, the expression in the if statement will never evaluate to true. So, I guess this is my problem. However, I do not know how to get around this because this code is generated by PackageMaker.


Update

I decided to work under the impression that this is a mistake in PackageMaker, and I am close to a workaround. Instead of using the “Result for Script” requirement, I used the “Result for Javascript” requirement and built a Javascript function that looks like

function my_check() {
    code = system.run('path/to/script/myscript.sh');
    return code == 0;
}

Now my only problem is that this will only work when I point to my script through an absolute path. Obviously, this creates a problem for the installer.

+3
source
2

, , , - .

, . , bash , script, script. :

, exit 0 ( ), $(exit 1).

, exit 1 $(exit 0).

, , , , , .

+7

, , . , Packages, " Script" . , 10.5 . 10.4, PackageMaker, " Script".

+2

All Articles