You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

create_ota.sh 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. #
  3. # Script to prepare an update.zip containing F-Droid
  4. set -e
  5. PROG_DIR=$(dirname $(realpath $0))
  6. TMP_DIR=$(mktemp -d -t fdroidclient.tmp.XXXXXXXX)
  7. trap "rm -rf $TMP_DIR" EXIT
  8. function error() {
  9. echo "*** ERROR: " $@
  10. usage
  11. }
  12. function usage() {
  13. cat << EOFU
  14. Usage: $0 variant
  15. where:
  16. - variant is one of: debug, release, or binary
  17. EOFU
  18. exit 1
  19. }
  20. # Parse input
  21. VARIANT="$1"
  22. [[ -z "$VARIANT" ]] && error "Missing variant"
  23. VERSIONCODE=$2
  24. GPG="gpg --keyring $PROG_DIR/f-droid.org-signing-key.gpg --no-default-keyring --trust-model always"
  25. GITVERSION=$(git describe --tags --always)
  26. FDROID_APK=F-Droid.apk
  27. # Collect files
  28. mkdir -p $TMP_DIR/META-INF/com/google/android/
  29. cp app/src/main/scripts/update-binary $TMP_DIR/META-INF/com/google/android/
  30. if [ $VARIANT == "binary" ] ; then
  31. if [ -z $VERSIONCODE ]; then
  32. curl -L https://f-droid.org/$FDROID_APK > $TMP_DIR/$FDROID_APK
  33. curl -L https://f-droid.org/${FDROID_APK}.asc > $TMP_DIR/${FDROID_APK}.asc
  34. else
  35. GITVERSION=$VERSIONCODE
  36. DL_APK=org.fdroid.fdroid_${VERSIONCODE}.apk
  37. curl -L https://f-droid.org/repo/$DL_APK > $TMP_DIR/$FDROID_APK
  38. curl -L https://f-droid.org/repo/${DL_APK}.asc > $TMP_DIR/${FDROID_APK}.asc
  39. fi
  40. $GPG --verify $TMP_DIR/${FDROID_APK}.asc
  41. rm $TMP_DIR/${FDROID_APK}.asc
  42. else
  43. cd $PROG_DIR
  44. ./gradlew assemble$(echo $VARIANT | tr 'dr' 'DR')
  45. OUT_DIR=$PROG_DIR/app/build/outputs/apk
  46. if [ $VARIANT == "debug" ]; then
  47. cp $OUT_DIR/app-${VARIANT}.apk \
  48. $TMP_DIR/$FDROID_APK
  49. elif [ -f $OUT_DIR/app-${VARIANT}-signed.apk ]; then
  50. cp $OUT_DIR/app-${VARIANT}-signed.apk \
  51. $TMP_DIR/$FDROID_APK
  52. else
  53. cp $OUT_DIR/app-${VARIANT}-unsigned.apk \
  54. $TMP_DIR/$FDROID_APK
  55. fi
  56. fi
  57. # Make zip
  58. if [ $VARIANT == "binary" ] ; then
  59. ZIPBASE=F-DroidFromBinaries-${GITVERSION}
  60. else
  61. ZIPBASE=F-Droid-${GITVERSION}
  62. fi
  63. if [ $VARIANT == "debug" ]; then
  64. ZIP=${ZIPBASE}-debug.zip
  65. else
  66. ZIP=${ZIPBASE}.zip
  67. fi
  68. OUT_DIR=$PROG_DIR/app/build/distributions
  69. mkdir -p $OUT_DIR
  70. [ -f $OUT_DIR/$ZIP ] && rm -f $OUT_DIR/$ZIP
  71. pushd $TMP_DIR
  72. zip -r $OUT_DIR/$ZIP .
  73. popd