From 7de7e36e99eb3a315c454f51c4cd56b3dd94bea1 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 10 Sep 2021 16:34:43 -0700 Subject: [PATCH] macos: handle shutdown & first release run copy dev profile if none --- README.md | 11 ++++------- build-release.sh | 20 ++++++++++++++++++++ lib/cwtch/ffi.dart | 15 +++++++++++++++ lib/main.dart | 2 +- 4 files changed, 40 insertions(+), 8 deletions(-) create mode 100755 build-release.sh diff --git a/README.md b/README.md index e0c38d3e..da93bdd1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This README covers build instructions, for information on Cwtch itself please go - `install.home.sh` installs the app into your home directory - `install.sys.sh` as root to install system wide - or run out of the unziped directory -- MacOS: Cwtch.dmg coming soon... +- MacOS: Available from [https://cwtch.im/download/](https://cwtch.im/download/) as a .dmg ## Running @@ -32,12 +32,9 @@ This project uses the flutter `dev` channel, which you will need to switch to: ` Once flutter is set up, run `flutter pub get` from this project folder to fetch dependencies. -By default a development version is built, which loads profiles from `$CWTCH_HOME/dev/`. -To build a release version and load normal profiles, add something like the -following to the `flutter build` commands below: -``` ---dart-define BUILD_VER="`git describe --tags --abbrev=1`" --dart-define BUILD_DATE="`date +%G-%m-%d-%H-%M`" -``` +By default a development version is built, which loads profiles from `$CWTCH_HOME/dev/`. This is so that you can build +and test development builds with alternative profiles while running a release/stable version of Cwtch uninterrupted. +To build a release version and load normal profiles, use `build-release.sh X` instead of `flutter build X` ### Building on Linux (for Linux) diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 00000000..dc3077da --- /dev/null +++ b/build-release.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "build-release.sh [android|linux|macos|windows]" + exit 1 +fi + +if [ -f "VERSION" ]; then + VERSION=`cat VERSION` +else + VERSION=`git describe --tags --abbrev=1` +fi + +if [ -f "BUILDDATE" ]; then + BUILDDATE=`cat BUILDDATE` +else + BUILDDATE=`date +%G-%m-%d-%H-%M` +fi + +flutter build $1 --dart-define BUILD_VER=$VERSION --dart-define BUILD_DATE=$BUILDDATE \ No newline at end of file diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index 8ab357c9..e34915df 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -136,6 +136,21 @@ class CwtchFfi implements Cwtch { } } + // the first Cwtch MacOS release (1.2) accidently was a dev build + // we need to temporarily remedy this for a release or two then delete + // if macOs and release build and no profile and is dev profile + // copy dev profile to release profile + if (Platform.isMacOS && EnvironmentConfig.BUILD_VER != dev_version) { + var devProfileExists = await Directory(path.join(cwtchDir, "dev", "profiles")).exists(); + var releaseProfileExists = await Directory(path.join(cwtchDir, "profiles")).exists(); + if (devProfileExists && !releaseProfileExists) { + print("MacOS one time dev -> release profile migration..."); + await Process.run("cp", ["-r", "-p", path.join(cwtchDir, "dev", "profiles"), cwtchDir]); + await Process.run("cp", ["-r", "-p", path.join(cwtchDir, "dev", "SALT"), cwtchDir]); + await Process.run("cp", ["-r", "-p", path.join(cwtchDir, "dev", "ui.globals"), cwtchDir]); + } + } + if (EnvironmentConfig.BUILD_VER == dev_version) { cwtchDir = path.join(cwtchDir, "dev"); } diff --git a/lib/main.dart b/lib/main.dart index fac0c74e..c0c56d69 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -156,7 +156,7 @@ class FlwtchState extends State { Future.delayed(Duration(seconds: 2)).then((value) { if (Platform.isAndroid) { SystemNavigator.pop(); - } else if (Platform.isLinux || Platform.isWindows) { + } else if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { print("Exiting..."); exit(0); }