nix: fix ivory-header error conditions (detecting lfs pointers)

This commit is contained in:
Joe Bryan 2019-11-01 14:47:57 -07:00
parent f30e1d9993
commit 46934cef17

View File

@ -1,13 +1,6 @@
source $stdenv/setup
set -ex
cleanup () {
echo "done"
}
trap cleanup EXIT
set -e
if ! [ -f "$IVORY" ]; then
echo "$IVORY doesn't exist"
@ -18,16 +11,19 @@ fi
# heuristics to confirm the ivory pill is valid
#
# greater than 10KB
#
if [ $(du -k $IVORY | cut -f1) -gt 10 ]; then
echo "$IVORY is less than 10KB"
fi
# first 7 bytes != "version" (start of an lfs pointer)
#
if [ "$(cat $(IVORY) | head -c 7)" = "version" ]; then
echo "$IVORY starts with 'version'; it's an LFS pointer"
if [ "$(cat "$IVORY" | head -c 7)" = "version" ]; then
echo "$IVORY is an LFS pointer (it starts with 'version')"
echo "to fix, run: git lfs install"
exit 1
fi
# greater than 10KB
#
if ! [ $(du -k "$IVORY" | cut -f1) -gt 10 ]; then
echo "$IVORY is less than 10KB"
exit 1
fi
cat $IVORY > u3_Ivory.pill
@ -37,5 +33,3 @@ mkdir -p $out/include
mv ivory.h $out/include
rm u3_Ivory.pill
set +x