run.sh 2.46 KB
Newer Older
thc's avatar
thc committed
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
#!/usr/bin/env bash
# change to path of this script
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )

# path were ort is downloaded to
ORT=$PWD/oss-review-toolkit
# path back to this files folder relative from $ORT
PROJECT=$(readlink -f "$1")
# license to check against
TARGETLICENSE=$2

if ! [ -d "$PROJECT" ]; then
    echo "Error: project directory not found"
    exit 1
fi

if ! [ -f rulesets/"$TARGETLICENSE".kts ]; then
    echo "Error: targeted license not found"
    echo "available licenses:"
    for file in rulesets/*.kts; do
        echo "$(basename "$file")" | cut -f 1 -d '.'
    done
    exit 1
fi

## clear ort dir if not empty
rm -rf "$ORT"

## download ort
git clone --recurse-submodules https://github.com/heremaps/oss-review-toolkit.git $ORT

## copy own rulesets
cp rulesets/"$TARGETLICENSE".kts "$ORT"/evaluator/src/main/resources/rules

## build ort docker version
cd $ORT
./docker/build.sh
#
## run analyzer
docker/run.sh "-v $PROJECT:/project" --info analyze --allow-dynamic-versions -i /project -o /project/meta/inherent_licenses/ort/analyzer
## run scanner
docker/run.sh "-v $PROJECT:/project" --info scan --scopes devDependencies -a /project/meta/inherent_licenses/ort/analyzer/analyzer-result.yml -o /project/meta/inherent_licenses/ort/scanner
## run evaluator
docker/run.sh "-v $PROJECT:/project" --info evaluate --rules-resource rules/"$TARGETLICENSE".kts -i /project/meta/inherent_licenses/ort/scanner/scan-result.yml -o /project/meta/inherent_licenses/ort/evaluator
## run reporter
docker/run.sh "-v $PROJECT:/project" --info report -f StaticHtml,Notice,Excel,WebApp -i /project/meta/inherent_licenses/ort/evaluator/evaluation-result.yml -o /project/meta/inherent_licenses/ort/reporter
#
## clean up tmp files from ort
mv -f "$PROJECT"/meta/inherent_licenses/ort/reporter/scan-report.html "$PROJECT"/meta/inherent_licenses/"$TARGETLICENSE"_compatibility_static.html
mv -f "$PROJECT"/meta/inherent_licenses/ort/reporter/scan-report-web-app.html "$PROJECT"/meta/inherent_licenses/"$TARGETLICENSE"_compatibility_app.html
mv -f "$PROJECT"/meta/inherent_licenses/ort/reporter/scan-report.xlsx "$PROJECT"/meta/inherent_licenses/"$TARGETLICENSE"_compatibility.xlsx
mv -f "$PROJECT"/meta/inherent_licenses/ort/reporter/NOTICE "$PROJECT"/meta/inherent_licenses/"$TARGETLICENSE"_compatibility.txt

rm -rf "$PROJECT"/meta/inherent_licenses/ort
#
##leave note
echo 'generated by https://gitext.gfz-potsdam.de/mdolling/licensechecker' > "$PROJECT"/meta/inherent_licenses/readme