diff --git a/build-tools/README.md b/build-tools/README.md index a1debb98a..217b9d834 100644 --- a/build-tools/README.md +++ b/build-tools/README.md @@ -6,7 +6,7 @@ This folder contains tools for building up a Devfile Registry Repository and pac ### Prerequisites -- Golang 1.13.x or higher +- Golang 1.24.x or higher - Docker 17.05 or higher - Git - [yq](https://github.com/mikefarah/yq) 4.x diff --git a/build-tools/build_image.sh b/build-tools/build_image.sh index 0e1952b01..9c177c938 100755 --- a/build-tools/build_image.sh +++ b/build-tools/build_image.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # # Copyright Red Hat # @@ -13,15 +15,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -#!/bin/bash - buildToolsFolder="$(dirname "$0")" registryFolder=$(mktemp -d) +# run setenv.sh script if invoking directly +if [ "$0" == "$BASH_SOURCE" ]; then + . $buildToolsFolder/../setenv.sh +fi + display_usage() { echo "A devfile registry repository folder must be passed in as an argument" - echo "usage: build_image.sh " -} + echo "usage: build_image.sh [offline: 0|1]" +} + +# Download all offline resources +download_offline() { + export STACKS_DIR=$1 + + # Download all the offline parent devfiles + bash $buildToolsFolder/dl_parent_devfiles.sh + + # Download all the offline starter projects + bash $buildToolsFolder/dl_starter_projects.sh + + # Update all devfiles to use offline starter projects + bash $buildToolsFolder/update_devfiles_offline.sh + + return $? +} # cleanup_and_exit removes the temp folder we created and exits with the exit code passed into it cleanup_and_exit() { @@ -30,11 +51,19 @@ cleanup_and_exit() { } # Check if a registry repository folder was passed in, if not, exit -if [ $# -ne 1 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then display_usage exit 1 fi +if [ ! -z $2 ] && [ $2 -eq 1 ]; then + download_offline $1/stacks + + if [ $? -ne 0 ]; then + exit $? + fi +fi + bash $buildToolsFolder/build.sh $1 $registryFolder if [ $? -ne 0 ]; then echo "Failed to build the devfile registry index" diff --git a/build-tools/update_devfiles_offline.sh b/build-tools/update_devfiles_offline.sh index 56ba1370e..756f925c4 100755 --- a/build-tools/update_devfiles_offline.sh +++ b/build-tools/update_devfiles_offline.sh @@ -22,7 +22,7 @@ # the location to the offline project in the stack root # Path of stacks directory in the registry -STACKS_DIR=/registry/stacks +STACKS_DIR=${STACKS_DIR:-/registry/stacks} # Automated comment used to check whether the devfile has already been modified MODIFIED_MESSAGE="# AUTOMATED MODIFICATION -"