This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
executable file
·131 lines (106 loc) · 2.62 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# SPDX-FileCopyrightText: 2022 Contributors to the License scan action project <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
# Provide convenient debug information
set -o xtrace
# Set default values for variables
RUN_DOWNLOAD="false"
RUN_EVALUATE="true"
RUN_REPORT="true"
RUN_SCAN="false"
REPORT_FORMATS="SpdxDocument,WebApp"
# Parsing commandline arguments into variables
while [[ $# -gt 0 ]]; do
option="$1"
case $option in
--run-download)
RUN_DOWNLOAD="$2"
shift; shift
;;
--run-evaluate)
RUN_EVALUATE="$2"
shift; shift
;;
--run-report)
RUN_REPORT="$2"
shift; shift
;;
--run-scan)
RUN_SCAN="$2"
shift; shift
;;
--report-formats)
REPORT_FORMATS="$2"
shift; shift
;;
*)
echo "ERROR: Found unknown commandline argument: ${1}"
exit 1
;;
esac
done
exit_if_nonexisting () {
if [[ ! -f ${1} ]] ; then
exit 1
fi
}
# Prepare directory structure
mkdir -p "ort/reports"
# TODO: remove in favor of mentioning outputs as intended by GitHub Actions
mkdir -p "ort/results"
# Analyze
/opt/ort/bin/ort \
--info \
analyze \
-i "." \
-o "ort"
LAST_OUTPUT_FILE="ort/analyzer-result.yml"
exit_if_nonexisting ${LAST_OUTPUT_FILE}
cp "ort/analyzer-result.yml" "ort/results/"
# Download
# TODO: It might be worthwhile to allow changing the output location
if "${RUN_DOWNLOAD}"; then
/opt/ort/bin/ort \
--info \
download \
-i "ort/analyzer-result.yml" \
-o "ort/download"
fi
# Scan
if "${RUN_SCAN}"; then
/opt/ort/bin/ort \
--info \
scan \
-i "ort/analyzer-result.yml" \
-o "ort/"
LAST_OUTPUT_FILE="ort/scan-result.yml"
exit_if_nonexisting ${LAST_OUTPUT_FILE}
fi
# Evaluate
if "${RUN_EVALUATE}"; then
PKG_CURATIONS_ARG=""
if [[ -f curations.yml ]] ; then
PKG_CURATIONS_ARG="--package-curations-file curations.yml"
fi
/opt/ort/bin/ort \
--info \
evaluate \
-i "${LAST_OUTPUT_FILE}" \
-o "ort" \
$PKG_CURATIONS_ARG
LAST_OUTPUT_FILE="ort/evaluation-result.yml"
exit_if_nonexisting ${LAST_OUTPUT_FILE}
cp "ort/evaluation-result.yml" "ort/results/"
fi
# Report
if "${RUN_REPORT}"; then
/opt/ort/bin/ort \
--info \
report \
-f "${REPORT_FORMATS}" \
-i "${LAST_OUTPUT_FILE}" \
-o ort/reports \
|| exit 1
cp -r "ort/reports" "ort/results/"
fi