Skip to content

Commit ab7dd6d

Browse files
tsteenbefviernau
authored andcommitted
ort-reporter: Conditionally set Reporter CLI options
Only set options for: A) Files or directories found in the configuration directory B) Report formats specified by the user Signed-off-by: Thomas Steenbergen <[email protected]>
1 parent acabd70 commit ab7dd6d

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

scripts/ort-reporter.sh

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,60 @@ elif [[ "$ORT_DISABLE_SCANNER" = "false" && "$ORT_DISABLE_EVALUATOR" = "true" ]]
1515
ORT_RESULTS_INPUT_FILE=$ORT_RESULTS_SCANNER_FILE
1616
fi
1717

18+
if [[ -f "$ORT_CONFIG_COPYRIGHT_GARBAGE_FILE" ]]; then
19+
ORT_REPORTER_OPTIONS="--copyright-garbage-file $ORT_CONFIG_COPYRIGHT_GARBAGE_FILE"
20+
else
21+
ORT_REPORTER_OPTIONS=""
22+
fi
23+
24+
if [[ -d "$ORT_CONFIG_CUSTOM_LICENSE_TEXTS_DIR" ]]; then
25+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --custom-license-texts-dir $ORT_CONFIG_CUSTOM_LICENSE_TEXTS_DIR"
26+
fi
27+
28+
if [[ -f "$ORT_HOW_TO_FIX_TEXT_PROVIDER_FILE" ]]; then
29+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --how-to-fix-text-provider-script $ORT_HOW_TO_FIX_TEXT_PROVIDER_FILE"
30+
fi
31+
32+
if [[ -f "$ORT_CONFIG_LICENSE_CONFIGURATION_FILE" ]]; then
33+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --license-classifications-file $ORT_CONFIG_LICENSE_CONFIGURATION_FILE"
34+
fi
35+
36+
if [[ -d "$ORT_CONFIG_PACKAGE_CONFIGURATION_DIR" ]]; then
37+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --package-configuration-dir $ORT_CONFIG_PACKAGE_CONFIGURATION_DIR"
38+
elif [[ -f "$ORT_CONFIG_PACKAGE_CONFIGURATION_FILE" ]]; then
39+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --package-configuration-file $ORT_CONFIG_PACKAGE_CONFIGURATION_FILE"
40+
elif [[ -d "$ORT_CONFIG/packages" ]]; then
41+
# Use legacy named package configuration directory if present.
42+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --package-configuration-dir $ORT_CONFIG/packages"
43+
ORT_CONFIG_PACKAGE_CONFIGURATION_DIR=$ORT_CONFIG/packages
44+
fi
45+
46+
if [[ -f "$ORT_CONFIG_RESOLUTIONS_FILE" ]]; then
47+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS --resolutions-file $ORT_CONFIG_RESOLUTIONS_FILE"
48+
fi
49+
50+
if [[ $ORT_REPORT_FORMATS =~ "EvaluatedModel" ]]; then
51+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS -O EvaluatedModel=output.file.formats=json"
52+
fi
53+
54+
if [[ $ORT_REPORT_FORMATS =~ "NoticeTemplate" ]]; then
55+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS -O NoticeTemplate=project-types-as-packages=\"SpdxDocumentFile\""
56+
ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS -O NoticeTemplate=template.path=$ORT_CONFIG_NOTICE_TEMPLATE_PATHS"
57+
fi
58+
59+
# FIXME: Below statement fails if SW_NAME contains a space
60+
# if [[ $ORT_REPORT_FORMATS =~ "SpdxDocument" ]]; then
61+
# ORT_REPORTER_OPTIONS="$ORT_REPORTER_OPTIONS -O SpdxDocument=document.name='${SW_NAME}' \ -O SpdxDocument=output.file.formats=json,yaml"
62+
# fi
63+
1864
$ORT \
1965
--$ORT_LOG_LEVEL \
2066
--stacktrace \
2167
report \
68+
$ORT_REPORTER_OPTIONS \
2269
-f $ORT_REPORT_FORMATS \
2370
-i $ORT_RESULTS_INPUT_FILE \
2471
-o $ORT_RESULTS_DIR \
25-
--copyright-garbage-file $ORT_CONFIG_COPYRIGHT_GARBAGE_FILE \
26-
--resolutions-file $ORT_CONFIG_RESOLUTIONS_FILE \
27-
--custom-license-texts-dir $ORT_CONFIG_CUSTOM_LICENSE_TEXTS_DIR \
28-
--license-classifications-file $ORT_CONFIG_LICENSE_CONFIGURATION_FILE \
29-
--package-configuration-dir $ORT_CONFIG_PACKAGE_CONFIGURATION_DIR \
30-
--how-to-fix-text-provider-script $ORT_HOW_TO_FIX_TEXT_PROVIDER_FILE \
31-
-O EvaluatedModel=output.file.formats=json \
32-
-O NoticeTemplate=project-types-as-packages="SpdxDocumentFile" \
33-
-O NoticeTemplate=template.path=$ORT_CONFIG_NOTICE_TEMPLATE_PATHS \
3472
-O SpdxDocument=document.name="${SW_NAME}" \
3573
-O SpdxDocument=output.file.formats=json,yaml
3674

0 commit comments

Comments
 (0)