jjb: MacOSX: mktemp wrapper that respects $TMPDIR
[lttng-ci.git] / scripts / binutils-gdb / build.sh
index 94bded9d9d0962cae4f434cde9ea7190111b9bdd..3d7c561a477f60e75105289a7c2f9ca803a8fe5a 100755 (executable)
 
 set -exu
 
+mktemp_compat() {
+    case "$platform" in
+        macos*)
+            # On MacOSX, mktemp doesn't respect TMPDIR in the same way as many
+            # other systems. Use the final positional argument to force the
+            # tempfile or tempdir to be created inside $TMPDIR, which must
+            # already exist.
+            if [ -n "${TMPDIR}" ] ; then
+                mktemp "${@}" "${TMPDIR}/tmp.XXXXXXXXXX"
+            else
+                mktemp "${@}"
+            fi
+        ;;
+        *)
+            mktemp "${@}"
+        ;;
+    esac
+}
+
+print_header() {
+    set +x
+
+    local message=" $1 "
+    local message_len
+    local padding_len
+
+    message_len="${#message}"
+    padding_len=$(( (80 - (message_len)) / 2 ))
+
+    printf '\n'; printf -- '#%.0s' {1..80}; printf '\n'
+    printf -- '-%.0s' {1..80}; printf '\n'
+    printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n'
+    printf -- '-%.0s' {1..80}; printf '\n'
+    printf -- '#%.0s' {1..80}; printf '\n\n'
+
+    set -x
+}
+
 failed_configure() {
     # Assume we are in the configured build directory
     echo "#################### BEGIN config.log ####################"
@@ -200,6 +238,8 @@ macos-*)
 esac
 
 # Print build env details
+print_header "Build environment details"
+print_hardware || true
 print_os || true
 print_tooling || true
 
@@ -262,7 +302,7 @@ case "$build" in
     echo "Out of tree build"
 
     # Create and enter a temporary build directory
-    builddir=$(mktemp -d)
+    builddir=$(mktemp_compat -d)
     cd "$builddir"
 
     "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
This page took 0.032785 seconds and 4 git commands to generate.