opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

hash.sh (369B)


      1 set -e
      2 
      3 if [ "$#" != 4 ] ; then
      4 	echo 'usage: hash.sh repo mode name file' >&2
      5 	exit 2
      6 fi
      7 
      8 repo=$1
      9 mode=$2
     10 name=$3
     11 shift 3
     12 
     13 case "$mode" in
     14 12????)
     15 	hash=$(printf %s "$1" | git -C "$repo" hash-object -w --stdin) ;;
     16 10????)
     17 	hash=$(git -C "$repo" hash-object -w --stdin <"$1") ;;
     18 *)
     19 	echo "invalid mode: $mode"
     20 	exit 1
     21 esac
     22 
     23 printf '%s %s\t%s\n' "$mode" "$hash" "$name"