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

powershell based install script #6691

Merged
merged 1 commit into from Jun 26, 2019

Conversation

@mwrock
Copy link
Contributor

commented Jun 26, 2019

Fixes #5437

This should work for all supported versions of windows (2008 R2 forward):

Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/habitat-sh/habitat/install_ps1/components/hab/install.ps1'))

Note that this also adjusts our CI to install hab from this script instead of chocolatey.

Signed-off-by: mwrock matt@mattwrock.com

@mwrock mwrock force-pushed the install_ps1 branch from 137ac6a to 21386ec Jun 26, 2019

@mwrock mwrock marked this pull request as ready for review Jun 26, 2019

@mwrock mwrock self-assigned this Jun 26, 2019

@@ -43,6 +43,13 @@ hr
= code(:powershell) do
| $ choco install habitat

h4.mt-2 Install Chef Habitat using a Powershell instal script

This comment has been minimized.

Copy link
@raskchanky

raskchanky Jun 26, 2019

Member

instal -> install

@raskchanky
Copy link
Member

left a comment

I don't know anything about Powershell so take my approval with the appropriately sized grain of salt, but I love that this moves CI off of a dependency on chocolatey. I found one minor typo that should be fixed but otherwise looks great.

@baumanj
Copy link
Member

left a comment

I can't really provide any useful feedback, but I'm glad this is happening!

@christophermaier
Copy link
Contributor

left a comment

Looks good, subject to the same Powershell expertise caveats that everyone else has :)

I have questions about the regex bits, though.

Powershell:
```
C:\> Set-ExecutionPolicy Bypass -Scope Process -Force
C:\> iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.ps1'))

This comment has been minimized.

Copy link
@christophermaier

christophermaier Jun 26, 2019

Contributor

"iex WebClient DownloadString" doesn't quite flow like "curlbash" does, but it's cool nevertheless 😆

This comment has been minimized.

Copy link
@mwrock

mwrock Jun 26, 2019

Author Contributor

there are somewhat better options like . { iwr https://raw.githubusercontent.com/habitat-sh/habitat/install_ps1/components/hab/install.ps1 } | iex but that won't work on older versions of PS (but most). I'm trying to capture our entire support base.

This comment has been minimized.

Copy link
@christophermaier

christophermaier Jun 26, 2019

Contributor

@mwrock I was totally being snarky, but I appreciate your explanation, as well as the thought given to users of older powershell installations ❤️

}
} else {
# No ConvertFrom-Json support so we must be on unpatched PSv2
if($version -match "^\d\.\d\d\.\d-\d\d\d\d\d\d\d\d\d\d\d\d\d\d`$") {

This comment has been minimized.

Copy link
@christophermaier

christophermaier Jun 26, 2019

Contributor

Is this matching a string like 0.75.0/20190219232208?

If so, this is probably too restrictive... nothing guarantees that our major version will only ever be one digit, or our minor version two digits and our patch one digit (in fact, as we move to "release with each merge", it's going to be fairly common to see triple-digit minor and patch versions).

Does Powershell regex have syntax for quantifying numbers of repetitions? Something like \d+\.\d+\.\d+/\d{12} would be much more readable, for instance.

Also, is this intending to match only something like 0.75.0/20190219232208, or should it also try to match 0.75.0, too?

This comment has been minimized.

Copy link
@mwrock

mwrock Jun 26, 2019

Author Contributor

ah good catch. your \d+\.\d+\.\d+/\d{12} works. Thanks!

This comment has been minimized.

Copy link
@mwrock

mwrock Jun 26, 2019

Author Contributor

the intent is to make sure it is fully qualified. If we cant parse the json file to find the actual release we are trusting the user is giving it to us.

This comment has been minimized.

Copy link
@baumanj

baumanj Jun 26, 2019

Member

That 12s gonna break in 7,981 years

This comment has been minimized.

Copy link
@christophermaier

christophermaier Jun 26, 2019

Contributor

The oft-overlooked Y10K problem...

@mwrock mwrock force-pushed the install_ps1 branch from 21386ec to 8d0632a Jun 26, 2019

powershell based install script
Signed-off-by: mwrock <matt@mattwrock.com>

@mwrock mwrock force-pushed the install_ps1 branch from 8d0632a to 9600af3 Jun 26, 2019

@mwrock mwrock merged commit 12fb32b into master Jun 26, 2019

5 checks passed

DCO This commit has a DCO Signed-off-by
Details
buildkite/habitat-sh-habitat-master-verify Build #2526 passed (55 minutes, 52 seconds)
Details
buildkite/habitat-sh-habitat-master-website Build #3052 passed (1 minute, 24 seconds)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
expeditor/config-validation Validated your Expeditor config file
Details

@mwrock mwrock deleted the install_ps1 branch Jun 26, 2019

chef-ci added a commit that referenced this pull request Jun 26, 2019

Update CHANGELOG.md with details from pull request #6691
Obvious fix; these changes are the result of automation not creative thinking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.