macos: handle shutdown & first release run copy dev profile if none
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2021-09-10 16:34:43 -07:00
parent c172a814bf
commit 7de7e36e99
4 changed files with 40 additions and 8 deletions

View File

@ -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.home.sh` installs the app into your home directory
- `install.sys.sh` as root to install system wide - `install.sys.sh` as root to install system wide
- or run out of the unziped directory - 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 ## 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. 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/`. By default a development version is built, which loads profiles from `$CWTCH_HOME/dev/`. This is so that you can build
To build a release version and load normal profiles, add something like the and test development builds with alternative profiles while running a release/stable version of Cwtch uninterrupted.
following to the `flutter build` commands below: To build a release version and load normal profiles, use `build-release.sh X` instead of `flutter build X`
```
--dart-define BUILD_VER="`git describe --tags --abbrev=1`" --dart-define BUILD_DATE="`date +%G-%m-%d-%H-%M`"
```
### Building on Linux (for Linux) ### Building on Linux (for Linux)

20
build-release.sh Executable file
View File

@ -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

View File

@ -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) { if (EnvironmentConfig.BUILD_VER == dev_version) {
cwtchDir = path.join(cwtchDir, "dev"); cwtchDir = path.join(cwtchDir, "dev");
} }

View File

@ -156,7 +156,7 @@ class FlwtchState extends State<Flwtch> {
Future.delayed(Duration(seconds: 2)).then((value) { Future.delayed(Duration(seconds: 2)).then((value) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
SystemNavigator.pop(); SystemNavigator.pop();
} else if (Platform.isLinux || Platform.isWindows) { } else if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
print("Exiting..."); print("Exiting...");
exit(0); exit(0);
} }