aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/installer/assemble.tcl422
-rw-r--r--scripts/installer/config/bg.pngbin0 -> 218806 bytes
-rw-r--r--scripts/installer/config/config.xml27
-rw-r--r--scripts/installer/config/controller.qs5
-rw-r--r--scripts/installer/config/logo.pngbin0 -> 3980 bytes
-rw-r--r--scripts/installer/config/sqlitestudio.icnsbin0 -> 287952 bytes
-rw-r--r--scripts/installer/config/sqlitestudio.icobin0 -> 297966 bytes
-rw-r--r--scripts/installer/config/watermark.pngbin0 -> 218806 bytes
-rwxr-xr-xscripts/linux/compile.sh57
-rwxr-xr-xscripts/linux/create_portable.sh184
-rwxr-xr-xscripts/linux/release.sh37
-rwxr-xr-xscripts/macosx/compile_build_bundle.sh62
-rwxr-xr-xscripts/macosx/create_packages.sh16
-rwxr-xr-xscripts/macosx/release.sh41
-rw-r--r--scripts/win32/compile.tcl55
-rw-r--r--scripts/win32/create_dist_pkg.tcl126
-rw-r--r--scripts/win32/release.tcl30
17 files changed, 1062 insertions, 0 deletions
diff --git a/scripts/installer/assemble.tcl b/scripts/installer/assemble.tcl
new file mode 100644
index 0000000..bb343f8
--- /dev/null
+++ b/scripts/installer/assemble.tcl
@@ -0,0 +1,422 @@
+#!/usr/bin/env tclsh
+
+# tclsh assemble.tcl c:/tmp/installer [--repo]
+
+package require platform
+lassign [split [platform::generic] -] OS ARCH
+
+set cfgFiles {
+ config.xml
+ bg.png
+ logo.png
+ sqlitestudio.icns
+ sqlitestudio.ico
+ watermark.png
+ controller.qs
+}
+
+switch $::OS {
+ "macosx" {
+ set mainPkgFiles {
+ SQLiteStudio.app/Contents/Frameworks/libcoreSQLiteStudio.1.0.0.dylib
+ SQLiteStudio.app/Contents/Frameworks/libguiSQLiteStudio.1.0.0.dylib
+ SQLiteStudio.app/Contents/Frameworks/libsqlite3.0.dylib
+ SQLiteStudio.app/Contents/MacOS/SQLiteStudio
+ SQLiteStudio.app/Contents/MacOS/sqlitestudiocli
+ SQLiteStudio.app/Contents/Resources
+ SQLiteStudio.app/Contents/Info.plist
+ SQLiteStudio.app/Contents/PkgInfo
+ }
+ set qtPkgFiles {
+ SQLiteStudio.app/Contents/Frameworks/QtCore.framework
+ SQLiteStudio.app/Contents/Frameworks/QtGui.framework
+ SQLiteStudio.app/Contents/Frameworks/QtNetwork.framework
+ SQLiteStudio.app/Contents/Frameworks/QtPrintSupport.framework
+ SQLiteStudio.app/Contents/Frameworks/QtScript.framework
+ SQLiteStudio.app/Contents/Frameworks/QtSvg.framework
+ SQLiteStudio.app/Contents/Frameworks/QtWidgets.framework
+ SQLiteStudio.app/Contents/Frameworks/QtXml.framework
+ SQLiteStudio.app/Contents/PlugIns/bearer
+ SQLiteStudio.app/Contents/PlugIns/iconengines
+ SQLiteStudio.app/Contents/PlugIns/imageformats
+ SQLiteStudio.app/Contents/PlugIns/platforms
+ SQLiteStudio.app/Contents/PlugIns/printsupport
+ SQLiteStudio.app/Contents/PlugIns/styles
+ }
+ array set pluginDeps {
+ }
+ }
+ "win32" {
+ set mainPkgFiles {
+ coreSQLiteStudio.dll
+ guiSQLiteStudio.dll
+ sqlite3.dll
+ SQLiteStudio.exe
+ sqlitestudiocli.exe
+ }
+ set qtPkgFiles {
+ iconengines
+ imageformats
+ platforms
+ printsupport
+ styles
+ libeay32.dll
+ libgcc_s_dw2-1.dll
+ libstdc++-6.dll
+ libwinpthread-1.dll
+ qt.conf
+ Qt5Core.dll
+ Qt5Gui.dll
+ Qt5Network.dll
+ Qt5PrintSupport.dll
+ Qt5Script.dll
+ Qt5Svg.dll
+ Qt5Widgets.dll
+ Qt5Xml.dll
+ }
+ array set pluginDeps {
+ ScriptingTcl {
+ tcl86.dll
+ zlib1.dll
+ }
+ DbSqlite2 {
+ sqlite.dll
+ }
+ }
+ }
+ default {
+ set mainPkgFiles {
+ lib/libcoreSQLiteStudio.so
+ lib/libguiSQLiteStudio.so
+ lib/libsqlite3.so
+ sqlitestudio
+ sqlitestudiocli
+ }
+ set qtPkgFiles {
+ iconengines/libqsvgicon.so
+ imageformats/libqgif.so
+ imageformats/libqicns.so
+ imageformats/libqico.so
+ imageformats/ibqjpeg.so
+ imageformats/libqsvg.so
+ imageformats/libqtga.so
+ imageformats/libqtiff.so
+ platforms/libqxcb.so
+ printsupport/libcupsprintersupport.so
+ lib/libQt5Concurrent.so
+ lib/libQt5Core.so
+ lib/libQt5DBus.so
+ lib/libQt5Gui.so
+ lib/libQt5Network.so
+ lib/libQt5PrintSupport.so
+ lib/libQt5Script.so
+ lib/libQt5Svg.so
+ lib/libQt5Widgets.so
+ lib/libQt5XcbQpa.so
+ lib/libQt5Xml.so
+ lib/libicudata.so
+ lib/libicui18n.so
+ lib/libicuuc.so.56
+ }
+ array set pluginDeps {
+ DbSqlite2 {
+ lib/libsqlite.so
+ }
+ }
+ }
+}
+
+proc defineGlobalVars {} {
+ lassign $::argv ::targetDir
+ set ::releaseDate [clock format [clock seconds] -format "%Y-%m-%d"]
+
+ # Version
+ set verFile "../../SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp"
+ set fd [open $verFile r]
+ set ver [lindex [regexp -inline {int\s+sqlitestudioVersion\s*\=\s*(\d+)} [read $fd]] 1]
+ ######################################################################################### VER +1
+ #incr ver
+ set ::sqliteStudioVersion [toVersion $ver]
+ set data [read $fd]
+ close $fd
+
+ switch $::OS {
+ "macosx" {
+ set ::portableDir [file normalize ../../output]
+ set ::finalExecutable "Contents/MacOS/SQLiteStudio"
+ set ::wizardStyle "Mac"
+ set ::initialTargetDir "/Applications/SQLiteStudio.app"
+ set ::libExt "dylib"
+ set ::updateArch "macosx"
+ set ::pluginsDir "SQLiteStudio.app/Contents/PlugIns"
+ set ::libPref "lib"
+ set ::dirsToSkipInPathBeginning 1
+ set qtCoreFile "$::portableDir/SQLiteStudio/SQLiteStudio.app/Contents/Frameworks/QtCore.framework/QtCore"
+ set ::output [file normalize $::targetDir/InstallSQLiteStudio-${::sqliteStudioVersion}]
+ }
+ "win32" {
+ set ::portableDir [file normalize ../../output/portable]
+ set ::finalExecutable "SQLiteStudio.exe"
+ set ::wizardStyle "Modern"
+ set ::initialTargetDir "C:\\Program Files\\SQLiteStudio"
+ set ::libExt "dll"
+ set ::updateArch "windows"
+ set ::pluginsDir "plugins"
+ set ::libPref ""
+ set ::dirsToSkipInPathBeginning 0
+ set qtCoreFile "$::portableDir/SQLiteStudio/Qt5Core.dll"
+ set ::output [file normalize $::targetDir/InstallSQLiteStudio-${::sqliteStudioVersion}.exe]
+ }
+ default {
+ set ::portableDir [file normalize ../../output/portable]
+ set ::finalExecutable "sqlitestudio"
+ set ::wizardStyle "Modern"
+ set ::initialTargetDir "/opt/SQLiteStudio"
+ set ::updateArch "linux"
+ set ::pluginsDir "plugins"
+ set ::libExt "so"
+ set ::libPref "lib"
+ set ::dirsToSkipInPathBeginning 0
+ set qtCoreFile "$::portableDir/SQLiteStudio/lib/libQt5Core.so"
+ set ::output [file normalize $::targetDir/InstallSQLiteStudio-${::sqliteStudioVersion}]
+ }
+ }
+
+ # Qt version
+ set fd [open $qtCoreFile r]
+ chan configure $fd -translation binary -encoding binary
+ set data [read $fd]
+ close $fd
+ set ::qtVer [lindex [regexp -inline -- {Qt\s+(\d\.\d{1,2}\.\d{1,2})} $data] 1]
+ ######################################################################################### VER +1
+ #set ::qtVer 6.0.0
+
+ set ::startApp $::finalExecutable
+
+ # Repository
+ set ::repoDir [file normalize $::targetDir/REPO]
+}
+
+proc toVersion {ver} {
+ return [expr {$ver / 10000}].[expr {$ver / 100 % 100}].[expr {$ver % 100}]
+}
+
+proc mapFile {f props} {
+ set fd [open $f r]
+ set data [read $fd]
+ close $fd
+
+ set data [string map $props $data]
+
+ set fd [open $f w+]
+ puts $fd $data
+ close $fd
+}
+
+proc initDirs {targetDir} {
+ file delete -force $::output $::repoDir $targetDir
+ file mkdir $targetDir $targetDir/config $targetDir/packages
+}
+
+proc archiveContentsOf {dir intoFile} {
+ set cdir [pwd]
+ cd $dir
+ set files [glob *]
+ exec archivegen $intoFile {*}$files
+ file delete -force {*}$files
+ cd $cdir
+}
+
+proc copyFileWithLinks {fromDir toDir file} {
+ set targetFile [file join {*}[lrange [file split $file] $::dirsToSkipInPathBeginning end]]
+ file mkdir [file dirname $toDir/$targetFile]
+ switch -- $::OS {
+ "macosx" {
+ file copy -force $fromDir/$file $toDir/$targetFile
+ set fd [file dirname $fromDir/$file]
+ set td [file dirname $toDir/$targetFile]
+ set fileOnly [lindex [file split $file] end]
+ set filePrefix [lindex [split $fileOnly .] 0]
+ foreach f [glob -nocomplain -tails -directory $fd "${filePrefix}.*.$::libExt"] {
+ file copy -force $fd/$f $td/$f
+ }
+ }
+ "win32" {
+ file copy -force $fromDir/$file $toDir/$targetFile
+ }
+ default {
+ set fd [file dirname $fromDir/$file]
+ set td [file dirname $toDir/$targetFile]
+ set fileOnly [lindex [file split $file] end]
+ foreach f [glob -nocomplain -tails -directory $fd "${fileOnly}*"] {
+ file copy -force $fd/$f $td/$f
+ }
+ }
+ }
+}
+
+proc copyMainPkg {targetDir} {
+ set pkgDir $targetDir/packages/pl.com.salsoft.sqlitestudio
+
+ puts "Copying core app files."
+ file mkdir $pkgDir $pkgDir/meta $pkgDir/data
+ foreach f $::mainPkgFiles {
+ copyFileWithLinks $::portableDir/SQLiteStudio $pkgDir/data $f
+ }
+ file copy ../../SQLiteStudio3/sqlitestudio/package.xml ../../SQLiteStudio3/sqlitestudio/register_file_types.ui ../../SQLiteStudio3/sqlitestudio/installscript.qs $pkgDir/meta/
+
+ file mkdir $pkgDir/data/app_icon
+ file copy ../../SQLiteStudio3/guiSQLiteStudio/img/sqlitestudio.ico $pkgDir/data/app_icon
+ file copy ../../SQLiteStudio3/guiSQLiteStudio/img/sqlitestudio.icns $pkgDir/data/app_icon
+ file copy ../../SQLiteStudio3/guiSQLiteStudio/img/sqlitestudio.svg $pkgDir/data/app_icon
+ file copy ../../SQLiteStudio3/guiSQLiteStudio/img/sqlitestudio_logo.png $pkgDir/data/app_icon/sqlitestudio.png
+
+ mapFile $pkgDir/meta/package.xml [list %VERSION% $::sqliteStudioVersion %DATE% $::releaseDate]
+
+ puts "Compressing core app files."
+ archiveContentsOf $pkgDir/data sqlitestudio.7z
+}
+
+proc copyQtPkg {targetDir} {
+ set pkgDir $targetDir/packages/io.qt
+
+ puts "Copying Qt."
+ file mkdir $pkgDir $pkgDir/meta $pkgDir/data
+ foreach f $::qtPkgFiles {
+ copyFileWithLinks $::portableDir/SQLiteStudio $pkgDir/data $f
+ }
+ file copy ../../SQLiteStudio3/qt_package.xml $pkgDir/meta/package.xml
+
+ mapFile $pkgDir/meta/package.xml [list %VERSION% $::qtVer %DATE% $::releaseDate]
+
+ puts "Compressing Qt."
+ archiveContentsOf $pkgDir/data qt.7z
+}
+
+proc copyConfig {targetDir} {
+ foreach f $::cfgFiles {
+ file copy config/$f $targetDir/config/
+ }
+
+ mapFile $targetDir/config/config.xml [list %SQLITESTUDIO_VERSION% $::sqliteStudioVersion %FINAL_EXECUTABLE% $::finalExecutable \
+ %WIZARD_STYLE% $::wizardStyle %TARGET_DIR% $::initialTargetDir %UPDATE_ARCH% $::updateArch]
+}
+
+proc createOutputBinary {targetDir} {
+ if {$::OS == "macosx"} {
+ puts "Creating installer binary: $::output.dmg"
+ exec binarycreator -f -p $targetDir/packages -c $targetDir/config/config.xml $::output.dmg
+ puts "Creating installer binary: $::output"
+ exec binarycreator -f -p $targetDir/packages -c $targetDir/config/config.xml $::output
+ } else {
+ puts "Creating installer binary: $::output"
+ exec binarycreator -f -p $targetDir/packages -c $targetDir/config/config.xml $::output
+ }
+}
+
+proc createOutputRepo {targetDir} {
+ puts "Creating update repository: $::repoDir"
+ exec repogen -p $targetDir/packages $::repoDir
+}
+
+proc readPluginVersion {path} {
+ set fd [open $path r]
+ set ver [lindex [regexp -inline -- {\"version\"\s*\:\s*(\d+)} [read $fd]] 1]
+ close $fd
+ return [toVersion $ver]
+}
+
+proc collectPlugins {} {
+ set mask "*.$::libExt"
+ set toRemove [expr {[string length $mask] - 1}]
+ set prefToRemove [string length $::libPref]
+
+ set files [glob -tails -directory $::portableDir/SQLiteStudio/$::pluginsDir $mask]
+ set ::plugins [list]
+ foreach f $files {
+ set plugin [string range $f $prefToRemove end-$toRemove]
+ set ver [readPluginVersion ../../Plugins/$plugin/[string tolower $plugin].json]
+ ######################################################################################### VER +1
+ #set ver 9.9.9
+ lappend ::plugins [dict create name $plugin version $ver]
+ }
+}
+
+proc readPluginPkgName {path} {
+ set fd [open $path r]
+ set pkg [lindex [regexp -inline -- {\<Name\>(.*)\<\/Name\>} [read $fd]] 1]
+ close $fd
+ return $pkg
+}
+
+proc copyPluginPkg {pluginDict targetDir} {
+ set name [dict get $pluginDict name]
+ set ver [dict get $pluginDict version]
+ set packageXml ../../Plugins/$name/package.xml
+
+ if {![file exists $packageXml]} {
+ puts "Skipping plugin $name, because package.xml for this plugin does not exist."
+ return
+ }
+
+ set pkgName [readPluginPkgName $packageXml]
+ set pkgDir $targetDir/packages/$pkgName
+
+ set targetPluginsDir [file join {*}[lrange [file split $::pluginsDir] $::dirsToSkipInPathBeginning end]]
+
+ puts "Copying plugin: $name ($ver)"
+ file mkdir $pkgDir $pkgDir/meta $pkgDir/data $pkgDir/data/$targetPluginsDir
+ file copy -force $::portableDir/SQLiteStudio/$::pluginsDir/$::libPref${name}.$::libExt $pkgDir/data/$targetPluginsDir/
+ if {[info exists ::pluginDeps($name)]} {
+ foreach f $::pluginDeps($name) {
+ copyFileWithLinks $::portableDir/SQLiteStudio $pkgDir/data $f
+ }
+ }
+ file copy $packageXml $pkgDir/meta/
+
+ mapFile $pkgDir/meta/package.xml [list %VERSION% $ver %DATE% $::releaseDate]
+
+ puts "Compressing $name."
+ archiveContentsOf $pkgDir/data $name.7z
+}
+
+proc copyPluginPkgs {targetDir} {
+ set packageXml ../../Plugins/package.xml
+ set pluginsPkg $targetDir/packages/pl.com.salsoft.sqlitestudio.plugins
+ file mkdir $pluginsPkg $pluginsPkg/data $pluginsPkg/meta
+ file copy $packageXml $pluginsPkg/meta/
+ mapFile $pluginsPkg/meta/package.xml [list %DATE% $::releaseDate]
+
+ foreach p $::plugins {
+ copyPluginPkg $p $targetDir
+ }
+}
+
+if {$argc < 1 || $argc > 2} {
+ puts stderr "Usage: $argv0 <installer output dir> \[--repo]"
+ exit 1
+}
+
+if {[catch {exec archivegen --help} res] && [string first "Usage: archivegen" $res] == -1} {
+ puts stderr "archivegen (QtIFW) missing in PATH."
+ exit 1
+}
+
+defineGlobalVars
+
+if {![file exists $::portableDir]} {
+ puts stderr "[file normalize $::portableDir] does not exist"
+ exit 1
+}
+
+collectPlugins
+initDirs $targetDir
+copyConfig $targetDir
+copyMainPkg $targetDir
+copyQtPkg $targetDir
+copyPluginPkgs $targetDir
+createOutputBinary $targetDir
+
+if {$argc >= 2 && [lindex $argv 1] == "--repo"} {
+ createOutputRepo $targetDir
+}
diff --git a/scripts/installer/config/bg.png b/scripts/installer/config/bg.png
new file mode 100644
index 0000000..9140aa2
--- /dev/null
+++ b/scripts/installer/config/bg.png
Binary files differ
diff --git a/scripts/installer/config/config.xml b/scripts/installer/config/config.xml
new file mode 100644
index 0000000..f52ba25
--- /dev/null
+++ b/scripts/installer/config/config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<Installer>
+ <Name>SQLiteStudio</Name>
+ <Version>%SQLITESTUDIO_VERSION%</Version>
+ <Title>SQLiteStudio Setup</Title>
+ <Publisher>SalSoft</Publisher>
+ <ProductUrl>http://sqlitestudio.pl</ProductUrl>
+ <InstallerWindowIcon>sqlitestudio</InstallerWindowIcon>
+ <InstallerApplicationIcon>sqlitestudio</InstallerApplicationIcon>
+ <Logo>logo.png</Logo>
+ <Background>bg.png</Background>
+ <RunProgram>@TargetDir@/%FINAL_EXECUTABLE%</RunProgram>
+ <RunProgramArguments>
+ </RunProgramArguments>
+ <RunProgramDescription>Run SQLiteStudio</RunProgramDescription>
+ <StartMenuDir>SQLiteStudio</StartMenuDir>
+ <MaintenanceToolName>UpdateSQLiteStudio</MaintenanceToolName>
+ <AllowNonAsciiCharacters>true</AllowNonAsciiCharacters>
+ <WizardStyle>%WIZARD_STYLE%</WizardStyle>
+ <TargetDir>%TARGET_DIR%</TargetDir>
+ <ControlScript>controller.qs</ControlScript>
+ <RemoteRepositories>
+ <Repository>
+ <Url>http://sqlitestudio.pl/update-repo/%UPDATE_ARCH%/</Url>
+ </Repository>
+ </RemoteRepositories>
+</Installer> \ No newline at end of file
diff --git a/scripts/installer/config/controller.qs b/scripts/installer/config/controller.qs
new file mode 100644
index 0000000..839c499
--- /dev/null
+++ b/scripts/installer/config/controller.qs
@@ -0,0 +1,5 @@
+function Controller() {
+ if (installer.isInstaller()) {
+ installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
+ }
+}
diff --git a/scripts/installer/config/logo.png b/scripts/installer/config/logo.png
new file mode 100644
index 0000000..f125df8
--- /dev/null
+++ b/scripts/installer/config/logo.png
Binary files differ
diff --git a/scripts/installer/config/sqlitestudio.icns b/scripts/installer/config/sqlitestudio.icns
new file mode 100644
index 0000000..70ac0cd
--- /dev/null
+++ b/scripts/installer/config/sqlitestudio.icns
Binary files differ
diff --git a/scripts/installer/config/sqlitestudio.ico b/scripts/installer/config/sqlitestudio.ico
new file mode 100644
index 0000000..0aef62d
--- /dev/null
+++ b/scripts/installer/config/sqlitestudio.ico
Binary files differ
diff --git a/scripts/installer/config/watermark.png b/scripts/installer/config/watermark.png
new file mode 100644
index 0000000..9140aa2
--- /dev/null
+++ b/scripts/installer/config/watermark.png
Binary files differ
diff --git a/scripts/linux/compile.sh b/scripts/linux/compile.sh
new file mode 100755
index 0000000..eff0b04
--- /dev/null
+++ b/scripts/linux/compile.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+set -e
+
+if [ "$1" == "" ]; then
+ QMAKE=`which qmake`
+ if [ "$QMAKE" == "" ]; then
+ echo "Cannot find qmake"
+ exit 1
+ else
+ read -p "Is this correct qmake (y/N) $QMAKE : " yn
+ case $yn in
+ [Yy]* ) ;;
+ * ) echo "Please pass path to correct qmake as argument to this script."; exit;;
+ esac
+ fi
+else
+ QMAKE=$1
+fi
+
+cdir=`pwd`
+cpu_cores=`grep -c ^processor /proc/cpuinfo`
+absolute_path=`realpath $0`
+this_dir=`dirname $absolute_path`
+this_dir=`dirname $this_dir`
+parent_dir=`dirname $this_dir`
+
+if [ "$2" == "" ]; then
+ read -p "Number of CPU cores to use for compiling (hit enter to use $cpu_cores): " new_cpu_cores
+ case $new_cpu_cores in
+ "" ) ;;
+ * ) cpu_cores=$new_cpu_cores ;;
+ esac
+else
+ cpu_cores=$2
+fi
+
+if [ -d $parent_dir/output ]; then
+ read -p "Directory $parent_dir/output already exists. The script will delete and recreate it. Is that okay? (y/N) : " yn
+ case $yn in
+ [Yy]* ) rm -rf $parent_dir/output ;;
+ * ) echo "Aborted."; exit;;
+ esac
+fi
+
+cd $parent_dir
+mkdir output output/build output/build/Plugins
+
+cd output/build
+$QMAKE CONFIG+=portable ../../SQLiteStudio3
+make -j $cpu_cores
+
+cd Plugins
+$QMAKE CONFIG+=portable ../../../Plugins
+make -j $cpu_cores
+
+cd $cdir
diff --git a/scripts/linux/create_portable.sh b/scripts/linux/create_portable.sh
new file mode 100755
index 0000000..b3b2d52
--- /dev/null
+++ b/scripts/linux/create_portable.sh
@@ -0,0 +1,184 @@
+#!/bin/bash
+
+# echo "$0 <sqlitestudio build output directory> <qmake path> [tgz|dist|dist_full]"
+
+if [ "$1" == "" ]; then
+ QMAKE=`which qmake`
+ if [ $QMAKE == "" ]; then
+ echo "Cannot find qmake"
+ else
+ read -p "Is this correct qmake (y/N) $QMAKE : " yn
+ case $yn in
+ [Yy]* ) ;;
+ * ) echo "Please pass path to correct qmake as argument to this script."; exit;;
+ esac
+ fi
+else
+ QMAKE=$1
+fi
+
+which chrpath >/dev/null
+if [ "$?" -ne 0 ]; then
+ echo "chrpath program missing!"
+ exit 1
+fi
+
+qt_paths_bin="${QMAKE/qmake/qtpaths}"
+$qt_paths_bin -v >/dev/null 2>&1
+if [ "$?" -ne 0 ]; then
+ echo "qtpaths program missing!"
+ exit 1
+fi
+
+OUTPUT=`pwd`/../../output
+
+cd $OUTPUT
+
+required_modules="libQt5Core.so libQt5Concurrent.so libQt5DBus.so libQt5Gui.so libQt5Network.so libQt5PrintSupport.so libQt5Script.so libQt5Widgets.so libQt5Xml.so \
+ libQt5Svg.so libQt5XcbQpa.so"
+required_plugins="platforms/libqxcb.so imageformats/libqgif.so imageformats/libqicns.so imageformats/libqico.so imageformats/libqjpeg.so \
+ imageformats/libqsvg.so imageformats/libqtga.so imageformats/libqtiff.so iconengines/libqsvgicon.so printsupport/libcupsprintersupport.so"
+optional_plugins="platformthemes/libqgtk3.so"
+
+qt_lib_dir=`ldd SQLiteStudio/sqlitestudio | grep libQt5Core | awk '{print $3;}'`
+qt_lib_dir=`dirname $qt_lib_dir`
+qt_plugins_dir=`$qt_paths_bin --plugin-dir`
+
+# Create portable dir to store distribution in
+rm -rf portable
+mkdir portable
+cd portable
+portable=`pwd`
+
+# Copy all output from compilation here
+cp -R $OUTPUT/SQLiteStudio .
+
+# Make lib directory to move all *.so files (sqlitestudio files and Qt files and dependencies)
+cd SQLiteStudio
+
+# Copy SQLite libs
+cd $portable/SQLiteStudio
+if [ -f /usr/local/lib/libsqlite3.so.0.8.6 ]; then
+ echo "SQLite3 library exists in /usr/local/lib/. Since this is usually a custom build of SQLite, it's preferred and will be used now."
+ sqlite3_lib=/usr/local/lib/libsqlite3.so.0.8.6
+ sqlite3_lib_target=`ldd $OUTPUT/SQLiteStudio/lib/libcoreSQLiteStudio.so | grep libsqlite | awk '{print $3;}'`
+ cp $sqlite3_lib lib/`basename $sqlite3_lib_target`
+else
+ sqlite3_lib=`ldd $OUTPUT/SQLiteStudio/lib/libcoreSQLiteStudio.so | grep libsqlite | awk '{print $3;}'`
+ cp $sqlite3_lib lib
+fi
+echo "Using SQLite3 library: $sqlite3_lib"
+
+sqlite2_lib=`ldd plugins/libDbSqlite2.so | grep libsqlite | awk '{print $3;}'`
+echo "Using SQLite2 library: $sqlite2_lib"
+cp $sqlite2_lib lib
+strip lib/*libsqlite*
+
+# Copy Qt
+cd $portable/SQLiteStudio/lib
+for module in $required_modules; do
+ if [ ! -f $qt_lib_dir/$module ]; then
+ echo "Required Qt module doesn't exist: $qt_lib_dir/$module"
+ exit 1
+ fi
+ cp -P $qt_lib_dir/$module* .
+
+ for dep_lib in `ldd $qt_lib_dir/$module | grep $qt_lib_dir | awk '{print $3;}'`; do
+ cp -Pu $dep_lib* .
+ done
+done
+
+for lib in `ls *.so`; do
+ chrpath -r \$ORIGIN/lib $lib 2>&1 >/dev/null
+done
+
+# Now copy Qt plugins
+cd $portable/SQLiteStudio
+qt_plugin_dirs=()
+for plugin in $required_plugins; do
+ if [ ! -f $qt_plugins_dir/$plugin ]; then
+ echo "Required Qt plugin doesn't exist: $qt_plugins_dir/$plugin"
+ exit 1
+ fi
+ parts=(${plugin/\// })
+ mkdir ${parts[0]} 2>/dev/null
+ cp -P $qt_plugins_dir/$plugin ${parts[0]}
+
+ # Update rpath in Qt plugins
+ cd ${parts[0]}
+ for lib in `ls *.so`; do
+ chrpath -r \$ORIGIN/../lib $lib 2>&1 >/dev/null
+ done
+ cd ..
+done
+
+for plugin in $optional_plugins; do
+ if [ ! -f $qt_plugins_dir/$plugin ]; then
+ continue
+ fi
+ parts=(${plugin/\// })
+ mkdir ${parts[0]} 2>/dev/null
+ cp -P $qt_plugins_dir/$plugin ${parts[0]}
+
+ # Update rpath in Qt plugins
+ cd ${parts[0]}
+ for lib in `ls *.so`; do
+ chrpath -r \$ORIGIN/../lib $lib 2>&1 >/dev/null
+ done
+ cd ..
+done
+
+cd $portable/SQLiteStudio
+chrpath -r \$ORIGIN/lib sqlitestudio 2>&1 >/dev/null
+chrpath -r \$ORIGIN/lib sqlitestudiocli 2>&1 >/dev/null
+
+cd $portable
+VERSION=`SQLiteStudio/sqlitestudiocli -v | awk '{print $2}'`
+
+# Complete
+echo "Building complete package: sqlitestudio-$VERSION.tar.xz"
+tar cf sqlitestudio-$VERSION.tar SQLiteStudio
+xz -z sqlitestudio-$VERSION.tar
+
+# App
+echo "Building incremental update package: sqlitestudio-$VERSION.tar.gz"
+cp -R SQLiteStudio app
+cd app
+#if [ "$3" == "dist" ]; then
+# rm -rf plugins
+# rm -f lib/libQ*
+# rm -rf iconengines
+# rm -rf imageformats
+# rm -rf platforms
+# rm -rf platformthemes
+# rm -rf printsupport
+# find . -type l -exec rm -f {} \;
+#fi
+rm -f lib/libicu*
+rm -f lib/libsqlite.so.0 ;# this is for SQLite 2
+tar cf sqlitestudio-$VERSION.tar *
+gzip -9 sqlitestudio-$VERSION.tar
+mv sqlitestudio-$VERSION.tar.gz ..
+cd ..
+rm -rf app
+
+
+# Plugins
+mkdir plugins
+SQLiteStudio/sqlitestudio --list-plugins | while read line
+do
+ PLUGIN=`echo $line | awk '{print $1}'`
+ PLUGIN_VER=`echo $line | awk '{print $2}'`
+ if [ -f SQLiteStudio/plugins/lib$PLUGIN.so ]; then
+ echo "Building plugin package: $PLUGIN-$PLUGIN_VER.tar.gz"
+ cp SQLiteStudio/plugins/lib$PLUGIN.so plugins/
+ tar cf $PLUGIN\-$PLUGIN_VER.tar plugins
+ gzip -9 $PLUGIN\-$PLUGIN_VER.tar
+ fi
+ rm -f plugins/*
+done
+rm -rf plugins
+
+echo "Done."
+
+echo "Portable distribution created at: $portable/SQLiteStudio"
diff --git a/scripts/linux/release.sh b/scripts/linux/release.sh
new file mode 100755
index 0000000..c490114
--- /dev/null
+++ b/scripts/linux/release.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+
+TARGET_DIR=/tmp/sqls-installer
+QMAKE=/opt/qt/5.10.0/gcc_64/bin/qmake
+CORES=2
+TMP_DIR=~/tmp/SQLiteStudio
+
+if [ ! -f $QMAKE ]; then
+ echo "qmake at $QMAKE does not exist."
+ exit 1
+fi
+
+OLDDIR=`pwd`
+
+VER=`grep 'static const int sqlitestudioVersion' ../../SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp | egrep -o '[\ 0-9]{2}' | bc | paste -s -d'.'`
+
+rm -rf ../../output
+./compile.sh $QMAKE $CORES
+./create_portable.sh $QMAKE
+cd ../installer
+rm -rf $TARGET_DIR
+tclsh assemble.tcl $TARGET_DIR --repo
+
+rm -rf $TMP_DIR
+$TARGET_DIR/InstallSQLiteStudio-* TargetDir=$TMP_DIR
+
+mv $TMP_DIR $TARGET_DIR/
+cd $TARGET_DIR
+
+tar cf sqlitestudio-$VER.tar SQLiteStudio
+xz -z sqlitestudio-$VER.tar
+rm -rf SQLiteStudio
+echo "Deleted installed app. System is clean."
+
+cd $OLDDIR
diff --git a/scripts/macosx/compile_build_bundle.sh b/scripts/macosx/compile_build_bundle.sh
new file mode 100755
index 0000000..0165ebb
--- /dev/null
+++ b/scripts/macosx/compile_build_bundle.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+if [ "$1" == "" ]; then
+ QMAKE=`which qmake`
+ if [ "$QMAKE" == "" ]; then
+ echo "Cannot find qmake"
+ exit 1
+ else
+ read -p "Is this correct qmake (y/N) $QMAKE : " yn
+ case $yn in
+ [Yy]* ) break;;
+ * ) echo "Please pass path to correct qmake as argument to this script."; exit;;
+ esac
+ fi
+else
+ QMAKE=$1
+fi
+
+realpath() {
+ [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
+}
+
+cdir=`pwd`
+cpu_cores=`sysctl -n hw.logicalcpu`
+absolute_path=`realpath $0`
+this_dir=`dirname $absolute_path`
+parent_dir=`dirname $this_dir`
+parent_dir=`dirname $parent_dir`
+
+if [ "$2" == "" ]; then
+ read -p "Number of CPU cores to use for compiling (hit enter to use $cpu_cores): " new_cpu_cores
+ case $new_cpu_cores in
+ "" ) break;;
+ * ) cpu_cores=$new_cpu_cores; break;;
+ esac
+else
+ cpu_cores=$2
+fi
+
+if [ -d $parent_dir/output ]; then
+ read -p "Directory $parent_dir/output already exists. The script will delete and recreate it. Is that okay? (y/N) : " yn
+ case $yn in
+ [Yy]* ) rm -rf $parent_dir/output; break;;
+ * ) echo "Aborted."; exit;;
+ esac
+fi
+
+cd $parent_dir
+mkdir output output/build output/build/Plugins
+
+cd output/build
+$QMAKE CONFIG+=portable ../../SQLiteStudio3
+make -j $cpu_cores
+
+cd Plugins
+$QMAKE CONFIG+=portable ../../../Plugins
+make -j $cpu_cores
+
+cd ..
+make bundle
+
+cd $cdir
diff --git a/scripts/macosx/create_packages.sh b/scripts/macosx/create_packages.sh
new file mode 100755
index 0000000..5a669b4
--- /dev/null
+++ b/scripts/macosx/create_packages.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+realpath() {
+ [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
+}
+
+cdir=`pwd`
+absolute_path=`realpath $0`
+this_dir=`dirname $absolute_path`
+parent_dir=`dirname $this_dir`
+parent_dir=`dirname $parent_dir`
+cd $parent_dir/output/build
+make pkg
+
+cd ..
+mv SQLiteStudio/*.zip SQLiteStudio/*.dmg .
+cd $cdir
diff --git a/scripts/macosx/release.sh b/scripts/macosx/release.sh
new file mode 100755
index 0000000..2fd3293
--- /dev/null
+++ b/scripts/macosx/release.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+TARGET_DIR=/tmp/sqls-installer
+QMAKE=~/Qt/5.10.0/clang_64/bin/qmake
+TMP_DIR=~/tmp/SQLiteStudio.app
+CORES=3
+RECOMPILE=1
+
+if [ ! -f $QMAKE ]; then
+ echo "qmake at $QMAKE does not exist."
+ exit 1
+fi
+
+OLDDIR=`pwd`
+
+if [ "$RECOMPILE" != "0" ]; then
+ rm -rf ../../output
+ ./compile_build_bundle.sh $QMAKE $CORES
+fi
+./create_packages.sh $QMAKE
+cd ../installer
+rm -rf $TARGET_DIR
+tclsh assemble.tcl $TARGET_DIR --repo
+
+rm -rf $TMP_DIR
+$TARGET_DIR/InstallSQLiteStudio-*.app/Contents/MacOS/Install* TargetDir=$TMP_DIR
+
+mv $TMP_DIR $TARGET_DIR/
+cd $TARGET_DIR
+
+VER=`grep -A 1 ShortVersionString SQLiteStudio.app/Contents/Info.plist | tail -n 1 | egrep -o '([0-9]{1,}\.){1,}[0-9]{1,}'`
+ditto -c -k --keepParent SQLiteStudio.app sqlitestudio-$VER.zip
+hdiutil create SQLiteStudio-$VER-tmp.dmg -ov -volname "SQLiteStudio 3.2.0" -fs HFS+ -srcfolder "SQLiteStudio.app"
+hdiutil convert SQLiteStudio-$VER-tmp.dmg -format UDZO -o SQLiteStudio-$VER.dmg
+
+rm -rf SQLiteStudio-$VER-tmp.dmg
+rm -rf SQLiteStudio.app
+rm -rf $TARGET_DIR/InstallSQLiteStudio-*.app
+echo "Deleted installed app. System is clean."
+
+cd $OLDDIR
diff --git a/scripts/win32/compile.tcl b/scripts/win32/compile.tcl
new file mode 100644
index 0000000..1736e92
--- /dev/null
+++ b/scripts/win32/compile.tcl
@@ -0,0 +1,55 @@
+set cpu_cores $env(NUMBER_OF_PROCESSORS)
+if {$cpu_cores > 1} {
+ incr cpu_cores -1 ;# if more than 1 available, leave 1 for OS to run smoothly
+}
+puts "Using $cpu_cores CPU cores."
+
+if {![catch {exec where /q qmake}]} {
+ set QMAKE [exec where qmake]
+ puts "INFO: Qt's qmake found at $QMAKE"
+} else {
+ puts "ERROR: Cannot find Qt"
+ exit 1
+}
+puts "Using qmake: $QMAKE"
+
+if {![catch {exec where /q mingw32-make}]} {
+ set MAKE [exec where mingw32-make]
+ puts "INFO: MinGW32's make found in $MAKE"
+} else {
+ puts "ERROR: Cannot find MinGW32 \[mingw32-make.exe]"
+ exit 1
+}
+puts "Using make: $MAKE"
+
+set cdir [pwd]
+cd ../..
+set parent_dir [pwd]
+cd $cdir
+puts [pwd]
+
+set output "$parent_dir/output"
+
+file delete -force $output
+
+cd $parent_dir
+file mkdir output output/build output/build/Plugins
+
+proc dt {} {
+ return "\[[clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]\]"
+}
+
+puts "[dt] Compiling core app."
+cd output/build
+exec $QMAKE ../../SQLiteStudio3
+catch {exec $MAKE -j $cpu_cores} res
+puts $res
+
+puts "[dt] Compiling plugins."
+cd Plugins
+exec $QMAKE ../../../Plugins
+catch {exec $MAKE -j $cpu_cores} res
+puts $res
+
+puts "[dt] Compilation finished."
+cd $cdir \ No newline at end of file
diff --git a/scripts/win32/create_dist_pkg.tcl b/scripts/win32/create_dist_pkg.tcl
new file mode 100644
index 0000000..e816cd9
--- /dev/null
+++ b/scripts/win32/create_dist_pkg.tcl
@@ -0,0 +1,126 @@
+set OLDDIR [pwd]
+
+# Find Qt
+if {![catch {exec where /q qmake}]} {
+ set QT_DIR [file dirname [exec where qmake]]
+ puts "INFO: Qt found at $QT_DIR"
+} else {
+ puts "ERROR: Cannot find Qt"
+ exit 1
+}
+
+# Find 7zip
+set USE_ZIP 0
+if {[catch {exec where /q 7z}]} {
+ puts "INFO: No 7z.exe. *.zip packages will not be created, only a runnable distribution."
+} else {
+ set ZIP [exec where 7z]
+ puts "INFO: 7zip found at $ZIP"
+ set USE_ZIP 1
+}
+
+cd $OLDDIR
+cd ../..
+set parent_dir [pwd]
+
+# Clean up
+puts "INFO: Cleaning up..."
+cd $parent_dir/output
+file delete -force portable
+
+# Create a copy
+puts "INFO: Creating a portable distribution"
+file mkdir portable
+file copy SQLiteStudio portable/
+
+# Remove .a files from app dir
+cd portable/SQLiteStudio
+foreach f [glob -nocomplain *.a] {
+ file delete -force $f
+}
+set PORTABLE [pwd]
+
+# Remove .a files from plugins dir
+cd plugins
+foreach f [glob -nocomplain *.a] {
+ file delete -force $f
+}
+
+# Copy Qt files
+cd $QT_DIR
+set QT_LIB_LIST [list Qt5Core Qt5Gui Qt5Network Qt5PrintSupport Qt5Script Qt5Svg Qt5Widgets Qt5Xml libgcc_s_dw2-1 libstdc++-6 libwinpthread-1]
+foreach f $QT_LIB_LIST {
+ file copy "$f.dll" $PORTABLE
+}
+file copy -force qt.conf $PORTABLE
+
+file mkdir $PORTABLE/iconengines $PORTABLE/imageformats $PORTABLE/platforms $PORTABLE/printsupport $PORTABLE/styles
+cd $QT_DIR/../plugins
+
+file copy iconengines/qsvgicon.dll $PORTABLE/iconengines
+file copy platforms/qwindows.dll $PORTABLE/platforms
+file copy styles/qwindowsvistastyle.dll $PORTABLE/styles
+file copy printsupport/windowsprintersupport.dll $PORTABLE/printsupport
+foreach f [list qdds qgif qicns qico qjpeg qsvg qtga qtiff qwbmp] {
+ if {[file exists imageformats/$f.dll]} {
+ file copy imageformats/$f.dll $PORTABLE/imageformats
+ }
+}
+
+# Copy app-specific deps
+cd $parent_dir/../lib
+foreach f [glob -nocomplain *.dll] {
+ file copy $f $PORTABLE
+}
+
+cd $PORTABLE
+set APP_VERSION [lindex [exec sqlitestudiocli --version] 1]
+cd ..
+
+if {$USE_ZIP} {
+ exec $ZIP a -r sqlitestudio-${APP_VERSION}.zip SQLiteStudio
+}
+
+# Incremental package
+puts "INFO: Creating incremental update package"
+cd $PORTABLE/..
+file mkdir incremental
+file copy SQLiteStudio incremental/
+
+cd incremental/SQLiteStudio
+foreach f [concat [glob -nocomplain Qt5*.dll] [glob -nocomplain libgcc*] [glob -nocomplain libstdc*] [glob -nocomplain libwinpthread*]] {
+ file delete -force $f
+}
+foreach f [list iconengines imageformats platforms printsupport plugins] {
+ file delete -force $f
+}
+
+cd $PORTABLE/../incremental
+if {$USE_ZIP} {
+ exec $ZIP a -r sqlitestudio-%APP_VERSION%.zip SQLiteStudio
+}
+
+# Plugin packages
+puts "INFO: Creating plugin updates"
+
+proc preparePlugin {plugin plugin_ver} {
+ if {[file exists plugins/$plugin.dll]} {
+ puts "INFO: Creating plugin update: $plugin ($plugin_ver)"
+ file mkdir ../plugins/$plugin/SQLiteStudio/plugins
+ file copy plugins/$plugin.dll ../plugins/$plugin/SQLiteStudio/plugins
+
+ cd ../plugins/$plugin
+ if {$::USE_ZIP} {
+ exec $::ZIP a -r ../${plugin}-$plugin_ver.zip SQLiteStudio
+ }
+ cd ../../SQLiteStudio
+ }
+}
+
+cd $PORTABLE
+foreach plug [split [exec SQLiteStudio.exe --list-plugins] \n] {
+ preparePlugin {*}$plug
+}
+
+cd $OLDDIR
+puts "INFO: Portable distribution v$APP_VERSION created at $PORTABLE"
diff --git a/scripts/win32/release.tcl b/scripts/win32/release.tcl
new file mode 100644
index 0000000..d513b67
--- /dev/null
+++ b/scripts/win32/release.tcl
@@ -0,0 +1,30 @@
+set TARGET_DIR c:/temp/sqls-installer
+set TMP_DIR c:/temp/SQLiteStudio
+
+set OLDDIR [pwd]
+
+file delete -force ../../output
+puts "Compiling app."
+exec tclsh ./compile.tcl
+puts "Creating portable distro."
+puts [exec tclsh ./create_dist_pkg.tcl]
+
+cd ../../output/portable/SQLiteStudio
+set VER [lindex [exec sqlitestudiocli --version] 1]
+cd $OLDDIR
+
+puts "Generating installator file."
+cd ../installer
+file delete -force $TARGET_DIR
+puts [exec tclsh assemble.tcl $TARGET_DIR --repo]
+
+puts "Installing in temporary location"
+file delete -force $TMP_DIR
+exec $TARGET_DIR/InstallSQLiteStudio-$VER.exe TargetDir=$TMP_DIR
+
+file rename -force $TMP_DIR $TARGET_DIR/
+cd $TARGET_DIR
+
+puts "REMEMBER to zip $TARGET_DIR/SQLiteStudio into sqlitestudio-$VER.zip and uninstall that installation."
+
+cd $OLDDIR