6 Commits

Author SHA1 Message Date
df4d6a3cca macOS fixes for profiles and launching. Version bump.
More fixes here. First, fixed binary path parsing for profiles,
so you should be able to add a profile on macOS now. Only one
requirement - you should add Quake3-UrT.x86_64 file, which located
inside Urban Terror's application bundle, under Contents/MacOS
directory.

Fixed the way we call Urban Terror on macOS and tested it. Should
work now flawlessly.

Bumped to 0.1.0-beta2, and mac-only release for now.
2016-10-09 17:06:47 +05:00
eaffb1f1ab Oops, wrong removing of wrong import. Now fixed. 2016-10-09 13:27:16 +05:00
c5349ab336 Unused import removed. 2016-10-09 13:25:43 +05:00
f283e93719 One more possible fix. 2016-10-09 13:23:59 +05:00
bbe03c485e Prossible MacOS launch fix. 2016-10-09 13:15:19 +05:00
f793b2f467 Updated macOS build script and some README update. 2016-10-09 03:29:36 +05:00
7 changed files with 84 additions and 22 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,6 @@
# We don't need binaries. # We don't need binaries.
urtrator urtrator
*tar* *tar*
# macOS things
.DS_Store

View File

@@ -47,6 +47,12 @@ URTrator executable contains everything we need. Just download
approriate binary and launch it! :) The only thing is to make approriate binary and launch it! :) The only thing is to make
sure you have GTK2 and sqlite3 installed. sure you have GTK2 and sqlite3 installed.
## Distro-and-OS specific instructions
* [MacOS](/doc/installation/macos/)
* Windows (to be written)
* Nixes: read below.
## Development version ## Development version
URTrator written in Go and GTK2, so you should have them installed. URTrator written in Go and GTK2, so you should have them installed.

View File

@@ -10,5 +10,5 @@
package common package common
const ( const (
URTRATOR_VERSION = "0.1-beta1" URTRATOR_VERSION = "0.1-beta2"
) )

View File

