2022-09-09 14:01:51 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-09-09 14:56:49 +00:00
|
|
|
set -o errexit -o pipefail -o noclobber -o nounset -x
|
2022-09-09 13:49:54 +00:00
|
|
|
|
2022-09-09 14:22:36 +00:00
|
|
|
CONTAINER_IMAGE="localhost/flutter-build-env"
|
2022-09-09 15:33:44 +00:00
|
|
|
OPTS=$(getopt -o "" --long "build-linux,build-apk,sign-apk-standalone,sign-apk-fdroid,package-linux-appimage,package-linux-flatpak,package-linux-archive" -- "$@")
|
2022-09-09 13:49:54 +00:00
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo "Usage: $0 [--build-linux] [--build-apk] [--sign-apk-standalone] [--sign-apk-fdroid] [--package-linux-appimage] [--package-linux-flatpak] [--package-linux-archive]" 1>&2; exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
podman_offline () {
|
2022-09-09 15:40:11 +00:00
|
|
|
podman run --rm -v "`pwd`:/var/lib/builder/src" -v "/var/lib/drone-runner-exec/fdroid:/var/lib/builder/repo:U" -v "/var/lib/drone-runner-exec/fdroid-keystore:/var/lib/builder/repo/fdroid-keystore:U" -v "/var/lib/drone-runner-exec/standalone-keystore:/var/lib/builder/repo/standalone-keystore:U" --env FDROID_KEYSTORE_PASS="$FDROID_KEYSTORE_PASS" --env STANDALONE_KEYSTORE_PASS="$STANDALONE_KEYSTORE_PASS" --network=none --workdir $1 "$CONTAINER_IMAGE" $2
|
2022-09-09 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
podman_online () {
|
2022-09-09 15:40:11 +00:00
|
|
|
podman run --rm -v "`pwd`:/var/lib/builder/src" --privileged --workdir $1 "$CONTAINER_IMAGE" $2
|
2022-09-09 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_linux () {
|
2022-09-09 14:51:37 +00:00
|
|
|
podman_offline "/var/lib/builder/src" "flutter pub get --offline"
|
2022-09-09 15:02:49 +00:00
|
|
|
podman_offline "/var/lib/builder/src" "flutter build linux -v"
|
2022-09-09 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_apk () {
|
2022-09-09 14:51:37 +00:00
|
|
|
podman_offline "/var/lib/builder/src" "flutter pub get --offline"
|
2022-09-09 15:02:49 +00:00
|
|
|
podman_offline "/var/lib/builder/src" "flutter build apk -v"
|
2022-09-09 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sign_apk_standalone () {
|
|
|
|
podman_offline "/var/lib/builder/repo" "cp /var/lib/builder/src/build/app/outputs/flutter-apk/app-release.apk ."
|
|
|
|
podman_offline "/var/lib/builder/repo" "zipalign -f -v 4 app-release.apk standalone_app-release.apk"
|
|
|
|
podman_offline "/var/lib/builder/repo" "apksigner sign --ks /var/lib/builder/repo/standalone-keystore --ks-key-alias standalone --ks-pass env:STANDALONE_KEYSTORE_PASS standalone_app-release.apk"
|
|
|
|
}
|
|
|
|
|
|
|
|
sign_apk_fdroid () {
|
|
|
|
podman_offline "/var/lib/builder/repo" "cp /var/lib/builder/src/build/app/outputs/flutter-apk/app-release.apk unsigned/"
|
|
|
|
}
|
|
|
|
|
|
|
|
package_linux_appimage () {
|
|
|
|
podman_online "/var/lib/builder/src" "appimage-builder --recipe appimage.yml"
|
|
|
|
}
|
|
|
|
|
|
|
|
package_linux_flatpak () {
|
|
|
|
podman_online "/var/lib/builder/src" "flatpak-builder --disable-rofiles-fuse --force-clean --repo=flatpak-repo flatpak-build flatpak.yml"
|
|
|
|
podman_online "/var/lib/builder/src" "flatpak build-bundle flatpak-repo selfprivacy.flatpak pro.kherel.selfprivacy"
|
|
|
|
}
|
|
|
|
|
|
|
|
package_linux_archive () {
|
|
|
|
podman_online "/var/lib/builder/src" "tar -C build/linux/x64/release/bundle -vacf selfprivacy.tar.zstd ."
|
|
|
|
}
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
2022-09-09 15:33:44 +00:00
|
|
|
--build-linux )
|
|
|
|
build_linux
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
|
|
|
--build-apk )
|
|
|
|
build_apk
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
|
|
|
--sign-apk-standalone )
|
|
|
|
sign_apk_standalone
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
|
|
|
--sign-apk-fdroid )
|
|
|
|
sign_apk_fdroid
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
|
|
|
--package-linux-appimage )
|
|
|
|
package_linux_appimage
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
|
|
|
--package-linux-flatpak )
|
|
|
|
package_linux_flatpak
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
|
|
|
--package-linux-archive )
|
|
|
|
package_linux_archive
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 13:49:54 +00:00
|
|
|
;;
|
2022-09-09 15:07:52 +00:00
|
|
|
-- )
|
2022-09-09 15:12:57 +00:00
|
|
|
shift
|
2022-09-09 15:07:52 +00:00
|
|
|
break
|
|
|
|
;;
|
2022-09-09 13:49:54 +00:00
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|