autopkg / apizz-recipes

MIT License
14 stars 23 forks source link

Issue running bash executables with ExecutableFileVersioner.py #95

Closed fishd72 closed 6 months ago

fishd72 commented 6 months ago

I was just packaging the wiz cli security tools (a large single binary) and needed to grab the version number by executing the downloaded binary along with a "version" parameter... however, setting the interpreter for this processor to '/bin/sh' or '/bin/zsh' would result in non-zero exit codes and the recipe failing.

I found if I added the the following, I could get it working:

I first added a new input variable: "interpreter_argument": { "required": False, "description": ( "Argument passed to the interpreter for execution " "file, if needed. " ), },

Then I added this into the main code so it looked like this: cmd = subprocess.check_output([ self.env['interpreter_path'], self.env['interpreter_argument'], self.env['found_filename'], self.env['version_argument']])

This now allows me to set the interpreter_path to /bin/sh and the interpreter_argument to -c and it will execute my binary successfully.

I've currently created my own custom processor for this in my repo, as I wasn't sure if these changes would break your workflow... but happy to submit a PR if you'd like to include this or keen to hear if you've a better idea.

fishd72 commented 6 months ago

Ok, so seems I spoke too soon... for some reason this works on the device that I tend to build my recipes on... but when transferred to the Mac that runs the AutoPkg jobs, it failed.

My python is not great, both Macs are running the same versions of macOS and AutoPkg...

As a quick fix, I removed the references to interpreters and switched the main execution from subprocess.check_output to use subprocess.run instead, which is enough for my needs, but likely to break your workflows... so this issue can be ignored I think.