summaryrefslogtreecommitdiff
path: root/osx/generate.py
blob: 57aa11ede13b9911930a43faffa37fd770eccacc (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
#!/usr/bin/python

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

from string import Template

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

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

TEMPLATE = 'template-info.plist'
ENTRYPOINT = 'bitmask-systray'
HELPER = 'bitmask_helper'


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)

INFO_PLIST = APP_PATH + '/Contents/Info.plist'

vardict = {
    'entrypoint': ENTRYPOINT,
    'info_string': APP_NAME + " " + VERSION,
    'bundle_identifier': BUNDLE_IDENTIFIER,
    'bundle_name': APP_NAME,
    'version': VERSION
}

template = Template(open(TEMPLATE).read())
with open(INFO_PLIST, 'w') as output:
    output.write(template.safe_substitute(vardict))


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


def copy_payload(filename):
    destfile = APP_PATH + "/Contents/MacOS/" + filename
    shutil.copyfile(STAGING + '/' + filename, destfile)
    cmode = os.stat(destfile).st_mode
    os.chmod(destfile, cmode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

copy_payload(ENTRYPOINT)
copy_payload(HELPER)