Skip to content

Commit 2989dc9

Browse files
author
mxklb
committed
Added osx deployment #3
1 parent 953a29b commit 2989dc9

File tree

13 files changed

+180
-52
lines changed

13 files changed

+180
-52
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ script:
2020
- qmake cuteproject.pro -r CONFIG+=debug
2121
- make
2222
after_success:
23+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make distclean ; fi
24+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then echo "catchTests=false" > globals.pri ; fi
25+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then qmake cuteproject.pro -r CONFIG+=release ; fi
26+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make ; fi
27+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then chmod +x pkgs/macOS.sh && pkgs/macOS.sh ; fi
2328
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash <(curl -s https://codecov.io/bash) ; fi

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ This is a C++ qmake project template with automated unit test execution (uses [
1010
[![coverage report](https://gitlab.com/mxklb/cuteproject/badges/master/coverage.svg)](https://gitlab.com/mxklb/cuteproject/builds/artifacts/master/download?job=debug_tests)
1111
[![GitHub license](https://img.shields.io/badge/MIT-license-blue.svg)](https://raw.githubusercontent.com/mxklb/cuteproject/master/LICENSE)
1212

13-
Download latest development package
14-
- [cuteproject.ubuntu14.04_amd64.deb](https://gitlab.com/mxklb/cuteproject/builds/artifacts/master/download?job=deploy_trusty)
15-
- [cuteproject.ubuntu16.04_amd64.deb](https://gitlab.com/mxklb/cuteproject/builds/artifacts/master/download?job=deploy_xenial)
13+
Download latest development version here
14+
- [cuteproject.macOS-10.11.dmg](https://rawgit.com/mxklb/cuteproject/osx-deploy/cuteproject.dmg)
15+
- [cuteproject.ubuntu14.04_amd64.deb](https://gitlab.com/mxklb/cuteproject/builds/artifacts/master/download?job=deploy_trusty)
16+
- [cuteproject.ubuntu16.04_amd64.deb](https://gitlab.com/mxklb/cuteproject/builds/artifacts/master/download?job=deploy_xenial)
1617

17-
Or use this template as a starting point for your personal qmake project.
18+
Feel free to use this template as a starting point for your personal C++ qmake project.
1819

1920
## Build Dependencies
2021
To successfully build on debian based OS:

app/app.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TEMPLATE = app
2-
TARGET = app
2+
TARGET = cuteproject
33

44
CONFIG += console
55
CONFIG += qt
@@ -23,4 +23,4 @@ unix:!macx {
2323
target.files += $$OUT_PWD/$$TARGET
2424
target.path = $$[QT_INSTALL_PREFIX]/bin
2525
INSTALLS += target
26-
}
26+
}

img/cuteproject.svg

Lines changed: 1 addition & 46 deletions
Loading

img/logo.icns

147 KB
Binary file not shown.

img/logo.ico

361 KB
Binary file not shown.

img/logolink.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.google.de/imgres?imgurl=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F8%2F83%2FAntu_preferences-system-performance.svg&imgrefurl=https%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FFile%3AAntu_preferences-system-performance.svg&docid=eoNfDuKdtGlyeM&tbnid=BOZXhYgds_JpjM%3A&vet=10ahUKEwjspqC3h87XAhXHFuwKHbVOBIoQMwiHAShYMFg..i&w=800&h=800&hl=en&safe=images&bih=700&biw=1280&as_q=rocket&ved=0ahUKEwjspqC3h87XAhXHFuwKHbVOBIoQMwiHAShYMFg&iact=mrc&uact=8

pkgs/macOS.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
# This script creates a deployable macOS image (application.dmg)
3+
#
4+
# It moves all custom libs (frameworks) to the app bundle and
5+
# corrects local binary linker-paths accordingly. Finally Qt
6+
# and external libs are copied & linked to Frameworks folder.
7+
#
8+
# Note this script dependes on:
9+
# - otool (to detect custom linked local frameworks)
10+
# - install_name_tool (to correct binary links)
11+
# - macdeployqt (to create a dmg image)
12+
pushd `dirname $0` > /dev/null
13+
scriptPath=`pwd`
14+
popd > /dev/null
15+
cd "$scriptPath"
16+
17+
# Set essentials
18+
binName="cuteproject"
19+
libIdentifier="cuteproject/libs"
20+
21+
# Set some paths
22+
libPath="$scriptPath/../libs"
23+
appPath="$scriptPath/../app/$binName.app"
24+
binPath="$appPath/Contents/MacOS/$binName"
25+
26+
echo "Setup $binName binary dependencies ..."
27+
28+
# Create frameworks directory
29+
mkdir -p $appPath/Contents/Frameworks
30+
31+
# Use otool to grep libIdentifier => to get all custom linked frameworks
32+
linkedLibs=($(otool -L $binPath | grep $libIdentifier | awk '{print $1;}'))
33+
frameworks=($(printf '%s\n' "${linkedLibs[@]}" | rev | cut -d'/' -f 1 | rev))
34+
35+
# Copy frameworks and correct links
36+
libCount=${#linkedLibs[@]}
37+
for ((i=0; i<$libCount; i++)); do
38+
echo " - Preparing ${frameworks[$i]} framework: substitute ${linkedLibs[$i]} with @executable_path"
39+
cp -R $libPath/${frameworks[$i]}/${frameworks[$i]}.framework $appPath/Contents/Frameworks
40+
install_name_tool -id @executable_path/../Frameworks/${frameworks[$i]}.framework/Versions/1/${frameworks[$i]} $appPath/Contents/Frameworks/${frameworks[$i]}.framework/Versions/1/${frameworks[$i]}
41+
install_name_tool -change ${linkedLibs[$i]} @executable_path/../Frameworks/${frameworks[$i]}.framework/Versions/1/${frameworks[$i]} $binPath
42+
done
43+
44+
libBinaries=()
45+
46+
# Correct all internal frameworks links
47+
for ((i=0; i<$libCount; i++)); do
48+
libBinPath="$appPath/Contents/Frameworks/${frameworks[$i]}.framework/Versions/1/${frameworks[$i]}"
49+
dependLibs=($(otool -L $libBinPath | grep $libIdentifier | awk '{print $1;}'))
50+
dependency=($(printf '%s\n' "${dependLibs[@]}" | rev | cut -d'/' -f 1 | rev))
51+
echo "Setup ${frameworks[$i]} framework dependencies ..."
52+
depCount=${#dependLibs[@]}
53+
for ((j=0; j<$depCount; j++)); do
54+
echo " - Preparing ${dependency[$j]} framework: substitute ${dependLibs[$j]} with @executable_path"
55+
install_name_tool -id @executable_path/../Frameworks/${dependency[$j]}.framework/Versions/1/${dependency[$j]} $appPath/Contents/Frameworks/${dependency[$j]}.framework/Versions/1/${dependency[$j]}
56+
install_name_tool -change ${dependLibs[$j]} @executable_path/../Frameworks/${dependency[$j]}.framework/Versions/1/${dependency[$j]} $libBinPath
57+
done
58+
libBinaries+=("-executable=$libBinPath")
59+
done
60+
61+
# Collect binaries for macdeployqt cmd
62+
executables=$(echo "${libBinaries[*]}")
63+
64+
# Create a .dmg image (with Qt libs)
65+
echo "Creating the .dmg disk image ..."
66+
cd "$scriptPath/../app"
67+
macdeployqt "$binName.app" -dmg $executables
68+
69+
# Modify/Optimize .dmg image
70+
chmod +x "$scriptPath/osx/dmg.sh"
71+
$scriptPath/osx/dmg.sh "$scriptPath/../app/$binName.dmg"

pkgs/osx/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# macOS Development Installer
2+
This branch simply contains the latest development DMG package.
3+
4+
Download latest osx development version: [cuteproject.dmg](https://rawgit.com/mxklb/cuteproject/osx-deploy/cuteproject.dmg)

pkgs/osx/background.png

152 KB
Loading

pkgs/osx/deploy.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Deploys (pushes) osx dmg images to the osx-deploy branch.
3+
#
4+
# Note: To be called directly @ travis-ci!
5+
# - Needs $GH_TOKEN to auth git push
6+
# - And $TRAVIS_COMMIT as commit message
7+
8+
pushd `dirname $0` > /dev/null
9+
scriptPath=`pwd`
10+
popd > /dev/null
11+
cd $scriptPath
12+
13+
mkdir dmg
14+
cp $scriptPath/../../app/cuteproject-*.dmg dmg/cuteproject.dmg
15+
cp $scriptPath/travis.yml dmg/.travis.yml
16+
cp $scriptPath/README.md dmg/README.md
17+
cd dmg
18+
19+
git init
20+
git config user.name "travis"
21+
git config user.email "travis@email.com"
22+
git add .
23+
git commit -m "OSX deployment - Pushed @ travis-ci [triggered by $TRAVIS_COMMIT]"
24+
git push --force --quiet "https://${GH_TOKEN}@github.com/mxklb/cuteproject" master:osx-deploy > /dev/null 2>&1

pkgs/osx/dmg.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
# This creates a modified copy of a read-only .dmg file
3+
#
4+
# Modifications applied
5+
# - add /Applications sym-link
6+
# - add a background image
7+
# - add a volume icon
8+
#
9+
# Note: This script uses hdiutil!
10+
if [ "$#" -eq "0" ] ; then
11+
echo "Error: No arguments supplied!"
12+
echo " -> Set path to dmg file (1st argument): dmg.sh ..path/to/app.dmg"
13+
exit 1
14+
fi
15+
16+
pushd `dirname $0` > /dev/null
17+
scriptPath=`pwd`
18+
popd > /dev/null
19+
20+
# Prepare some vars ..
21+
dmgDir=$(echo "$(cd "$(dirname "$1")"; pwd)")
22+
dmgName=$(echo "$(basename "$1")")
23+
dmgFile=$(echo "$dmgDir/$dmgName")
24+
binName="${dmgName%.*}"
25+
tmpImage="$dmgDir/$binName.sparseimage"
26+
if [ ! -f "$dmgFile" ] ; then
27+
echo "Error: $dmgFile file not found!"
28+
exit 1
29+
fi
30+
31+
# Convert existing dmg to an editable temp image
32+
hdiutil convert -ov "$dmgFile" -format UDSP -o "$tmpImage"
33+
34+
# --> Mount temp image to apply modifications
35+
mntDir=$(hdiutil attach "$tmpImage" | awk '{print $NF}' | tail -1)
36+
37+
# 1. Create /Applications link
38+
ln -s /Applications "$mntDir/Applications"
39+
40+
# 2. Add background image
41+
mkdir "$mntDir/.background"
42+
cp "$scriptPath/background.png" "$mntDir/.background/"
43+
44+
# Fix permissions and blessing
45+
chmod -Rf go-w "${mntDir}" &> /dev/null || true
46+
bless --folder "${mntDir}" --openfolder "${mntDir}"
47+
48+
# 3. Add volume icon file
49+
volumeIcon="$scriptPath/../../img/logo.icns"
50+
cp "$volumeIcon" "$mntDir/.VolumeIcon.icns"
51+
SetFile -c icnC "$mntDir/.VolumeIcon.icns"
52+
if ! test -z "$volumeIcon"; then
53+
# tell the volume that it has a special file attribute
54+
SetFile -a C "$mntDir"
55+
fi
56+
57+
# <-- Unmount temp image
58+
hdiutil detach $mntDir && sleep 4
59+
60+
# Write the modified read-only image to disk
61+
hdiutil convert -ov "$tmpImage" -format UDZO -imagekey zlib-level=9 -o "$dmgDir/$binName-mod.dmg"
62+
63+
# Remove temp image
64+
rm "$tmpImage"

pkgs/osx/travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
branches:
2+
except:
3+
- osx-deploy

0 commit comments

Comments
 (0)