github.com/google/osv-scalibr@v0.4.1/build_protos.sh (about)

     1  #!/bin/sh
     2  # Copyright 2025 Google LLC
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #      http:#www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  
    17  rm -rf binary/proto/*_go_proto
    18  
    19  # Install and prepare osv-schema protos.
    20  if [ ! -e binary/proto/vulnerability.proto ]; then
    21    OSV_SCHEMA_VERSION="1.7.4"
    22    wget --no-verbose https://github.com/ossf/osv-schema/archive/refs/tags/v$OSV_SCHEMA_VERSION.tar.gz
    23    tar -xf v$OSV_SCHEMA_VERSION.tar.gz
    24    mv osv-schema-$OSV_SCHEMA_VERSION/proto/vulnerability.proto binary/proto/vulnerability.proto
    25    rm -r v$OSV_SCHEMA_VERSION.tar.gz osv-schema-$OSV_SCHEMA_VERSION
    26  fi
    27  
    28  
    29  # Compile protos.
    30  protoc -I=binary --go_out=binary/proto binary/proto/*.proto
    31  
    32  # Clean up.
    33  mv binary/proto/github.com/google/osv-scalibr/binary/proto/* binary/proto/
    34  rm -r binary/proto/github.com binary/proto/vulnerability.proto