1+ #! /bin/bash
2+
13#
24# Copyright Red Hat
35#
1315# See the License for the specific language governing permissions and
1416# limitations under the License.
1517
16- #! /bin/bash
17-
1818buildToolsFolder=" $( dirname " $0 " ) "
1919registryFolder=$( mktemp -d)
2020
21+ # run setenv.sh script if invoking directly
22+ if [ " $0 " == " $BASH_SOURCE " ]; then
23+ . $buildToolsFolder /../setenv.sh
24+ fi
25+
2126display_usage () {
2227 echo " A devfile registry repository folder must be passed in as an argument"
23- echo " usage: build_image.sh <path-to-registry-repository-folder>"
24- }
28+ echo " usage: build_image.sh <path-to-registry-repository-folder> [offline: 0|1]"
29+ }
30+
31+ # Download all offline resources
32+ download_offline () {
33+ export STACKS_DIR=$1
34+
35+ # Download all the offline parent devfiles
36+ bash $buildToolsFolder /dl_parent_devfiles.sh
37+
38+ # Download all the offline starter projects
39+ bash $buildToolsFolder /dl_starter_projects.sh
40+
41+ # Update all devfiles to use offline starter projects
42+ bash $buildToolsFolder /update_devfiles_offline.sh
43+
44+ return $?
45+ }
2546
2647# cleanup_and_exit removes the temp folder we created and exits with the exit code passed into it
2748cleanup_and_exit () {
@@ -30,11 +51,19 @@ cleanup_and_exit() {
3051}
3152
3253# Check if a registry repository folder was passed in, if not, exit
33- if [ $# -ne 1 ]; then
54+ if [ $# -lt 1 ] || [ $# -gt 2 ]; then
3455 display_usage
3556 exit 1
3657fi
3758
59+ if [ ! -z $2 ] && [ $2 -eq 1 ]; then
60+ download_offline $1 /stacks
61+
62+ if [ $? -ne 0 ]; then
63+ exit $?
64+ fi
65+ fi
66+
3867bash $buildToolsFolder /build.sh $1 $registryFolder
3968if [ $? -ne 0 ]; then
4069 echo " Failed to build the devfile registry index"
0 commit comments