aboutsummaryrefslogtreecommitdiffstats
path: root/test/legal/docker_license_analysis/tools/analysis.sh
diff options
context:
space:
mode:
authorAlexander Mazuruk <a.mazuruk@samsung.com>2020-12-17 17:13:45 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2021-01-04 07:29:18 +0000
commit846dd7f1f83214a4bd8bbf81ede5ac8bc12d81fd (patch)
tree0916281119b678f50718019c0d9f42065eee7462 /test/legal/docker_license_analysis/tools/analysis.sh
parentdd9bf99fe8c5bd124b2a578399dcd8c77496c1f8 (diff)
Add license analysis vagrantfile
Usage in README.rst This Vagrantfile is intended for single image analysis. Issue-ID: INT-1735 Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com> Change-Id: Ief45804d216a9a50777491c2cf7a8088133e5a3b
Diffstat (limited to 'test/legal/docker_license_analysis/tools/analysis.sh')
-rwxr-xr-xtest/legal/docker_license_analysis/tools/analysis.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/legal/docker_license_analysis/tools/analysis.sh b/test/legal/docker_license_analysis/tools/analysis.sh
new file mode 100755
index 000000000..a667ce69c
--- /dev/null
+++ b/test/legal/docker_license_analysis/tools/analysis.sh
@@ -0,0 +1,31 @@
+#!/bin/env sh
+# Analysis is run twice to populate tern cache:
+# https://github.com/tern-tools/tern/issues/818
+
+TERNVENV="${TERNVENV:-$HOME/ternvenv}"
+
+if [ -d "$TERNVENV" ]; then
+ cd $TERNVENV
+ if [ -f bin/activate ]; then
+ . bin/activate
+ else
+ echo "Tern virtual environment is not initialized!" >&2;
+ exit 1
+ fi
+else
+ echo "Ternenv directory not found, if it is not in $HOME/ternvenv set the \$TERNVENV to your location." >&2;
+ exit 1
+fi
+
+if [ -n "$IMAGE" ]; then
+ echo 'Running Docker Image analysis'
+ tern report -f json -o /dev/null -i "$IMAGE"
+ tern report -f json -o report-scancode.json -x scancode -i "$IMAGE"
+elif [ -f "$FILE" ]; then
+ echo 'Running Dockerfile analysis'
+ tern report -f json -o /dev/null -d $FILE
+ tern report -f json -o report-scancode.json -x scancode -d $FILE
+else
+ echo "\$IMAGE is not set and \$FILE does not point to a file." >&2;
+fi
+