-
Notifications
You must be signed in to change notification settings - Fork 315
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
[bldr-build] Adds new helper function & default phase implementations. #136
Merged
Conversation
This file contains 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 change introduces several new public-facing helper functions: * `download_file()` * `verify_file()` * `unpack_file()` This allows a Plan author to use these functions to download, verify, or unpack additional archives and artifacts. The default phase behavior use these new functions under the covers and ensures there is one code path to perfom the above mentioned tasks. Additionally a new compositional style is unlocked with the creation of a "default" implementation for each phase function. The first class phase functions can then be overridden by Plan authors (as before), but now they can invoke the original implementation before **adding** more behavior. The following new public-facing helper functions have been added: * `do_default_begin()` * `do_default_download()` * `do_default_verify()` * `do_default_clean()` * `do_default_unpack()` * `do_default_prepare()` * `do_default_build()` * `do_default_install()` * `do_default_build_config()` * `do_default_build_service()` * `do_default_strip()` * `do_default_dockerfile_inline()` * `do_default_docker_image()` * `do_default_end()` For an example that ties both of these concepts together, consider a slightly non-standard Plan that must download multiple patches to be applied on top of a base release. Readline is such an example. Here is a young version of part of a Readline Plan which downloads and verifies a collection of patches in the appropriate phase callback functions. The default behavior of downloading, verifying, and unpacking the main source archive is preserved by augmenting the `do_download()` and `do_verify()` callbacks. Example: ``` # The root URL for all official patch files _patch_url_base=$_url_base/${pkg_name}-${_base_version}-patches/${pkg_name}${_base_version//.} # All official patch file URLs _patch_files=( ${_patch_url_base}-001 ${_patch_url_base}-002 ${_patch_url_base}-003 ${_patch_url_base}-004 ${_patch_url_base}-005 ${_patch_url_base}-006 ${_patch_url_base}-007 ${_patch_url_base}-008 ) # All official patch file shasums _patch_shasums=( 1a79bbb6eaee750e0d6f7f3d059b30a45fc54e8e388a8e05e9c3ae598590146f 39e304c7a526888f9e112e733848215736fb7b9d540729b9e31f3347b7a1e0a5 ec41bdd8b00fd884e847708513df41d51b1243cecb680189e31b7173d01ca52f 4547b906fb2570866c21887807de5dee19838a60a1afb66385b272155e4355cc 877788f9228d1a9907a4bcfe3d6dd0439c08d728949458b41208d9bf9060274b 5c237ab3c6c97c23cf52b2a118adc265b7fb411b57c93a5f7c221d50fafbe556 4d79b5a2adec3c2e8114cbd3d63c1771f7c6cf64035368624903d257014f5bea 3bc093cf526ceac23eb80256b0ec87fa1735540d659742107b6284d635c43787 ) do_download() { do_default_download # Download all patch files, providing the corresponding shasums so we can # skip re-downloading if already present and verified for i in $(seq 0 $((${#_patch_files[@]} - 1))); do p="${_patch_files[$i]}" download_file $p $(basename $p) ${_patch_shasums[$i]} done; unset i p } do_verify() { do_default_verify # Verify all patch files against their shasums for i in $(seq 0 $((${#_patch_files[@]} - 1))); do verify_file $(basename ${_patch_files[$i]}) ${_patch_shasums[$i]} done; unset i } ``` As no external behavior changed, all previous Plans will execute as before, but there are now options for Plan authors to (hopefully) delete code to reduce duplication.
This PR has passed 'Verify' and is ready for review and approval! |
@delivery approve |
chef-delivery
added a commit
that referenced
this pull request
Jan 11, 2016
Merged change 4850cc70-3870-440a-830e-3b2d338fb920 From review branch fnichol/bldr-build-more-helpers into master Signed-off-by: adam <[email protected]>
Change: 4850cc70-3870-440a-830e-3b2d338fb920 approved by: @adamhjk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change introduces several new public-facing helper functions:
download_file()
verify_file()
unpack_file()
This allows a Plan author to use these functions to download, verify, or
unpack additional archives and artifacts. The default phase behavior use
these new functions under the covers and ensures there is one code path
to perfom the above mentioned tasks.
Additionally a new compositional style is unlocked with the creation of
a "default" implementation for each phase function. The first class
phase functions can then be overridden by Plan authors (as before), but
now they can invoke the original implementation before adding more
behavior. The following new public-facing helper functions have been
added:
do_default_begin()
do_default_download()
do_default_verify()
do_default_clean()
do_default_unpack()
do_default_prepare()
do_default_build()
do_default_install()
do_default_build_config()
do_default_build_service()
do_default_strip()
do_default_dockerfile_inline()
do_default_docker_image()
do_default_end()
For an example that ties both of these concepts together, consider a
slightly non-standard Plan that must download multiple patches to be
applied on top of a base release. Readline is such an example. Here is a
young version of part of a Readline Plan which downloads and verifies a
collection of patches in the appropriate phase callback functions. The
default behavior of downloading, verifying, and unpacking the main
source archive is preserved by augmenting the
do_download()
anddo_verify()
callbacks.Example:
As no external behavior changed, all previous Plans will execute as
before, but there are now options for Plan authors to (hopefully)
delete code to reduce duplication.