Skip to content

Commit

Permalink
merge utils scripts into utils.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
odrevet committed Oct 21, 2023
1 parent 74477de commit 7f5564d
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 53 deletions.
14 changes: 6 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@ the image can be created with `bash docker/build_vnc.sh` and run with `bash dock

**Must be run using bash**

In case of errors, exported shell variables in `utils/config.sh` may be set
In case of errors, exported shell variables at the beggining of the script may be adujsted.

* To build the apk: `build.sh`. Android SDK will be downloaded at first run.
* To build the apk: `--build`. Android SDK will be downloaded at first run.

* To signe the apk: `sign.sh`. The keystore included is needed to signe the app, **the password is 123456**
* To sign the apk: `--sign`. Keystore and pass may be passed after this argument, or will defaults to included test keystore

* To install the apk on a phone: `install.sh`.
* To install the apk: `--install`.

A typical session is :
Example:

```bash
bash utils/build.sh
bash utils/sign.sh
bash utils/install.sh
bash utils.sh --build --sign --install
```


Expand Down
72 changes: 72 additions & 0 deletions utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

# Read the buildozer.spec file and extract version and package.domain
APP_VERSION=$(grep "version =" buildozer.spec | awk -F "=" '{print $2}' | tr -d '[:space:]')
APP_NAME=$(grep "package.name =" buildozer.spec | awk -F "=" '{print $2}' | tr -d '[:space:]')

BIN='bin'
ANDROID_SDK_DIR=~/.buildozer/android/platform/android-sdk
PACKAGE=fr.odrevet.$APP_NAME
BUILD_TOOLS_VERSION='34.0.0'
BUILD_TOOLS_DIR=$ANDROID_SDK_DIR/build-tools/$BUILD_TOOLS_VERSION
TARGET_ARCH=arm64-v8a

usage() {
echo "arguments: "
echo "--build"
echo "--sign"
echo "--install"
}

while true; do
action=$1
echo $action
case "$1" in
--build)
shift

buildozer android release
;;
--sign)
shift

if [[ $1 != --* ]]; then
KEYSTORE=$1
shift
else
KEYSTORE=mykeystore.keystore
fi

if [[ $1 != --* ]]; then
PASS=$1
shift
else
PASS=123456
fi

RELEASE_UNSIGNED=$BIN/$APP_NAME-$APP_VERSION-$TARGET_ARCH-release-unsigned.apk
RELEASE_ALIGNED=$BIN/$APP_NAME-aligned-unsigned.apk
OUT=$BIN/$APP_NAME.apk

$BUILD_TOOLS_DIR/zipalign -v -p 4 $RELEASE_UNSIGNED $RELEASE_ALIGNED
$BUILD_TOOLS_DIR/apksigner sign --ks $KEYSTORE --ks-pass pass:"$PASS" --out $OUT $RELEASE_ALIGNED

;;
--install)
shift

$PLATEFORM_TOOLS_DIR=$ANDROID_SDK_DIR/platform-tools
$PLATEFORM_TOOLS_DIR/adb uninstall $PACKAGE
$PLATEFORM_TOOLS_DIR/adb install $BIN/$APP_NAME.apk

;;
--logcat)
shift

$PLATEFORM_TOOLS_DIR=$ANDROID_SDK_DIR/platform-tools
$PLATEFORM_TOOLS_DIR/adb logcat | grep $PACKAGE

;;
*) break ;;
esac
done
3 changes: 0 additions & 3 deletions utils/build.sh

This file was deleted.

8 changes: 0 additions & 8 deletions utils/build_sign_install.sh

This file was deleted.

12 changes: 0 additions & 12 deletions utils/config.sh

This file was deleted.

7 changes: 0 additions & 7 deletions utils/install.sh

This file was deleted.

6 changes: 0 additions & 6 deletions utils/logcat.sh

This file was deleted.

9 changes: 0 additions & 9 deletions utils/sign.sh

This file was deleted.

0 comments on commit 7f5564d

Please # to comment.