Skip to content

Commit 41a2743

Browse files
committed
Remove obsolete pre-installation hooks.
1 parent 82e06b4 commit 41a2743

File tree

9 files changed

+46
-104
lines changed

9 files changed

+46
-104
lines changed

src/main/bash/sdkman-install.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@ function __sdkman_download() {
128128
local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp"
129129
local headers_file="${metadata_folder}/${base_name}.headers"
130130

131-
# pre-installation hook: implements function __sdkman_pre_installation_hook
132-
local pre_installation_hook="${SDKMAN_DIR}/tmp/hook_pre_${candidate}_${version}.sh"
133-
__sdkman_echo_debug "Get pre-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}"
134-
__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" >| "$pre_installation_hook"
135-
__sdkman_echo_debug "Copy remote pre-installation hook: $pre_installation_hook"
136-
source "$pre_installation_hook"
137-
__sdkman_pre_installation_hook || return 1
138-
__sdkman_echo_debug "Completed pre-installation hook..."
139-
140131
export local binary_input="${SDKMAN_DIR}/tmp/${base_name}.bin"
141132
export local zip_output="${SDKMAN_DIR}/tmp/${base_name}.zip"
142133

src/test/groovy/sdkman/steps/stub_steps.groovy

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import static sdkman.support.FilesystemUtils.readVersionsCsvFromCandidateFolder
1212
And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String version ->
1313
primeEndpointWithString("/candidates/default/${candidate}", version)
1414
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform())
15-
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess())
1615
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess())
1716
}
1817

@@ -24,28 +23,24 @@ And(~'^an available selfupdate endpoint$') { ->
2423
And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version ->
2524
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.inferPlatform()}", "valid")
2625
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform())
27-
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess())
2826
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess())
2927
}
3028

3129
And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download with checksum "([^"]*)" using algorithm "([^"]*)"$') {
3230
String candidate, String version, String checksum, String algorithm ->
3331
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.inferPlatform()}", "valid")
3432
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform(), ["X-Sdkman-Checksum-${algorithm}": "${checksum}"])
35-
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess())
3633
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess())
3734
}
3835

39-
And(~/^the appropriate universal hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String os ->
36+
And(~/^the appropriate universal hook is available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String os ->
4037
String lcPlatform = UnixUtils.inferPlatform(os)
41-
primeUniversalHookFor("pre", candidate, version, lcPlatform)
42-
primeUniversalHookFor("post", candidate, version, lcPlatform)
38+
primeUniversalHookFor(candidate, version, lcPlatform)
4339
}
4440

45-
And(~/^the appropriate multi-platform hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String os, String architecture ->
41+
And(~/^the appropriate multi-platform hook is available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String os, String architecture ->
4642
String lcPlatform = UnixUtils.inferPlatform(os, architecture)
47-
primePlatformSpecificHookFor("pre", candidate, version, lcPlatform)
48-
primePlatformSpecificHookFor("post", candidate, version, lcPlatform)
43+
primePlatformSpecificHookFor(candidate, version, lcPlatform)
4944
}
5045

5146
And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version ->
@@ -58,14 +53,14 @@ And(~/^the candidate "(.*)" version "(.*)" is available for download on "(.*)" w
5853
primeDownloadFor(SERVICE_UP_URL, candidate, version, lcPlatform)
5954
}
6055

61-
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String phase, String candidate, String version, String os, String architecture ->
56+
And(~/^a post-installation hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String candidate, String version, String os, String architecture ->
6257
String lcPlatform = UnixUtils.inferPlatform(os, architecture)
63-
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookSuccess() : postInstallationHookSuccess())
58+
primeEndpointWithString("/hooks/post/${candidate}/${version}/${lcPlatform}", postInstallationHookSuccess())
6459
}
6560

66-
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String phase, String candidate, String version, String os, String architecture ->
61+
And(~/^a post-installation hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String candidate, String version, String os, String architecture ->
6762
String lcPlatform = UnixUtils.inferPlatform(os, architecture)
68-
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookFailure() : postInstallationHookFailure())
63+
primeEndpointWithString("/hooks/post/${candidate}/${version}/${lcPlatform}", postInstallationHookFailure())
6964
}
7065

