summaryrefslogtreecommitdiff
path: root/osx/generate.py
blob: 8982d94fdb580ca3d7f9c5af61d5e3d55224ada2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python

import os
import os.path
import shutil
import sys
import stat

# Variables ----------------------------
# TODO consolidate version string for all builds.

VERSION = "0.0.1"
APP_NAME = "RiseupVPN"
BUNDLE_IDENTIFIER = "se.leap.riseupvpn"
ENTRYPOINT = "bitmask-systray"
# Do not edit below --------------------


here = os.path.split(os.path.abspath(__file__))[0]
APP_PATH = os.path.abspath(here + '/../dist/' + APP_NAME + ".app")
STAGING = os.path.abspath(here + '/../staging/')

os.makedirs(APP_PATH + "/Contents/MacOS", exist_ok=True)


f = open(APP_PATH + "/Contents/Info.plist", "w")
f.write("""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>%s</string>
    <key>CFBundleGetInfoString</key>
    <string>%s</string>
    <key>CFBundleIconFile</key>
    <string>app.icns</string>
    <key>CFBundleIdentifier</key>
    <string>%s</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>%s</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>%s</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>%s</string>
    <key>NSAppleScriptEnabled</key>
    <string>YES</string>
    <key>NSMainNibFile</key>
    <string>MainMenu</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
</dict>
</plist>
""" % (
    ENTRYPOINT,
    APP_NAME + " " + VERSION,
    BUNDLE_IDENTIFIER,
    APP_NAME,
    APP_NAME + " " + VERSION,
    VERSION))
f.close()

f = open(APP_PATH + "/Contents/PkgInfo", "w")
f.write("APPL????")
f.close()

entrypoint_file = APP_PATH + "/Contents/MacOS/" + ENTRYPOINT
shutil.copyfile(STAGING + '/' + ENTRYPOINT, entrypoint_file)

oldmode = os.stat(entrypoint_file).st_mode
os.chmod(entrypoint_file, oldmode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)