Merge branch 'ivory-header-build' (#1907)

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

Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
Jared Tobin 2019-11-03 22:05:53 +08:00
commit e59ee780de
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4

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