7166
And(~/^the candidate "(.*?)" version "(.*?)" is not available for download on "(.*?)"$/) { String candidate, String version, String os ->

src/test/groovy/sdkman/stubs/HookResponses.groovy

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
11
package sdkman.stubs
22

33
class HookResponses {
4-
5-
static preInstallationHookSuccess() {
6-
'''\
7-
#!/usr/bin/env bash
8-
function __sdkman_pre_installation_hook {
9-
echo "Pre-installation hook success"
10-
return 0
11-
}
12-
'''
13-
}
14-
15-
static preInstallationHookFailure() {
16-
'''\
17-
#!/usr/bin/env bash
18-
function __sdkman_pre_installation_hook {
19-
echo "Pre-installation hook failure"
20-
return 1
21-
}
22-
'''
23-
}
24-
4+
255
static postInstallationHookSuccess() {
266
'''\
277
#!/usr/bin/env bash

src/test/groovy/sdkman/stubs/WebServiceStub.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ class WebServiceStub {
1212
.withBody(body)))
1313
}
1414

15-
static primeUniversalHookFor(String phase, String candidate, String version, String platform) {
16-
primeHookFor(phase, candidate, version, platform, true)
15+
static primeUniversalHookFor(String candidate, String version, String platform) {
16+
primeHookFor(candidate, version, platform, true)
1717
}
1818

19-
static primePlatformSpecificHookFor(String phase, String candidate, String version, String platform) {
20-
primeHookFor(phase, candidate, version, platform, false)
19+
static primePlatformSpecificHookFor(String candidate, String version, String platform) {
20+
primeHookFor(candidate, version, platform, false)
2121
}
2222

23-
private static primeHookFor(String phase, String candidate, String version, String platform, boolean universal = true) {
24-
def hookFile = "hooks/${phase}_hook_${candidate}_${version}_${universal ? 'universal' : platform}.sh"
25-
stubFor(get(urlEqualTo("/hooks/$phase/$candidate/$version/$platform")).willReturn(
23+
private static primeHookFor(String candidate, String version, String platform, boolean universal = true) {
24+
def hookFile = "hooks/post_hook_${candidate}_${version}_${universal ? 'universal' : platform}.sh"
25+
stubFor(get(urlEqualTo("/hooks/post/$candidate/$version/$platform")).willReturn(
2626
aResponse()
2727
.withStatus(200)
2828
.withHeader("Content-Type", "text/plain")

src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Feature: Hooks
2+
3+
We can safely remove this feature when `.tar.gz` and `.zip` are supported directly by the backend.
4+
5+
Background:
6+
Given the internet is reachable
7+
And an initialised environment
8+
9+
Scenario: Post-installation Hook returns successfully
10+
And an "x86_64" machine with "Linux" installed
11+
And the system is bootstrapped
12+
And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64"
13+
And a post-installation hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully
14+
When I enter "sdk install grails 2.1.0"
15+
And I see "Post-installation hook success"
16+
And the exit code is 0
17+
18+
Scenario: Post-install Hook returns a non-zero code
19+
And an "x86_64" machine with "Linux" installed
20+
And the system is bootstrapped
21+
And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64"
22+
And a post-installation hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure
23+
When I enter "sdk install grails 2.1.0"
24+
Then I see "Post-installation hook failure"
25+
And the exit code is 1

src/test/resources/features/java_installation.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Feature: Java Multi Platform Binary Distribution
44
This feature uses real hooks found in the resources folder under /hooks.
55

66
The following hooks are available:
7-
8.0.111: pre- and post-hooks prepared for successful installation
8-
8.0.101: pre-hook succeeds but post-hook aborts with non-zero return code
7+
8.0.111: post-hook prepared for successful installation
8+
8.0.101: post-hook aborts with non-zero return code
99

1010
Background:
1111
Given the internet is reachable
@@ -15,7 +15,7 @@ Feature: Java Multi Platform Binary Distribution
1515
Given an "x86_64" machine with "Linux" installed
1616
And the system is bootstrapped
1717
And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64"
18-
And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "x86_64"
18+
And the appropriate multi-platform hook is available for "java" version "8.0.111" on "Linux" with architecture "x86_64"
1919
When I enter "sdk install java 8.0.111"
2020
And I see "Done installing!"
2121
And the candidate "java" version "8.0.111" is installed
@@ -25,7 +25,7 @@ Feature: Java Multi Platform Binary Distribution
2525
And the system is bootstrapped
2626
And the default "java" version is "8.0.111"
2727
And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64"
28-
And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "x86_64"
28+
And the appropriate multi-platform hook is available for "java" version "8.0.111" on "Linux" with architecture "x86_64"
2929
When I enter "sdk install java"
3030
And I see "Done installing!"
3131
And the candidate "java" version "8.0.111" is installed
@@ -34,7 +34,7 @@ Feature: Java Multi Platform Binary Distribution
3434
Given an "x86_64" machine with "Linux" installed
3535
And the system is bootstrapped
3636
And the candidate "java" version "8.0.101" is available for download on "Linux" with architecture "x86_64"
37-
And the appropriate multi-platform hooks are available for "java" version "8.0.101" on "Linux" with architecture "x86_64"
37+
And the appropriate multi-platform hook is available for "java" version "8.0.101" on "Linux" with architecture "x86_64"
3838
When I enter "sdk install java 8.0.101"
3939
And I see "Download has failed, aborting!"
4040
And the candidate "java" version "8.0.101" is not installed

src/test/resources/features/pre_and_post_installation_hooks.feature

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)