coatless-mac/r-macos-rtools

Verify pkg hash

coatless opened this issue · 0 comments

Per Simon's e-mail on R-SIG-MAC, we're going to implement a check that verifies the md5 hash of the file.

Sample function:

#1 Path to File
#2 md5 Hash to Check Against
check_md5_hash() {
	
    # Obtain file hash
    FILE_HASH=$(md5 $1 | awk '{print $4}')
    
    # MD5 (path/to/file.pkg) = c29700c4e7b2914073ef7e741eb105bc
    #  1 %         2        %3%      4 
     
    # Check against hash
    if [ "$FILE_HASH" = "$2" ]; then
       echo 0
    else 
       exit 1
    fi
}

Hard coded hashes: