• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
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
18# Compute the MD5 sum.
19#
20# Parameter(s):
21#   ${1} - path to the file
22function compute_md5() {
23  UNAME_S=`uname -s`
24  if [ ${UNAME_S} == Linux ]; then
25    tflm_md5sum=md5sum
26  elif [ ${UNAME_S} == Darwin ]; then
27    tflm_md5sum='md5 -r'
28  fi
29  ${tflm_md5sum} ${1} | awk '{print $1}'
30}
31
32# Check that MD5 sum matches expected value.
33#
34# Parameter(s):
35#   ${1} - path to the file
36#   ${2} - expected md5
37function check_md5() {
38  MD5=`compute_md5 ${1}`
39
40  if [[ ${MD5} != ${2} ]]
41  then
42    echo "Bad checksum. Expected: ${2}, Got: ${MD5}"
43    exit 1
44  fi
45
46}
47
48