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

tools: add custom private key option for release.sh #14401

Closed
wants to merge 1 commit into from

Conversation

krydos
Copy link
Contributor

@krydos krydos commented Jul 20, 2017

Hi,
I just noticed issue here - #14378 and tried to solve it.
So I've added -i option for release.sh that allows user to specify non-default private key for ssh and scp commands.

I've tested script manually with some debug echo statements since I'm not sure we have any tests for our tools (or idk about them).

One more thing is shift $((OPTIND-1)) right after while loop. It's important to save variable such as $1, $2 etc, that are used in the script. So these variables should not be broken.

If anyone could help me to test this script it would be great :)

Checklist
Affected core subsystem(s)

tools

@nodejs-github-bot nodejs-github-bot added the tools Issues and PRs related to the tools directory. label Jul 20, 2017
@Fishrock123
Copy link
Contributor

Oh nice! Thanks!

As I said I'm not this familiar with bash but I can certainly try using this for 8.2.1 (#14399).

@Fishrock123
Copy link
Contributor

I think the main thing would be to ensure this works with -s, which uses a much more rudimentary flag detection mechanism.

@krydos
Copy link
Contributor Author

krydos commented Jul 20, 2017

ah, didn't notice -s there... I hope it works because of shift $((OPTIND-1)) but I'm not sure.
If no one will against getopts I guess it would be nice to rewrite -s flag to the way how -i works

@Fishrock123
Copy link
Contributor

So, I used this for 8.2.1 and it worked just fine! 😄

(I did not need to use -s though.)

@rvagg
Copy link
Member

rvagg commented Jul 20, 2017

Nice work @krydos! It'd be nice to do -s in the same way but that's not a big deal. I'll review and test shortly and be back with feedback.

@rvagg
Copy link
Member

rvagg commented Jul 21, 2017

-s doesn't work anymore with this, it gets chopped off completely. I guess because it's technically an option and getopts includes it in OPTIND even though it's not handled by the case

so could you try pulling the -s up into the getopts handling? it always needs a version number argument.

@krydos
Copy link
Contributor Author

krydos commented Jul 21, 2017

Sure, I'll try to convert -s option to getopts as soon as possible

@krydos krydos force-pushed the custom-ssh-key-for-release-sh branch from c0b8c45 to 3648684 Compare July 21, 2017 11:08
@krydos
Copy link
Contributor Author

krydos commented Jul 21, 2017

I've changed how -s is parsed. It took too much time to find a way how to show custom message when option is passed but argument for this option is not... And didn't find solution yet :(

Previously in case nothing is passed to -s option you could see message Please supply a version string to sign. Now you will see this one ./release.sh: option requires an argument -- s (default one produced by getopts). If it's ok then great, if not I will try to come up with something else.

And again, I tried to debug it with multiple echo statements but I was unable to debug if script in a whole works correctly or not.
If someone could test it, it would sooo great.
I hope I didn't break anything 😟

jasnell
jasnell previously approved these changes Jul 21, 2017
@Fishrock123
Copy link
Contributor

Hmm, the script doesn't actually seem to run now? All variants with valid options just seem to return from the script without doing anything. :/

@krydos krydos force-pushed the custom-ssh-key-for-release-sh branch from 3648684 to 8f6897f Compare July 24, 2017 19:39
@krydos
Copy link
Contributor Author

krydos commented Jul 24, 2017

ah, excuse me, I didn't really get the purpose of $OPTERR and used it wrongly.
Should be working from now.

@jasnell jasnell dismissed their stale review July 25, 2017 14:57

Will re-review

Copy link
Contributor

@Fishrock123 Fishrock123 left a comment

Choose a reason for hiding this comment

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

I promoted the armv6 binaries for 8.2.1 with the latest version of this.

Both -i and -s worked just fine. I wasn't able to test without -i though.

@Fishrock123
Copy link
Contributor

@rvagg @jasnell could ya'll re-review?

@Fishrock123
Copy link
Contributor

@nodejs/build & @jasnell can someone with bash knowledge please review / sign off on this?

tools/release.sh Outdated
signversion="${OPTARG}"
;;
\?)
exit 1
Copy link
Member

Choose a reason for hiding this comment

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

If you want a nicer error message you can do this:

diff --git a/tools/release.sh b/tools/release.sh
index 4225be4cc7..fcb5ef1242 100755
--- a/tools/release.sh
+++ b/tools/release.sh
@@ -16,7 +16,7 @@ signcmd=dist-sign
 customsshkey="" # let ssh and scp use default key
 signversion=""
 
-while getopts "i:s:" option; do
+while getopts ":i:s:" option; do
     case "${option}" in
         i)
             customsshkey="-i ${OPTARG}"
@@ -25,6 +25,11 @@ while getopts "i:s:" option; do
             signversion="${OPTARG}"
             ;;
         \?)
+            echo "Invalid option -$OPTARG."
+            exit 1
+            ;;
+        :)
+            echo "Option -$OPTARG takes a parameter."
             exit 1
             ;;
     esac

up to you whether it's worth it though.

@gibfahn
Copy link
Member

gibfahn commented Aug 14, 2017

Both -i and -s worked just fine. I wasn't able to test without -i though.

@Fishrock123 FWIW you can add the IdentityFile option to the ~/.ssh/config entry for direct.nodejs.org, something like this should work (then you could test without the -i):

Host direct.nodejs.org
     User dist
     IdentityFile ~/.ssh/custom_id_rsa

Copy link
Member

@gibfahn gibfahn left a comment

Choose a reason for hiding this comment

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

Looks fine with or without the proposed fix.

@krydos krydos force-pushed the custom-ssh-key-for-release-sh branch from 8f6897f to f24235b Compare August 18, 2017 06:56
@krydos
Copy link
Contributor Author

krydos commented Aug 18, 2017

@gibfahn thank you for the help. I didn't know that colon at the beginning of the arguments definition switch getopts to silent error reporting mode. Very cool!

Add -i option for release.sh that allows
user to specify non-default private key
for ssh and scp commands.
Change argument parsing to getopts.
@krydos krydos force-pushed the custom-ssh-key-for-release-sh branch from f24235b to 688d22e Compare August 18, 2017 07:08
@BridgeAR
Copy link
Member

Landed in 237a42d

@BridgeAR BridgeAR closed this Aug 27, 2017
BridgeAR pushed a commit that referenced this pull request Aug 27, 2017
Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: #14401
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: nodejs/node#14401
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: nodejs/node#14401
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: #14401
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: #14401
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 20, 2017
Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: #14401
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants