aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build-mingw.bat37
-rw-r--r--build-msvc.bat37
-rwxr-xr-xbuild.sh43
3 files changed, 97 insertions, 20 deletions
diff --git a/build-mingw.bat b/build-mingw.bat
index 04f5073..5a17fe8 100644
--- a/build-mingw.bat
+++ b/build-mingw.bat
@@ -9,7 +9,9 @@ goto start
:usage
echo.
-echo Usage: %0 [/?] ^<cxx^> [^<install-dir^>] [^<trust^>]
+echo Usage: %0 [/?] [^<options^>] ^<cxx^> [^<install-dir^>] [^<trust^>]
+echo Options:
+echo --timeout ^<sec^> Network operations timeout in seconds.
echo.
echo By default the batch file will install into C:\build2. It also expects
echo to find the base utilities in the bin\ subdirectory of the installation
@@ -31,8 +33,6 @@ goto end
set "owd=%CD%"
-if "_%1_" == "_/?_" goto usage
-
rem Package repository URL (or path).
rem
if "_%BUILD2_REPO%_" == "__" (
@@ -46,6 +46,33 @@ rem
set "cver=0.7-a.0"
set "cdir=build2-toolchain-%cver%"
+rem Parse options.
+rem
+set "timeout="
+
+:options
+if "_%~1_" == "_/?_" goto usage
+if "_%~1_" == "_-h_" goto usage
+if "_%~1_" == "_--help_" goto usage
+
+if "_%~1_" == "_--timeout_" (
+ if "_%~2_" == "__" (
+ echo error: value in seconds expected after --timeout
+ goto error
+ )
+ set "timeout=%~2"
+ shift
+ shift
+ goto options
+)
+if "_%~1_" == "_--_" shift
+
+rem Validate options and arguments.
+rem
+if not "_%timeout%_" == "__" (
+ set "timeout=--fetch-timeout %timeout%"
+)
+
rem Compiler.
rem
if "_%1_" == "__" (
@@ -177,10 +204,10 @@ bpkg-stage create^
bpkg-stage add %BUILD2_REPO%
@if errorlevel 1 goto error
-bpkg-stage fetch %trust%
+bpkg-stage fetch %timeout% %trust%
@if errorlevel 1 goto error
-bpkg-stage build --yes build2 bpkg
+bpkg-stage build %timeout% --yes build2 bpkg
@if errorlevel 1 goto error
bpkg-stage install build2 bpkg
diff --git a/build-msvc.bat b/build-msvc.bat
index e129ede..477950d 100644
--- a/build-msvc.bat
+++ b/build-msvc.bat
@@ -9,7 +9,9 @@ goto start
:usage
echo.
-echo Usage: %0 [/?] [^<install-dir^>] [^<trust^>]
+echo Usage: %0 [/?] [^<options^>] [^<install-dir^>] [^<trust^>]
+echo Options:
+echo --timeout ^<sec^> Network operations timeout in seconds.
echo.
echo By default the batch file will install into C:\build2. It also expects
echo to find the base utilities in the bin\ subdirectory of the installation
@@ -31,8 +33,6 @@ goto end
set "owd=%CD%"
-if "_%1_" == "_/?_" goto usage
-
rem Package repository URL (or path).
rem
if "_%BUILD2_REPO%_" == "__" (
@@ -46,6 +46,33 @@ rem
set "cver=0.7-a.0"
set "cdir=build2-toolchain-%cver%"
+rem Parse options.
+rem
+set "timeout="
+
+:options
+if "_%~1_" == "_/?_" goto usage
+if "_%~1_" == "_-h_" goto usage
+if "_%~1_" == "_--help_" goto usage
+
+if "_%~1_" == "_--timeout_" (
+ if "_%~2_" == "__" (
+ echo error: value in seconds expected after --timeout
+ goto error
+ )
+ set "timeout=%~2"
+ shift
+ shift
+ goto options
+)
+if "_%~1_" == "_--_" shift
+
+rem Validate options and arguments.
+rem
+if not "_%timeout%_" == "__" (
+ set "timeout=--fetch-timeout %timeout%"
+)
+
rem Installation directory.
rem
if "_%1_" == "__" (
@@ -167,10 +194,10 @@ bpkg-stage create^
bpkg-stage add %BUILD2_REPO%
@if errorlevel 1 goto error
-bpkg-stage fetch %trust%
+bpkg-stage fetch %timeout% %trust%
@if errorlevel 1 goto error
-bpkg-stage build --yes build2 bpkg
+bpkg-stage build %timeout% --yes build2 bpkg
@if errorlevel 1 goto error
bpkg-stage install build2 bpkg
diff --git a/build.sh b/build.sh
index 7ab3aae..818d3f3 100755
--- a/build.sh
+++ b/build.sh
@@ -56,6 +56,7 @@ while test $# -ne 0; do
diag " --repo <loc> Alternative package repository location."
diag " --trust <fp> Certificate fingerprint to trust."
diag " --make <jobs> Bootstrap using GNU make instead of script."
+ diag " --timeout <sec> Network operations timeout in seconds."
diag
diag "By default the script will install into /usr/local using sudo(1)."
diag "To use sudo for a custom installation directory you need to specify"
@@ -121,6 +122,16 @@ while test $# -ne 0; do
make="$1"
shift
;;
+ --timeout)
+ shift
+ if test $# -eq 0; then
+ diag "error: value in seconds expected after --timeout"
+ diag "$usage"
+ exit 1
+ fi
+ timeout="$1"
+ shift
+ ;;
*)
cxx="$1"
break
@@ -178,6 +189,26 @@ case "$sys" in
;;
esac
+# We don't have arrays in POSIX shell but we should be ok as well as none of
+# the option values contain spaces. Note also that the expansion must be
+# unquoted.
+#
+bpkg_fetch_ops=
+bpkg_build_ops=
+
+if test -n "$timeout"; then
+ bpkg_fetch_ops="--fetch-timeout $timeout"
+ bpkg_build_ops="--fetch-timeout $timeout"
+fi
+
+if test "$trust" = "yes"; then
+ bpkg_fetch_ops="$bpkg_fetch_ops --trust-yes"
+elif test "$trust" = "no"; then
+ bpkg_fetch_ops="$bpkg_fetch_ops --trust-no"
+elif test -n "$trust"; then
+ bpkg_fetch_ops="$bpkg_fetch_ops --trust $trust"
+fi
+
# Bootstrap, stage 1.
#
run cd build2
@@ -230,16 +261,8 @@ config.install.root="$idir" \
config.install.sudo="$conf_sudo"
run bpkg-stage add "$BUILD2_REPO"
-if test -z "$trust"; then
- run bpkg-stage fetch
-elif test "$trust" = "yes"; then
- run bpkg-stage --trust-yes fetch
-elif test "$trust" = "no"; then
- run bpkg-stage --trust-no fetch
-else
- run bpkg-stage --trust "$trust" fetch
-fi
-run bpkg-stage build --yes build2 bpkg
+run bpkg-stage $bpkg_fetch_ops fetch
+run bpkg-stage $bpkg_build_ops build --yes build2 bpkg
run bpkg-stage install build2 bpkg
run which b