aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorGravatar Peter Korsgaard <peter@korsgaard.com>2016-06-01 17:55:16 +0200
committerGravatar Peter Korsgaard <peter@korsgaard.com>2016-06-01 17:55:16 +0200
commit577021e81b0bf894d26d8127822410267b2bb411 (patch)
tree8b93cd2342bc73294c9a7695cf8d558da7f16503 /support
parent206ce569269a4b0b7d3ae60f9162d40b290726d8 (diff)
parent5386c61796feb30a02ec287ad769a6754aa525dd (diff)
downloadbuildroot-577021e81b0bf894d26d8127822410267b2bb411.tar.gz
buildroot-577021e81b0bf894d26d8127822410267b2bb411.tar.bz2
Merge branch 'next'
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'support')
-rwxr-xr-xsupport/scripts/hardlink-or-copy35
-rw-r--r--support/scripts/pycompile.py24
2 files changed, 59 insertions, 0 deletions
diff --git a/support/scripts/hardlink-or-copy b/support/scripts/hardlink-or-copy
new file mode 100755
index 0000000000..b046bdf059
--- /dev/null
+++ b/support/scripts/hardlink-or-copy
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Try to hardlink a file into a directory, fallback to copy on failure.
+#
+# Hardlink-or-copy the source file in the first argument into the
+# destination directory in the second argument, using the basename in
+# the third argument as basename for the destination file. If the third
+# argument is missing, use the basename of the source file as basename
+# for the destination file.
+#
+# In either case, remove the destination prior to doing the
+# hardlink-or-copy.
+#
+# Note that this is NOT an atomic operation.
+
+set -e
+
+main() {
+ local src_file="${1}"
+ local dst_dir="${2}"
+ local dst_file="${3}"
+
+ if [ -n "${dst_file}" ]; then
+ dst_file="${dst_dir}/${dst_file}"
+ else
+ dst_file="${dst_dir}/${src_file##*/}"
+ fi
+
+ mkdir -p "${dst_dir}"
+ rm -f "${dst_file}"
+ ln -f "${src_file}" "${dst_file}" 2>/dev/null \
+ || cp -f "${src_file}" "${dst_file}"
+}
+
+main "${@}"
diff --git a/support/scripts/pycompile.py b/support/scripts/pycompile.py
new file mode 100644
index 0000000000..fde711a42a
--- /dev/null
+++ b/support/scripts/pycompile.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+# Wrapper for python2 and python3 around compileall to raise exception
+# when a python byte code generation failed.
+#
+# Inspired from:
+# http://stackoverflow.com/questions/615632/how-to-detect-errors-from-compileall-compile-dir
+
+from __future__ import print_function
+import sys
+import py_compile
+import compileall
+
+class ReportProblem:
+ def __nonzero__(self):
+ type, value, traceback = sys.exc_info()
+ if type is not None and issubclass(type, py_compile.PyCompileError):
+ print("Cannot compile %s" %value.file)
+ raise value
+ return 1
+
+report_problem = ReportProblem()
+
+compileall.compile_dir(sys.argv[1], quiet=report_problem)