diff --git a/.gitignore b/.gitignore index 4a1b0b559..2229dc22a 100644 --- a/.gitignore +++ b/.gitignore @@ -72,4 +72,5 @@ ios/Pods # Lnd binaries android/lndmobile/Lndmobile.aar -ios/LncMobile/Lndmobile.xcframework \ No newline at end of file +ios/LncMobile/Lndmobile.xcframework +ios/LndMobileLibZipFile \ No newline at end of file diff --git a/fetch-libraries.sh b/fetch-libraries.sh index cd82f5cfb..bc37e22f3 100644 --- a/fetch-libraries.sh +++ b/fetch-libraries.sh @@ -24,34 +24,48 @@ then exit fi -# delete old instances of library files -rm android/lndmobile/$ANDROID_FILE -rm -rf ios/LncMobile/$IOS_FILE +########### +# Android # +########### -# create temp dir -mkdir tmp +if ! echo "$ANDROID_SHA256 android/lndmobile/$ANDROID_FILE" | sha256sum -c -; then + echo "Android library file missing or checksum failed" >&2 -# download LND library files -curl -L $ANDROID_LINK > tmp/$ANDROID_FILE -curl -L $IOS_LINK > tmp/$IOS_FILE.zip + # delete old instance of library file + rm android/lndmobile/$ANDROID_FILE -# check checksums -if ! echo "$ANDROID_SHA256 tmp/$ANDROID_FILE" | sha256sum -c -; then - echo "Android checksum failed" >&2 - exit 1 -fi + # download Android LND library file + curl -L $ANDROID_LINK > android/lndmobile/$ANDROID_FILE -if ! echo "$IOS_SHA256 tmp/$IOS_FILE.zip" | sha256sum -c -; then - echo "iOS checksum failed" >&2 - exit 1 + # check checksum + if ! echo "$ANDROID_SHA256 android/lndmobile/$ANDROID_FILE" | sha256sum -c -; then + echo "Android checksum failed" >&2 + exit 1 + fi fi -# unzip LND library files -unzip tmp/$IOS_FILE.zip -d tmp/ +####### +# iOS # +####### + +if ! echo "$IOS_SHA256 ios/LndMobileLibZipFile/$IOS_FILE.zip" | sha256sum -c -; then + echo "iOS library file missing or checksum failed" >&2 + + # delete old instance of library file + rm ios/LndMobileLibZipFile/$IOS_FILE.zip -# move LND library files into place -mv tmp/$ANDROID_FILE android/lndmobile/$ANDROID_FILE -mv tmp/$IOS_FILE ios/LncMobile/$IOS_FILE + # download iOS LND library file + curl -L $IOS_LINK > ios/LndMobileLibZipFile/$IOS_FILE.zip + + # check checksum + if ! echo "$IOS_SHA256 ios/LndMobileLibZipFile/$IOS_FILE.zip" | sha256sum -c -; then + echo "iOS checksum failed" >&2 + exit 1 + fi +fi + +# delete old instances of library files +rm -rf ios/LncMobile/$IOS_FILE -# delete temp dir -rm -rf tmp \ No newline at end of file +# unzip LND library file +unzip ios/LndMobileLibZipFile/$IOS_FILE.zip -d ios/LncMobile