Skip to content

Commit e0069f5

Browse files
committed
Build dmg image from application bundle
1 parent 6cd1331 commit e0069f5

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ git interactions :
2727
* [GitPython][3], to display repository info and trigger git actions
2828
* [PyInstaller][4], to bundle an easy to distribute application bundle
2929
* [fswatch][5], to track changes in filesystem
30+
* [create-dmg][7], to create nice DMG for bundled app
3031

3132
## Screenshots
3233

@@ -169,3 +170,4 @@ You may need to reinstall XCode stuff to get git working again, [see][6].
169170
[4]: http://www.pyinstaller.org/ "PyInstaller"
170171
[5]: https://github.com/emcrisostomo/fswatch "fswatch"
171172
[6]: http://www.linuxuk.org/post/fixing_git_on_macOS_Sierra/
173+
[7]: https://github.com/andreyvit/create-dmg "create-dmg"

bundle.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ res/build_resources.sh
1010
#echo QT5DIR=${QT5DIR}
1111

1212
THIS_DIR=$(dirname $0)
13-
BUNDLE_DIR=${THIS_DIR}/dist/GitOver.app
13+
BUNDLE_NAME=GitOver
14+
DIST_DIR=${THIS_DIR}/dist
15+
BUNDLE_DIR=${DIST_DIR}/${BUNDLE_NAME}.app
1416
BUNDLE_CONTENTS_DIR=${BUNDLE_DIR}/Contents
1517
BUNDLE_MACOS_DIR=${BUNDLE_CONTENTS_DIR}/MacOS
18+
BUNDLE_ICON=${THIS_DIR}/res/icon.icns
19+
BUNDLE_VERSION=$(grep "gitover_version =" ${THIS_DIR}/gitover/ui/resources.py | cut -d "=" -f 2 | tr -d " '")
20+
BUNDLE_DMG_NAME=${BUNDLE_NAME}_${BUNDLE_VERSION}
1621
SIGNING_CERT="GitOverSigning"
1722

1823
# When using pyenv virtualenv the Python interpreter must be build with shared option enabled.
@@ -21,11 +26,11 @@ SIGNING_CERT="GitOverSigning"
2126
#
2227
# Extended debug while building/running application:
2328
# --log-level=DEBUG --debug
24-
pyinstaller --icon ${THIS_DIR}/res/icon.icns \
29+
pyinstaller --icon ${BUNDLE_ICON} \
2530
--onefile --windowed --noconfirm --clean \
2631
--hidden-import PyQt5.sip \
2732
--osx-bundle-identifier de.manuelkoch.gitover \
28-
-n GitOver \
33+
-n ${BUNDLE_NAME} \
2934
--paths ${THIS_DIR} \
3035
${THIS_DIR}/gitover/main.py
3136

@@ -45,4 +50,16 @@ cp ${THIS_DIR}/README.md ${BUNDLE_MACOS_DIR}
4550
${THIS_DIR}/res/fix_app_qt_folder_names_for_codesign.py ${BUNDLE_DIR}
4651
security find-certificate -c "${SIGNING_CERT}" >/dev/null \
4752
&& codesign --deep -s "${SIGNING_CERT}" ${BUNDLE_DIR} \
48-
&& codesign -dv --verbose=4 ${BUNDLE_DIR}
53+
&& codesign -dv --verbose=4 ${BUNDLE_DIR}
54+
55+
# DMG
56+
test -f ${DIST_DIR}/${BUNDLE_DMG_NAME}.dmg && rm -f ${DIST_DIR}/${BUNDLE_DMG_NAME}.dmg
57+
create-dmg --volname ${BUNDLE_NAME} --volicon ${BUNDLE_ICON} \
58+
--icon "${BUNDLE_NAME}.app" 110 150 \
59+
--app-drop-link 380 150 \
60+
--background res/dmg_bg.png \
61+
${DIST_DIR}/${BUNDLE_DMG_NAME}.dmg \
62+
${BUNDLE_DIR}
63+
pushd ${DIST_DIR}
64+
shasum -a 256 ${BUNDLE_DMG_NAME}.dmg > ${BUNDLE_DMG_NAME}.sha256
65+
popd

res/dmg_bg.png

2.03 KB
Loading

0 commit comments

Comments
 (0)