From fb937dfe51b66e66b82adb57cf7bad5b5ccdda67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20De=C3=A1k?= Date: Fri, 24 Jul 2020 02:24:30 +1000 Subject: [PATCH] Work on scripts. --- .../{BuildMacOS.md => BuildDarwin.md} | 0 Scripts/Install/InstallDarwin.sh | 36 ++++++++++++++ Scripts/Install/InstallLinux.sh | 35 ++++++++++++++ Scripts/Install/InstallWindows.ps1 | 48 +++++++++++++++++++ Scripts/Install/PackageListAPT.txt | 26 ++++++++++ Scripts/Install/PackageListChoco.config | 7 +++ .../PackageListPython.txt} | 0 Scripts/Tools/InstallToolsDarwin.sh | 11 ----- Scripts/Tools/InstallToolsLinux.sh | 9 ---- Scripts/Tools/InstallToolsWindows.ps1 | 23 --------- Scripts/Tools/UpdateToolsDarwin.sh | 7 --- Scripts/Tools/UpdateToolsLinux.sh | 5 -- Scripts/Tools/UpdateToolsWindows.ps1 | 14 ------ Scripts/build.py | 2 +- Scripts/install.py | 44 +++++++++-------- Scripts/update.py | 30 ------------ readme.md | 2 +- 17 files changed, 179 insertions(+), 120 deletions(-) rename Documentation/{BuildMacOS.md => BuildDarwin.md} (100%) create mode 100644 Scripts/Install/InstallDarwin.sh create mode 100644 Scripts/Install/InstallLinux.sh create mode 100644 Scripts/Install/InstallWindows.ps1 create mode 100644 Scripts/Install/PackageListAPT.txt create mode 100644 Scripts/Install/PackageListChoco.config rename Scripts/{Tools/ToolRequirements.txt => Install/PackageListPython.txt} (100%) delete mode 100755 Scripts/Tools/InstallToolsDarwin.sh delete mode 100755 Scripts/Tools/InstallToolsLinux.sh delete mode 100644 Scripts/Tools/InstallToolsWindows.ps1 delete mode 100755 Scripts/Tools/UpdateToolsDarwin.sh delete mode 100755 Scripts/Tools/UpdateToolsLinux.sh delete mode 100644 Scripts/Tools/UpdateToolsWindows.ps1 delete mode 100755 Scripts/update.py diff --git a/Documentation/BuildMacOS.md b/Documentation/BuildDarwin.md similarity index 100% rename from Documentation/BuildMacOS.md rename to Documentation/BuildDarwin.md diff --git a/Scripts/Install/InstallDarwin.sh b/Scripts/Install/InstallDarwin.sh new file mode 100644 index 0000000..9618f6c --- /dev/null +++ b/Scripts/Install/InstallDarwin.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +install() { + + sudo xcode-select --install || exit 1 + + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1 + + brew install python git cmake libsodium openssl || exit 1 + + sudo pip3 install -r "${installToolsPath}/PackageListPython.txt" || exit 1 + +} + +upgrade() { + + brew upgrade || exit 1 + + sudo pip3 install -r "${installToolsPath}/PackageListPython.txt" --upgrade || exit 1 + +} + +set -o nounset + +installToolsPath="$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" + +if [ "${1}" = "--upgrade" ] || [ "${1}" = "-u" ]; then + upgrade +elif [ -z "${1}" ]; then + install +else + echo "error: Invalid argument. Use '--upgrade' switch to upgrade packages, or none to install packages." + exit 1 +fi + +exit 0 diff --git a/Scripts/Install/InstallLinux.sh b/Scripts/Install/InstallLinux.sh new file mode 100644 index 0000000..cc5914c --- /dev/null +++ b/Scripts/Install/InstallLinux.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +install() { + + cat "${installToolsPath}/PackageListAPT.txt" | xargs sudo apt-get install -y || exit 1 + + sudo pip3 install -r "${installToolsPath}/PackageListPython.txt" || exit 1 + +} + +upgrade() { + + sudo apt-get upgrade + + cat "${installToolsPath}/PackageListAPT.txt" | xargs sudo apt-get upgrade -y || exit 1 + + sudo pip3 install -r "${installToolsPath}/PackageListPython.txt" --upgrade || exit 1 + +} + +set -o nounset + +installToolsPath="$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" + +if [ "${1}" = "--upgrade" ] || [ "${1}" = "-u" ]; then + upgrade +elif [ -z "${1}" ]; then + install +else + echo "error: Invalid argument. Use '--upgrade' switch to upgrade packages, or none to install packages." + exit 1 +fi + +exit 0 + diff --git a/Scripts/Install/InstallWindows.ps1 b/Scripts/Install/InstallWindows.ps1 new file mode 100644 index 0000000..4d9f0d5 --- /dev/null +++ b/Scripts/Install/InstallWindows.ps1 @@ -0,0 +1,48 @@ +param( [ parameter( mandatory = $false ) ] [ switch ] $upgrade ) + +$installBlock = + { + param( [ string ] $installToolsPath ) + + Set-ExecutionPolicy Bypass -Scope Process -Force + [ System.Net.ServicePointManager ]::SecurityProtocol = [ System.Net.ServicePointManager ]::SecurityProtocol -bor 3072 + iex ( ( New-Object System.Net.WebClient ).DownloadString( 'https://chocolatey.org/install.ps1' ) ) + + $packageListChocoPath = Join-Path -Path $installToolsPath -ChildPath "PackageListChoco.config" + choco install "$packageListChocoPath" + refreshenv + + $packageListPythonPath = Join-Path -Path $installToolsPath -ChildPath "PackageListPython.txt" + pip3 install -r "$packageListPythonPath" + refreshenv + + Write-Host "`nPress any key to continue..." + [ void ][ System.Console ]::ReadKey( $true ) + } + +$upgradeBlock = + { + param( [ string ] $installToolsPath ) + + $packageListChocoPath = Join-Path -Path $installToolsPath -ChildPath "PackageListChoco.config" + choco upgrade all + refreshenv + + $packageListPythonPath = Join-Path -Path $installToolsPath -ChildPath "PackageListPython.txt" + pip3 install -r "$packageListPythonPath" --upgrade + refreshenv + + Write-Host "`nPress any key to continue..." + [ void ][ System.Console ]::ReadKey( $true ) + } + +if ( $upgrade ) + { + Start-Process powershell -Verb runAs -ArgumentList "-command & {$upgradeBlock} '$PSScriptRoot'" + } +else + { + Start-Process powershell -Verb runAs -ArgumentList "-command & {$installBlock} '$PSScriptRoot'" + } + +exit 0 diff --git a/Scripts/Install/PackageListAPT.txt b/Scripts/Install/PackageListAPT.txt new file mode 100644 index 0000000..40d4c0d --- /dev/null +++ b/Scripts/Install/PackageListAPT.txt @@ -0,0 +1,26 @@ +alien +build-essential +build-essential +cmake +cmake +devscripts +g++ +git +libavahi-compat-libdnssd-dev +libcurl4-openssl-dev +libegl1-mesa +libgl1-mesa-glx +libqt5svg5-dev +libsodium-dev +libssl-dev +libsystemd-dev +libx11-dev +make +python3 +python3-pip +python3-setuptools +qtbase5-dev +qtcreator +qtdeclarative5-dev +qttools5-dev +xorg-dev diff --git a/Scripts/Install/PackageListChoco.config b/Scripts/Install/PackageListChoco.config new file mode 100644 index 0000000..990eae8 --- /dev/null +++ b/Scripts/Install/PackageListChoco.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Scripts/Tools/ToolRequirements.txt b/Scripts/Install/PackageListPython.txt similarity index 100% rename from Scripts/Tools/ToolRequirements.txt rename to Scripts/Install/PackageListPython.txt diff --git a/Scripts/Tools/InstallToolsDarwin.sh b/Scripts/Tools/InstallToolsDarwin.sh deleted file mode 100755 index 0e8efa5..0000000 --- a/Scripts/Tools/InstallToolsDarwin.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -scriptPath="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - -xcode-select --install - -/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - -brew install python git cmake libsodium openssl - -sudo pip3 install -r "${scriptPath}/ToolRequirements.txt" diff --git a/Scripts/Tools/InstallToolsLinux.sh b/Scripts/Tools/InstallToolsLinux.sh deleted file mode 100755 index ee00841..0000000 --- a/Scripts/Tools/InstallToolsLinux.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -scriptPath="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - -sudo apt-get update - -sudo apt-get install -y build-essential python3 python3-pip python3-setuptools git cmake build-essential devscripts alien - -sudo pip3 install -r "${scriptPath}/ToolRequirements.txt" diff --git a/Scripts/Tools/InstallToolsWindows.ps1 b/Scripts/Tools/InstallToolsWindows.ps1 deleted file mode 100644 index 4f7da92..0000000 --- a/Scripts/Tools/InstallToolsWindows.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -$scriptBlock = - { - Write-Host "Installing tool..." - - Set-ExecutionPolicy Bypass -Scope Process -Force - [ System.Net.ServicePointManager ]::SecurityProtocol = [ System.Net.ServicePointManager ]::SecurityProtocol -bor 3072 - iex ( ( New-Object System.Net.WebClient ).DownloadString( 'https://chocolatey.org/install.ps1' ) ) - - choco install python3 git - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' - - refreshenv - - pip3 install -r ToolRequirements.txt - - refreshenv - - Write-Host "`nPress any key to continue..." - [ void ][ System.Console ]::ReadKey( $true ) - } - -Start-Process powershell -Verb runAs -ArgumentList $scriptBlock -# Start-Process powershell -ArgumentList $scriptBlock -NoNewWindow diff --git a/Scripts/Tools/UpdateToolsDarwin.sh b/Scripts/Tools/UpdateToolsDarwin.sh deleted file mode 100755 index a529b1e..0000000 --- a/Scripts/Tools/UpdateToolsDarwin.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -scriptPath="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - -brew upgrade - -sudo pip3 install -r "${scriptPath}/ToolRequirements.txt" --upgrade diff --git a/Scripts/Tools/UpdateToolsLinux.sh b/Scripts/Tools/UpdateToolsLinux.sh deleted file mode 100755 index 2ca147a..0000000 --- a/Scripts/Tools/UpdateToolsLinux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -scriptPath="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - -sudo pip3 install -r "${scriptPath}/ToolRequirements.txt" --upgrade diff --git a/Scripts/Tools/UpdateToolsWindows.ps1 b/Scripts/Tools/UpdateToolsWindows.ps1 deleted file mode 100644 index 5e0cfa4..0000000 --- a/Scripts/Tools/UpdateToolsWindows.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -$scriptBlock = - { - choco upgrade all - - pip3 install -r ToolRequirements.txt --upgrade - - refreshenv - - Write-Host "`nPress any key to continue..." - [ void ][ System.Console ]::ReadKey( $true ) - } - -Start-Process powershell -Verb runAs -ArgumentList $scriptBlock -# Start-Process powershell -ArgumentList $scriptBlock -NoNewWindow diff --git a/Scripts/build.py b/Scripts/build.py index 2769dfe..512882e 100755 --- a/Scripts/build.py +++ b/Scripts/build.py @@ -48,7 +48,7 @@ def buildProducts(): scripts = { "Darwin" : "Scripts/Build/BuildDarwin.sh", "Linux" : "Scripts/Build/BuildLinux.sh", - "Windows" : "Scripts/Build/BuildWindows.cmd", + "Windows" : "Scripts\\Build\\BuildWindows.cmd", } scriptPath = utility.joinPath( config.toplevelPath, scripts[ platform.system() ] ) diff --git a/Scripts/install.py b/Scripts/install.py index 6888bbc..dc22662 100755 --- a/Scripts/install.py +++ b/Scripts/install.py @@ -1,30 +1,36 @@ #!/usr/bin/env python3 -import os, platform +import os, platform, sys -print( "Installing tools for platform " + platform.system() ) +arguments = "" -toolsPath = os.path.join( os.path.dirname( os.path.realpath( __file__ ) ), "Tools" ) +if len( sys.argv ) > 1: + if sys.argv[ 1 ] == "--upgrade": + arguments += "--upgrade" + elif sys.argv[ 1 ] == "-u": + arguments += "--upgrade" + else: + print( "error: Invalid argument. Use '--upgrade' switch to upgrade packages, or none to install packages." ) + raise SystemExit( 1 ) -if ( platform.system() == "Darwin" ): +basePath = os.path.dirname( os.path.realpath( __file__ ) ) - command = os.path.join( toolsPath, "InstallToolsDarwin.sh" ) - - os.system( command ) +scripts = { + "Darwin" : "Install/InstallDarwin.sh", + "Linux" : "Install/InstallLinux.sh", + "Windows" : "Install\\InstallWindows.ps1", + } -elif ( platform.system() == "Linux" ): +command = '"' + os.path.join( basePath, scripts[ platform.system() ] ) + '"' - command = os.path.join( toolsPath, "InstallToolsLinux.sh" ) +if platform.system() == "Windows": + command = "powershell.exe -File " + command + arguments = arguments.replace( "--", "-" ) - os.system( command ) +command += ' ' + arguments -elif ( platform.system() == "Windows" ): +print( command ) - command = os.path.join( toolsPath, "InstallToolsWindows.ps1" ) - - os.system( "powershell " + command ) - -else: - - print( "Unrecognised platform: " + platform.system() ) - raise SystemExit( 1 ) +if os.system( command ) != 0: + print( "Command exited with error." ) + raise SystemExit( 1 ) diff --git a/Scripts/update.py b/Scripts/update.py deleted file mode 100755 index e0ed13a..0000000 --- a/Scripts/update.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 - -import os, platform - -print( "Updating tools for platform " + platform.system() ) - -toolsPath = os.path.join( os.path.dirname( os.path.realpath( __file__ ) ), "Tools" ) - -if ( platform.system() == "Darwin" ): - - command = os.path.join( toolsPath, "UpdateToolsDarwin.sh" ) - - os.system( command ) - -elif ( platform.system() == "Linux" ): - - command = os.path.join( toolsPath, "UpdateToolsLinux.sh" ) - - os.system( command ) - -elif ( platform.system() == "Windows" ): - - command = os.path.join( toolsPath, "UpdateToolsWindows.ps1" ) - - os.system( "powershell " + command ) - -else: - - print( "Unrecognised platform: " + platform.system() ) - raise SystemExit( 1 ) diff --git a/readme.md b/readme.md index 79b9434..a819ea5 100644 --- a/readme.md +++ b/readme.md @@ -29,7 +29,7 @@ The information presented here is based on the [official wiki pages](https://git 3. Building the Binaries * [Building on Linux Mint / Ubuntu](./Documentation/BuildLinux.md) - * [Building on macOS](./Documentation/BuildMacOS.md) + * [Building on macOS](./Documentation/BuildDarwin.md) * [Building on Windows](./Documentation/BuildWindows.md) ## Disclaimers and Legal