wilas / vbkick

Tool for building and maintaining VirtualBox VMs described as a code in a single definition file.
Other
8 stars 5 forks source link

Make shebang line path agnostic #1

Closed alanpearce closed 11 years ago

alanpearce commented 11 years ago

This is needed to run the script on systems where bash is not at /bin/bash, such as FreeBSD.

wilas commented 11 years ago

Thanks @alanpearce for the PR.

I agree that vbkick should support systems where bash is not at /bin/bash, but use /usr/bin/env bash not solves all problems. It only moves the location of the problem to different place.

  1. /usr/bin/env
    • the env utility must be located in /usr/bin/ (It's much more likely to be there than bash but still not specified in POSIX)
    • the bash/python binary must be located in $PATH (use first interpreter executable from user's $PATH, what mean that the script/program could behave diffrently depending who runs it - consider what may happen when someone has $HOME/bin/bash in first place in $PATH)
    • an package (.rpm, .dep, etc.) - if you preparing package for specific OS then location of all interpreters is known, use the hard coded path guarantee the package to work regardless if there is a different version of Python/Bash installed somewhere in the user's $PATH (here is a good topic)
    • more portable but it reduces control, it maybe be root of the problem which is difficult to oversee or analyze
  2. /bin/bash
    • add proper symlink to system which link Bash/Python to needed location e.g. ln -s /usr/local/bin/bash /bin/bash (people are lazy [a tool should be user friendly] + dealing with multiple symlinks may introduce some vulnerabilities and slow down kickstarting process on the new box)
    • the script shouldn't expect to find Bash/Python in hard coded path (e.g. /bin) if the system does not provide this
    • ensure that script is run with the version I have tested and developed it with

MAIN

There is different way to deal with portability - installation routine. The installer should take care about different OS and allow user's specify/choose shebang and install location. vbkick and convert_2_scancode.py need to be auto-generated on-site using Makefile with the proper (defined by user) head line. It gives the biggest control, flexibility and portability.

I will create separate issue to address the installer (Makefile) changes.

To be consistent head line in convert_2_scancode.py will be updated as well from #!/usr/bin/env python to #!/usr/bin/python.

PS. Did you use vbkick on FreeBSD ?

wilas commented 11 years ago

Close as #2 will be implemented.

alanpearce commented 11 years ago

I did try to use it on FreeBSD, but I ran into some other issues. I couldn't run it on Mac OSX either. Worked fine on Arch GNU/Linux, however.

wilas commented 11 years ago

@alanpearce thanks for a feedback. Feel free to create another gh issues with some error output about your FreeBSD and Mac OSX problems. We can try solve it.