-echo Fetching %_bootimage_version% boot image...
-set boot_image_url=http://downloads.factorcode.org/images/%GIT_BRANCH%/%_bootimage% %_bootimage%
-echo URL: %boot_image_url%
-cscript /nologo misc\http-get.vbs %boot_image_url% %_bootimage%
-if errorlevel 1 goto fail
+set _bootimage_url=https://downloads.factorcode.org/images/%GIT_BRANCH%/%_bootimage%
+if "%_bootimage_type%"=="download" (
+ call :download %GIT_BRANCH% %_bootimage_url% %_bootimage%
+ if errorlevel 1 (
+ echo boot image for branch %GIT_BRANCH% is not on server, trying master instead
+ call :download master https://downloads.factorcode.org/images/master/%_bootimage% %_bootimage%
+ )
+ if errorlevel 1 goto fail
+) else if "%_bootimage_type%"=="make" (
+ echo Making boot image...
+ .\factor.com -run=bootstrap.image %_bootimage%
+ if errorlevel 1 goto fail
+)