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

Switch to POSIX sh for deployment scripts. #5

Open
wants to merge 9 commits into
base: latest
Choose a base branch
from

Conversation

nuclearsandwich
Copy link
Contributor

There's got to be something in here about chickens coming home to roost. I generally write things in POSIX sh in order to make sure they continue to function correctly, but doing so in a bash world is a challenge and when we were first preparing this repository I decided I could relax this constraint and use bash in order to make contributing more accessible (also there's nothing as robust as the BASH_SOURCE environment variable in POSIX sh).

However, trying to use these scripts for the OSRF build farm's mac deployments reminded me that bash (and GNU userland utils) is still far from universal.

This option is unsupported in POSIX sh.
POSIX sh does not maintain the EUID variable.
This is not as robust as BASH_SOURCE but should work for our needs.
The suffix option to mktemp is a GNU extension to the standard. The main
advantage of the suffix is the syntax highlighting when reviewing the
script. We could drop it altogether.
These are not available in POSIX sh.
@nuclearsandwich nuclearsandwich requested a review from j-rivero April 6, 2023 14:26
@nuclearsandwich nuclearsandwich self-assigned this Apr 6, 2023

# Create a tempfile so the user has the opportunity to review the omnitruck script.
omnitruck_script="$(mktemp --suffix=.bash)"
omnitruck_script="$(mktemp)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
omnitruck_script="$(mktemp)"
omnitruck_script="$(mktemp XXXXXXXXXX.bash)"

and you can probably remove the line below. If you have interest into keeping the bash file into the current directory:

omnitruck_script="$(mktemp -p . XXXXXXXXXX.bash)"

but I think that for cleanness we can keep it the temp directory.

@@ -43,11 +45,12 @@ freshen_chef_repo() {
if [ ! -d chef_repo ]; then
git clone "$CHEF_REPO" -b "$CHEF_BRANCH" --recurse-submodules --remote-submodules chef_repo
else
pushd chef_repo
CURDIR="$(pwd)"
cd chef_repo
git fetch origin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, git -C chef_repo <rest-of-the-command> should work here to save some code lines, right?

Copy link
Contributor

@j-rivero j-rivero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, non of them important enough to block.

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

Successfully merging this pull request may close these issues.

2 participants