-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(poetry): use sudo to install curl if running as user #119
base: master
Are you sure you want to change the base?
Conversation
If the UID is not 0 (root), uses sudo to install curl. Also checking if curl is already installed before trying to install it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, and thanks for finding this! Couple comments, but overall we'd be happy to accept this fix.
poetry/orb.yaml
Outdated
@@ -26,16 +26,24 @@ commands: | |||
type: string | |||
steps: | |||
- run: | |||
name: install curl | |||
name: Install curl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: leave this lowercase please, all our step names are.
apt-get update -qy | ||
apt-get install -qy curl | ||
if cat /etc/issue | grep "Alpine" >/dev/null 2>&1; then | ||
if [ "$ID" = 0 ]; then export SUDO=""; else export SUDO="sudo"; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression Alpine doesn't tend to ship with the sudo
binary, do you have a sample flow for how you tested this which I could play with?
I haven't ever really had opportunity to do this, but I have vague recollections about them using su-exec
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the default alpine doesn't ship with either, so in any case it needs to be installed beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is running alpine with ID!=0 just not possible, then, if you need to use non-default packages? Maybe we need to make that an error case? Or avoid setting this SUDO
value in that case? Just want to make sure we aren't breaking any cases which previously worked, here.
poetry/orb.yaml
Outdated
exit 1 | ||
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi | ||
fi | ||
echo "export SUDO=$SUDO" >> ${BASH_ENV} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this -- the SUDO
variable isn't used in any future steps here, so we can keep it contained into only this step rather than potentially affecting future tasks.
poetry/orb.yaml
Outdated
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi | ||
fi | ||
echo "export SUDO=$SUDO" >> ${BASH_ENV} | ||
if [ ! "$(command -v curl)" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this check to be the first line of this step: there's no need to do any work in this step if curl
is already installed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
Summary
If the UID is not 0 (root), uses sudo to install curl. Also checking if curl is already installed before trying to install it.
Standard Checklist