@@ -0,0 +1,25 @@
# MacOS installation
For proper application bundle building you have to:
* Install Homebrew (http://brew.sh)
* Install Golang:
```
brew install go
```
* Install GTK+2:
```
brew install gtk+
```
* Install dylibbundler:
```
brew install dylibbundler
```
* Execute ``make-app.sh`` script from current directory. If everything
went fine - you will see URTrator.app right in this directory.

View File

@@ -32,16 +32,16 @@ if [ $? -ne 0 ]; then
fi fi
echo "Building URTrator..." echo "Building URTrator..."
go build -v github.com/pztrn/urtrator go install -v github.com/pztrn/urtrator
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to build URTrator! Please, create a new bug report at https://github.com/pztrn/urtrator and attach FULL console output!" echo "Failed to build URTrator! Please, create a new bug report at https://github.com/pztrn/urtrator and attach FULL console output!"
exit 1 exit 1
fi fi
echo "Creating app bundle..." echo "Creating app bundle..."
mkdir -p /Applications/URTrator.app/Contents/{MacOS,Library,Resources} mkdir -p URTrator.app/Contents/{MacOS,Framework,Resources}
cp $GOPATH/bin/urtrator /Applications/URTrator.app/Contents/MacOS/ cp $GOPATH/bin/urtrator URTrator.app/Contents/MacOS/
cp $GOPATH/src/github.com/pztrn/urtrator/artwork/urtrator.icns /Applications/URTrator.app/Contents/Resources/ cp $GOPATH/src/github.com/pztrn/urtrator/artwork/urtrator.icns URTrator.app/Contents/Resources/
##################################################################### #####################################################################
# APP BUNDLE INFO.PLIST # APP BUNDLE INFO.PLIST
@@ -53,7 +53,7 @@ INFOPLIST='<?xml version="1.0" encoding="UTF-8"?>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>URTrator</string> <string>URTrator</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>urtrator</string> <string>urtrator.sh</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>name.pztrn.urtrator</string> <string>name.pztrn.urtrator</string>
<key>CFBundleName</key> <key>CFBundleName</key>
@@ -73,20 +73,28 @@ INFOPLIST='<?xml version="1.0" encoding="UTF-8"?>
</dict> </dict>
</plist>' </plist>'
echo ${INFOPLIST} > /Applications/URTrator.app/Contents/Info.plist echo ${INFOPLIST} > URTrator.app/Contents/Info.plist
echo -e '#!/bin/bash\ncd "${0%/*}"\n./urtrator' > ./URTrator.app/Contents/MacOS/urtrator.sh
chmod +x ./URTrator.app/Contents/MacOS/urtrator.sh
##################################################################### #####################################################################
# Libraries works. # Libraries works.
# First iteration - main libraries.
echo "Copying libraries..." echo "Copying libraries..."
LIBS_TO_COPY=$(otool -L urtrator | awk {' print $1 '} | grep "/usr/local") dylibbundler -of -b -x ./URTrator.app/Contents/MacOS/urtrator -d ./URTrator.app/Contents/Framework/ -p @executable_path/../Framework/
for lib in ${LIBS_TO_COPY[@]}; do # Fix shit for dylibbundler. By this moment we should have everything
cp ${lib} /Applications/URTrator.app/Contents/Library # we needed in Framework directory.
for lib in $(ls ./URTrator.app/Contents/Framework); do
libname=$(echo ${lib} | awk -F"/" {' print $NF '}) libname=$(echo ${lib} | awk -F"/" {' print $NF '})
install_name_tool -change ${lib} @executable_path/../Library/${libname} /Applications/URTrator.app/Contents/MacOS/urtrator DEPS=$(otool -L ./URTrator.app/Contents/Framework/${lib} | grep "/usr/local")
for dep in ${DEPS[@]}; do
dep_name=$(echo ${dep} | awk -F"/" {' print $NF '})
install_name_tool -change ${dep} @executable_path/../Framework/${dep_name} ./URTrator.app/Contents/Framework/${libname}
done
done done
echo "Finishing..." echo "Finishing..."
echo "URTrator is ready! Launch from Applications!" echo "URTrator is ready! Copy URTrator.app bundle to Applications and launch it!"

View File

@@ -15,6 +15,7 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"runtime"
"strconv" "strconv"
"strings" "strings"
@@ -88,8 +89,7 @@ func (l *Launcher) Launch(server_profile *datamodels.Server, user_profile *datam
launch_params = append(launch_params, additional_parameters[i]) launch_params = append(launch_params, additional_parameters[i])
} }
} }
if user_profile.Second_x_session == "1" { if runtime.GOOS == "linux" && user_profile.Second_x_session == "1" {
fmt.Println(launch_params)
launch_params = append([]string{launch_bin}, launch_params...) launch_params = append([]string{launch_bin}, launch_params...)
display := l.findFreeDisplay() display := l.findFreeDisplay()
launch_bin, err = exec.LookPath("xinit") launch_bin, err = exec.LookPath("xinit")
@@ -98,7 +98,15 @@ func (l *Launcher) Launch(server_profile *datamodels.Server, user_profile *datam
} }
launch_params = append(launch_params, "--", ":" + display) launch_params = append(launch_params, "--", ":" + display)
} }
fmt.Println(launch_params) if runtime.GOOS == "darwin" {
// On macOS we should not start binary, but application bundle.
// So we will obtain app bundle path.
bundle_path := strings.Split(launch_bin, "/Contents")[0]
// and create special launch string, which involves open.
launch_bin = "/usr/bin/open"
launch_params = append([]string{launch_bin, "-W", bundle_path, "--args"}, launch_params...)
}
fmt.Println(launch_bin, launch_params)
go func() { go func() {
go func() { go func() {
cmd := exec.Command(launch_bin, launch_params...) cmd := exec.Command(launch_bin, launch_params...)

View File

@@ -53,7 +53,7 @@ type OptionsProfile struct {
} }
func (op *OptionsProfile) browseForBinary() { func (op *OptionsProfile) browseForBinary() {
op.f = gtk.NewFileChooserDialog("URTrator - Select Urban Terro binary", op.window, gtk.FILE_CHOOSER_ACTION_OPEN, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) op.f = gtk.NewFileChooserDialog("URTrator - Select Urban Terror binary", op.window, gtk.FILE_CHOOSER_ACTION_OPEN, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
op.f.Response(op.browseForBinaryHelper) op.f.Response(op.browseForBinaryHelper)
op.f.Run() op.f.Run()
} }
@@ -62,6 +62,7 @@ func (op *OptionsProfile) browseForBinaryHelper() {
filename := op.f.GetFilename() filename := op.f.GetFilename()
op.binary_path.SetText(filename) op.binary_path.SetText(filename)
op.f.Destroy() op.f.Destroy()
fmt.Println(filename)
// Check for valid filename. // Check for valid filename.
// ToDo: add more OSes. // ToDo: add more OSes.
@@ -80,10 +81,13 @@ func (op *OptionsProfile) browseForBinaryHelper() {
} }
} }
} else if runtime.GOOS == "darwin" { } else if runtime.GOOS == "darwin" {
// No separate arch thing here, macOS now 64bit only. // Official application: Quake3-UrT.app. Split by it and get second
if len(filename) > 0 && strings.Split(filename, ".")[1] != "app" && strings.Split(filename, ".")[0] != "Quake3-UrT" { // part of string.
if strings.Contains(filename, "Quake3-UrT.app") {
filename = strings.Split(filename, "Quake3-UrT.app")[1]
if len(filename) > 0 && !strings.Contains(strings.Split(filename, ".")[1], "x86_64") && !strings.Contains(strings.Split(filename, ".")[0], "Quake3-UrT") {
fmt.Println("Invalid binary selected!") fmt.Println("Invalid binary selected!")
mbox_string := "Invalid binary selected!\nAccording to your OS, it should be Quake3-UrT.app." mbox_string := "Invalid binary selected!\nAccording to your OS, it should be Quake3-UrT.app/Contents/MacOS/Quake3-UrT.x86_64."
m := gtk.NewMessageDialog(op.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string) m := gtk.NewMessageDialog(op.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
m.Response(func() { m.Response(func() {
m.Destroy() m.Destroy()
@@ -91,6 +95,14 @@ func (op *OptionsProfile) browseForBinaryHelper() {
m.Run() m.Run()
op.binary_path.SetText("") op.binary_path.SetText("")
} }
} else {
mbox_string := "Invalid binary selected!\nAccording to your OS, it should be Quake3-UrT.app/Contents/MacOS/Quake3-UrT.x86_64.\n\nNote, that currently URTrator supports only official binary."
m := gtk.NewMessageDialog(op.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
m.Response(func() {
m.Destroy()
})
m.Run()
}
} }
} }
@@ -177,7 +189,7 @@ func (op *OptionsProfile) Initialize(update bool) {
op.another_x_session.SetTooltipText(another_x_tooltip) op.another_x_session.SetTooltipText(another_x_tooltip)
op.vbox.PackStart(op.another_x_session, false, true, 5) op.vbox.PackStart(op.another_x_session, false, true, 5)
// macOS can't do that :). // macOS can't do that :).
if runtime.GOOS == "darwin" { if runtime.GOOS != "linux" {
op.another_x_session.SetSensitive(false) op.another_x_session.SetSensitive(false)
} }