Skip to content

Commit

Permalink
Use temp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
niallthomson committed Feb 27, 2025
1 parent 89aed4e commit efee0f7
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions oss/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,28 @@ parse_params() {
parse_params "$@"
setup_colors

temp_dir=$(mktemp -d)

echo "Using temp dir $temp_dir"

base_dir="/project"
src_dir="$base_dir/src"
ort_dir="$base_dir/oss/ort"
output_dir="$base_dir/oss-output"

if [ -d "$script_dir/../oss-output" ]; then
echo "Error: Output directory already exists please remove it"
exit 1
fi

function run_ort()
{
component=$1
profile=$2
output_dir=$3

container_component_dir="$src_dir/$component"

container_component_output_dir="$output_dir/$component"

docker run --rm --user 0 -v $script_dir/..:/project ghcr.io/oss-review-toolkit/ort:$ORT_VERSION analyze \
-i $container_component_dir -o $container_component_output_dir \
docker run --rm --user 0 -v $output_dir:/output -v $script_dir/..:/project ghcr.io/oss-review-toolkit/ort:$ORT_VERSION analyze \
-i $container_component_dir -o /output \
--repository-configuration-file "$ort_dir/$profile.ort.yml" -f JSON

docker run --rm --user 0 -v $script_dir/..:/project ghcr.io/oss-review-toolkit/ort:$ORT_VERSION download \
-i $container_component_output_dir/analyzer-result.json -o $container_component_output_dir/src
docker run --rm --user 0 -v $output_dir:/output -v $script_dir/..:/project ghcr.io/oss-review-toolkit/ort:$ORT_VERSION download \
-i /output/analyzer-result.json -o /output/src
}

function do_component()
Expand All @@ -119,7 +116,7 @@ function do_component()

component_dir="$script_dir/../src/$component"

component_output_dir="$script_dir/../oss-output/$component"
component_output_dir="$temp_dir/$component"

mkdir -p $component_output_dir

Expand All @@ -130,7 +127,19 @@ function do_component()
exit 1
fi

source $component_dir/scripts/oss.source
if [ -f "$component_dir/pom.xml" ]; then
echo "Detected Java"
run_ort $component 'maven' $component_output_dir
elif [ -f "$component_dir/go.mod" ]; then
echo "Detected Go"
run_ort $component 'go-mod' $component_output_dir
elif [ -f "$component_dir/package.json" ]; then
echo "Detected Javascript"
run_ort $component 'npm' $component_output_dir
else
echo "Error: Component $component does not contain a supported build system"
exit 1
fi

(cd $script_dir/attribution && yarn start $component_output_dir $component_dir/ATTRIBUTION.md)

Expand Down

0 comments on commit efee0f7

Please sign in to comment.