From 3f54304a101c37007d99942494983e2db4ab5801 Mon Sep 17 00:00:00 2001
From: manongjohn <19245851+manongjohn@users.noreply.github.com>
Date: Thu, 9 Jun 2022 08:13:14 -0400
Subject: [PATCH] Prompt for macOS stuff installation path
---
.gitattributes | 1 +
toonz/installer/osx/app.rb | 4 +++-
.../osx/scripts/getStuffFolderLocation.scpt | 3 +++
toonz/installer/osx/scripts/pkg-script.sh | 9 -------
.../osx/scripts/postinstall-script.sh | 24 +++++++++++++++++++
.../osx/scripts/preinstall-script.sh | 2 ++
6 files changed, 33 insertions(+), 10 deletions(-)
create mode 100644 toonz/installer/osx/scripts/getStuffFolderLocation.scpt
delete mode 100755 toonz/installer/osx/scripts/pkg-script.sh
create mode 100644 toonz/installer/osx/scripts/postinstall-script.sh
create mode 100644 toonz/installer/osx/scripts/preinstall-script.sh
diff --git a/.gitattributes b/.gitattributes
index f3c14f13..61b7a613 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,3 @@
*.lib filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
+*.scpt filter=lfs diff=lfs merge=lfs -text
diff --git a/toonz/installer/osx/app.rb b/toonz/installer/osx/app.rb
index 201076a5..7357f74f 100755
--- a/toonz/installer/osx/app.rb
+++ b/toonz/installer/osx/app.rb
@@ -40,8 +40,10 @@ exec_with_assert "cp -r #{APP_BUNDLE} #{VIRTUAL_ROOT}/#{APP}"
PKG_PLIST = "#{BUILD_DIR}/app.plist"
unless File.exist? PKG_PLIST then
exec_with_assert "pkgbuild --root #{VIRTUAL_ROOT} --analyze #{PKG_PLIST}"
+ exec_with_assert "gsed -i -e \"14i BundlePreInstallScriptPath\" #{PKG_PLIST}"
+ exec_with_assert "gsed -i -e \"15i preinstall-script.sh\" #{PKG_PLIST}"
exec_with_assert "gsed -i -e \"14i BundlePostInstallScriptPath\" #{PKG_PLIST}"
- exec_with_assert "gsed -i -e \"15i pkg-script.sh\" #{PKG_PLIST}"
+ exec_with_assert "gsed -i -e \"15i postinstall-script.sh\" #{PKG_PLIST}"
end
# Preparing stuff
diff --git a/toonz/installer/osx/scripts/getStuffFolderLocation.scpt b/toonz/installer/osx/scripts/getStuffFolderLocation.scpt
new file mode 100644
index 00000000..84b71134
--- /dev/null
+++ b/toonz/installer/osx/scripts/getStuffFolderLocation.scpt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3719efe7269e2dd0d3842242fbb09aab58a391d01603e898ac224012fd1607a0
+size 3476
diff --git a/toonz/installer/osx/scripts/pkg-script.sh b/toonz/installer/osx/scripts/pkg-script.sh
deleted file mode 100755
index c04678d2..00000000
--- a/toonz/installer/osx/scripts/pkg-script.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-STUFF_DIR="Tahoma2D_stuff"
-tar xzvf stuff.tar.bz2
-mv stuff $STUFF_DIR
-mkdir /Applications/Tahoma2D
-cp -nr $STUFF_DIR /Applications/Tahoma2D
-chmod -R 777 /Applications/Tahoma2D
-rm -rf $STUFF_DIR
-
diff --git a/toonz/installer/osx/scripts/postinstall-script.sh b/toonz/installer/osx/scripts/postinstall-script.sh
new file mode 100644
index 00000000..aeafaa4a
--- /dev/null
+++ b/toonz/installer/osx/scripts/postinstall-script.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+INIFILE=/Applications/Tahoma2D.app/Contents/Resources/SystemVar.ini
+STUFF_DIR="/Applications/Tahoma2D/Tahoma2D_stuff"
+if [ -f tahoma2dstuffdirloc ]
+then
+ STUFF_DIR=`cat tahoma2dstuffdirloc`
+fi
+
+tar xzvf stuff.tar.bz2
+
+if [ ! -f $STUFF_DIR ]
+then
+ mkdir -p $STUFF_DIR
+fi
+
+cp -rf stuff/* $STUFF_DIR/
+rm -rf stuff
+
+chmod -R 777 $STUFF_DIR
+
+xxx=`echo $STUFF_DIR | sed -e"s/\//|/g"`
+sed -e"s/.Applications.*Tahoma2D_stuff/$xxx/" $INIFILE | sed -e"s/|/\//g" >| temp.ini
+sudo mv -f temp.ini $INIFILE
+
diff --git a/toonz/installer/osx/scripts/preinstall-script.sh b/toonz/installer/osx/scripts/preinstall-script.sh
new file mode 100644
index 00000000..c676099c
--- /dev/null
+++ b/toonz/installer/osx/scripts/preinstall-script.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+osascript getStuffFolderLocation.scpt $HOME/Documents/Tahoma2D_stuff
\ No newline at end of file