Repository navigation
Add the webfront-wf driver and bootstrap provisioning [#321] #336
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
35c0741
Add the webfront-wf driver, configure-time bootstrap provisioning and…
ambroise-leclerc 751771a
Run the driver usage test under the display wrapper like the other br…
ambroise-leclerc 58b00e9
Keep established connections when the network is cut, bound the boots…
ambroise-leclerc 6b6b113
Serve the pinned starters from the driver and survive a lost bridge a…
ambroise-leclerc f68a828
Follow the entry declared by environment.json and keep the provisioni…
ambroise-leclerc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # Bootstrap environment used to test WebFront: the pinned archive wf runs from, provisioned at configure time. | ||
| # | ||
| # It is distinct from include/webfront/system/DeveloperReleaseData.hpp (the environment applications start from) and is | ||
| # updated by an explicit pull request, once a published environment can build and test itself without interaction. | ||
| # 0.5.0 is the last published environment: it has no non-interactive mode yet, so the driver tests run the environment built | ||
| # from the current sources (the "environment under test") until the first environment that can bootstrap itself is pinned. | ||
| set(WEBFRONT_BOOTSTRAP_VERSION "0.5.0") | ||
| set(WEBFRONT_BOOTSTRAP_URL "https://ambroise-leclerc.github.io/WebFront/developer/0.5.0/environment.tgz") | ||
| set(WEBFRONT_BOOTSTRAP_INTEGRITY "sha512-TV6S61kUhnCJc99/Ow890Pro47mfZ0fBqki17lx0xnpCNmcfcqZPpO1SG09Su50WIEtRDopMxt3yvanFwbLEdQ==") | ||
|
|
||
| # A directory holding environment.tgz (the pinned archive) replaces the download on a machine without network access. | ||
| set(WEBFRONT_BOOTSTRAP_DIR "" CACHE PATH "Directory with the pinned bootstrap environment.tgz, instead of downloading it") | ||
|
|
||
| # Converts a base64 value to lowercase hexadecimal bytes. | ||
| function(webfront_base64_to_hex value output) | ||
| set(alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") | ||
| string(LENGTH "${value}" length) | ||
| math(EXPR remainder "${length} % 4") | ||
| if(NOT remainder EQUAL 0) | ||
| message(FATAL_ERROR "Invalid base64 value (length ${length})") | ||
| endif() | ||
| set(hex "") | ||
| math(EXPR last "${length} - 1") | ||
| foreach(start RANGE 0 ${last} 4) | ||
| set(group 0) | ||
| set(padding 0) | ||
| foreach(offset RANGE 0 3) | ||
| math(EXPR position "${start} + ${offset}") | ||
| string(SUBSTRING "${value}" ${position} 1 character) | ||
| if(character STREQUAL "=") | ||
| math(EXPR padding "${padding} + 1") | ||
| set(sextet 0) | ||
| else() | ||
| string(FIND "${alphabet}" "${character}" sextet) | ||
| if(sextet EQUAL -1) | ||
| message(FATAL_ERROR "Invalid base64 character '${character}'") | ||
| endif() | ||
| endif() | ||
| math(EXPR group "(${group} << 6) | ${sextet}") | ||
| endforeach() | ||
| math(EXPR bytes "3 - ${padding}") | ||
| foreach(index RANGE 0 ${bytes}) | ||
| if(index EQUAL bytes) | ||
| break() | ||
| endif() | ||
| math(EXPR shift "16 - 8 * ${index}") | ||
| math(EXPR byte "(${group} >> ${shift}) & 255" OUTPUT_FORMAT HEXADECIMAL) | ||
| string(SUBSTRING "${byte}" 2 -1 digits) | ||
| string(LENGTH "${digits}" digitCount) | ||
| if(digitCount EQUAL 1) | ||
| set(digits "0${digits}") | ||
| endif() | ||
| string(APPEND hex "${digits}") | ||
| endforeach() | ||
| endforeach() | ||
| set(${output} "${hex}" PARENT_SCOPE) | ||
| endfunction() | ||
|
|
||
| # The hexadecimal SHA-512 of an SRI value ("sha512-<base64>"). | ||
| function(webfront_sri_to_sha512 integrity output) | ||
| if(NOT integrity MATCHES "^sha512-([A-Za-z0-9+/]+=*)$") | ||
| message(FATAL_ERROR "Bootstrap integrity must be a sha512- SRI value: '${integrity}'") | ||
| endif() | ||
| webfront_base64_to_hex("${CMAKE_MATCH_1}" hex) | ||
| string(LENGTH "${hex}" length) | ||
| if(NOT length EQUAL 128) | ||
| message(FATAL_ERROR "Bootstrap integrity is not a SHA-512 digest") | ||
| endif() | ||
| set(${output} "${hex}" PARENT_SCOPE) | ||
| endfunction() | ||
|
|
||
| # Makes <archive> the verified path of an environment archive: <LOCAL_DIR>/<name> when LOCAL_DIR is given, else the | ||
| # download of URL into DESTINATION (reused when it already matches). A wrong digest or a missing file stops the configure. | ||
| function(webfront_provision_bootstrap archive) | ||
| cmake_parse_arguments(ARG "" "URL;INTEGRITY;DESTINATION;LOCAL_DIR" "" ${ARGN}) | ||
| webfront_sri_to_sha512("${ARG_INTEGRITY}" expected) | ||
| get_filename_component(name "${ARG_URL}" NAME) | ||
| if(ARG_LOCAL_DIR) | ||
| set(path "${ARG_LOCAL_DIR}/${name}") | ||
| if(NOT EXISTS "${path}") | ||
| message(FATAL_ERROR "Bootstrap environment ${path} is missing: WEBFRONT_BOOTSTRAP_DIR must hold ${name}") | ||
| endif() | ||
| else() | ||
| set(path "${ARG_DESTINATION}/${name}") | ||
| set(present FALSE) | ||
| if(EXISTS "${path}") | ||
| file(SHA512 "${path}" actual) | ||
| if(actual STREQUAL expected) | ||
| set(present TRUE) | ||
| endif() | ||
| endif() | ||
| if(NOT present) | ||
| file(MAKE_DIRECTORY "${ARG_DESTINATION}") | ||
| file(DOWNLOAD "${ARG_URL}" "${path}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600) | ||
| list(GET result 0 code) | ||
| if(NOT code EQUAL 0) | ||
| file(REMOVE "${path}") | ||
| list(GET result 1 reason) | ||
| message(FATAL_ERROR "Cannot download the bootstrap environment ${ARG_URL}: ${reason}. " | ||
| "Provision it with -DWEBFRONT_BOOTSTRAP_DIR=<directory holding ${name}>.") | ||
| endif() | ||
| endif() | ||
| endif() | ||
| file(SHA512 "${path}" actual) | ||
| if(NOT actual STREQUAL expected) | ||
| if(NOT ARG_LOCAL_DIR) | ||
| file(REMOVE "${path}") | ||
| endif() | ||
| message(FATAL_ERROR "Bootstrap environment integrity check failed for ${path}: expected ${ARG_INTEGRITY}") | ||
| endif() | ||
| set(${archive} "${path}" PARENT_SCOPE) | ||
| endfunction() | ||
|
|
||
| # The SRI value ("sha512-<base64>") of a file, for archives a test builds itself. | ||
| function(webfront_file_sri file output) | ||
| file(SHA512 "${file}" hex) | ||
| set(alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") | ||
| string(LENGTH "${hex}" length) | ||
| set(encoded "") | ||
| foreach(start RANGE 0 ${length} 6) | ||
| if(start GREATER_EQUAL length) | ||
| break() | ||
| endif() | ||
| math(EXPR remaining "(${length} - ${start}) / 2") | ||
| string(SUBSTRING "${hex}" ${start} 6 digits) | ||
| string(LENGTH "${digits}" digitCount) | ||
| string(APPEND digits "000000") | ||
| string(SUBSTRING "${digits}" 0 6 digits) | ||
| math(EXPR group "0x${digits}") | ||
| set(characters 4) | ||
| if(remaining EQUAL 1) | ||
| set(characters 2) | ||
| elseif(remaining EQUAL 2) | ||
| set(characters 3) | ||
| endif() | ||
| foreach(index RANGE 0 3) | ||
| math(EXPR shift "18 - 6 * ${index}") | ||
| math(EXPR sextet "(${group} >> ${shift}) & 63") | ||
| if(index LESS characters) | ||
| string(SUBSTRING "${alphabet}" ${sextet} 1 character) | ||
| else() | ||
| set(character "=") | ||
| endif() | ||
| string(APPEND encoded "${character}") | ||
| endforeach() | ||
| endforeach() | ||
| set(${output} "sha512-${encoded}" PARENT_SCOPE) | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.