-
Notifications
You must be signed in to change notification settings - Fork 511
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
New installer options #590
Conversation
This adds support for serveral new command line options (taken from the usage): "-b, --bin-dir" "Override the bin installation directory [default: ${_bin_dir}]" \ "-m, --man-dir" "Override the man installation directory [default: ${_man_dir}]" \ "-a, --arch" "Override the architecture identified by the installer [default: ${_arch}]" \ "-h, --help" "Display this help message" This also (coincidentally) allows for $BIN_DIR, $MAN_DIR, and $ARCH to be set to create default settings for these. These variables are *always* overwritten by the command line arguments. This diff is unusually large, as my formatter ([shfmt](https://github.com/mvdan/sh)) ran, reformatting the majority of the script. This also adds a few utilities to the script (`log`/`abort`) and modifies `err` to simply output to stderr. This allows for more fine grain control over script flow and output, without relying on `echo >&2`.
This avoids logging the message when `--help` is specified, and helps ensure the correct output if `--arch` is specified
The default is *not* programatically generated in the help menu, as we don't determine this until later. This is intentional, so we can validate the user's choice of command.
This resets the indention to 4 spaces, reducing the size of the final diff to just code changes and *minor* formatting differences, reducing the effect of indention.
…h multiple collaborators
SC3043 is the warning about lack of `local` definition in POSIX. This is a Dev Exp improvement, as it removes unneeded and unwanted warnings.
one known issue, which might be complicated to resolve, is that the use of |
This fixes a logic error, where `$_man_dir` is checked to ensure it exists, but not the `man1` subdirectory. It feels most reasonable to ensure the selected mandir exists, but not that the file structure of the directory is user-managed.
Additionally, if |
This stops the script from breaking if the user specified sudo command outputs to stdout
This helps ensure that mismatched permission on `_bin_dir` and `_man_dir` don't cause issues. Also prevents creating man pages owned by root being written to the user's $HOME
This ensures that mismatched permissions/ownership on `${_man_dir}` and `${_man_dir}/man1` don't cause the script to fail. *If* `${man_dir}/man1` already exists and is writable, OR `${_man_dir}/man1` *doesn't* yet exist, but `${_man_dir}` is writable, then the script continues without sudo. If `/man1` doesn't exist, and it's parent isn't writable, we need sudo. If `/man1` *does* exist, and it's not writable, we need sudo.
SUDO may not be set, if no parameter or environment variable is passed. This ensures that elevate_priv gets an empty string (as expected) in those cases
This was causing the script to always use sudo privilages if `/man1` already exists
*usually*, $PATH will *not* contain trailing slashes, while _bin_dir may or may not. This changes the case statement to test for `_bin_dir`, `_bin_dir/`, and `_bin_dir` without a trailing slash. This reduces false positives and unnecessary logs
The CI shellcheck linter requires brackets on variables, so this commit adds them
This prevents attempting to create files in `/` if a path is not given, instead failing early.
Thanks shfmt for pointing out these agressive simplifications that are possible, but not necisarily needed. Now can I pass CI? Please? 😄
They now suggest passing to `sh`, rather than `bash`, to match the shebang and reduce posibility that non-posix behaivor of `bash` affects the script.
This pattern *is* POSIX defined (see [here](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02)): ``` Guideline 10: The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character. ``` This ensures that odd values for _bin_name, _bin_dir, and others aren't treated as options to the command and cause a failure.
I have now tested all the options (and they work on my system), and I have fixed the above mentioned error about _man_dir and _bin_dir permission mismatches. @ajeetdsouza, Please take a look and let me know what you think. I would also appreciate if you could test these on your own system to avoid "it works on my machine" 😄 |
I'd recommend re-applying your changes without Generally speaking, It's very hard to review a PR if you bring in more than what you are suggesting adding to the project. One should keep the general coding style and formatting of the project you are contributing to. If you think what shfmt brings is great a nice improvement, you can add that as an issue and discuss it with the maintainer but not add it as part of your attempted contributed work. This PR is very unlikely to be even considered with such a huge diff. Same goes for:
Please don't take this in the wrong way, I know that your intentions are great and that you put time into all of these improvements, only sharing my experience with open source and the general expectation of the open source module maintainers. |
For what it worth, I am doing:
|
4a7505d
to
073500c
Compare
I am closing this issue in favor of the rewrite at #672, without the formatting. Sorry for the time wasted on this PR, hopefully the new one is much more reasonable. Note: I created a new PR instead of rebasing, because I rewrote it on a new branch, and the history is much neater with a new PR than with a bunch of force pushes / edits. |
This adds support for serveral new command line options (taken from the usage):
This also (coincidentally) allows for $BIN_DIR, $MAN_DIR, $ARCH, and $SUDO to be set to create default settings for these.
These variables are always overwritten by the command line arguments.
This diff is unusually large, as my formatter (shfmt) ran, reformatting the majority of the script.
This also adds a few utilities to the script (
log
/abort
) and modifieserr
to simply output to stderr.This allows for more fine grain control over script flow and output, without relying on
echo >&2
.Each commit should include descriptions regarding their necessity. If you don't understand something or just want some extra clarity, I'm happy to explain any of my choices.
NOTE:
These options are not yet fully tested. I am posting this here while I test on my own machine for the purposes of a second set of eyes, but this should not be merged until tested by at least two people 😄