#!/usr/bin/env bash set -e USER_HOME=$(realpath ~) if [ -z "$XDG_DATA_HOME" ]; then XDG_DATA_HOME="$USER_HOME/.local/share" fi DATA_DIR="$XDG_DATA_HOME/breezy_gnome" # create a string to string mapping, file name to expected file location declare -A file_paths file_paths=( ["build/driver_air_glasses/manifest"]="$USER_HOME/.local/bin/xr_driver/manifest" ["breezydesktop@xronlinux.com"]="$XDG_DATA_HOME/gnome-shell/extensions/breezydesktop@xronlinux.com" ) # verify the file hashes in ./manifest while IFS= read -r line do # split the line into hash and filename manifest_hash=$(echo $line | awk '{print $1}') file=$(echo $line | awk '{print $2}') actual_file_path=${file_paths[$file]} # check if the file path is a directory if [ -d "$actual_file_path" ]; then # compute the SHA256 hash of the directory contents pushd $actual_file_path > /dev/null actual_hash=$(find -L . -type f ! -name "*.compiled" -exec sha256sum {} \; | sort | sha256sum | sed 's/ .*//') popd > /dev/null else # compute the SHA256 hash of the actual file actual_hash=$(sha256sum $actual_file_path | awk '{print $1}') fi # compare the hashes if ! [ "$manifest_hash" = "$actual_hash" ]; then echo "Verification failed" >&2 exit 1 fi done < "$XDG_DATA_HOME/breezy_gnome/manifest" # if our checks succeeded, run the xr_driver verify script $USER_HOME/.local/bin/xr_driver/verify_installation > /dev/null echo "Verification succeeded"