#!/bin/sh
#
# Shell script that generates the list of checksums and sizes
# for bootstrap.txt.
#
# Copyright (C) 2019, 2020  Pim Goossens
# See the README and COPYING files for details and license information.

FILES='asterix asterix-asm elfwrap'

die() {
	echo "$0: $*" >&2
	exit 1
}

p() {
	printf "%-12s %s\n" "$1" "$2"
}

for f in $FILES; do
	[ -x "$f" ] || die "Need to build binaries first"
done

echo 'Binary       Size (in bytes)'
echo '-----------  ---------------'
ls -l $FILES | while read rwx links user group size d1 d2 d3 file; do
	p "$file" "$size"
done

echo

echo 'Binary       SHA256 checksum'
echo '-----------  ----------------------------------------------------------------'
sha256sum $FILES | while read sum file; do
	p "$file" "$sum"
done

echo

echo 'Binary       RIPEMD160 checksum'
echo '-----------  ----------------------------------------'
openssl rmd160 $FILES | while read x sum; do
	file=${x#RIPEMD160(}
	file=${file%)=}
	p "$file" "$sum"
done
