nix: fix ivory-header error conditions (detecting lfs pointers)
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
+# first 7 bytes != "version" (start of an lfs pointer)
#
-if [ $(du -k $IVORY | cut -f1) -gt 10 ]; then
- echo "$IVORY is less than 10KB"
+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
-# first 7 bytes != "version" (start of an lfs pointer)
+# greater than 10KB
#
-if [ "$(cat $(IVORY) | head -c 7)" = "version" ]; then
- echo "$IVORY starts with 'version'; it's an LFS pointer"
+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
