-
Notifications
You must be signed in to change notification settings - Fork 43
/
setup.py
165 lines (151 loc) · 5.83 KB
/
setup.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from setuptools import setup
import os
import sys
import copy
import shutil
import fileinput
import shlex
VERSION = '1.0.1865.25'
PATCH_DIR = 'build'
install_upstart = True
install_systemd = True
install_gtk = True
data_files = []
LINUX = 'linux'
SHELL = 'shell'
if sys.platform.startswith('linux'):
PLATFORM = LINUX
else:
raise NotImplementedError('Interface not available for platform')
prefix = sys.prefix
for arg in copy.copy(sys.argv):
if arg.startswith('--prefix'):
prefix = os.path.normpath(shlex.split(arg)[0].split('=')[-1])
elif arg == '--no-upstart':
sys.argv.remove('--no-upstart')
install_upstart = False
elif arg == '--no-systemd':
sys.argv.remove('--no-systemd')
install_systemd = False
elif arg == '--no-gtk':
sys.argv.remove('--no-gtk')
install_gtk = False
if not os.path.exists('build'):
os.mkdir('build')
if install_gtk:
for img_size in os.listdir(os.path.join('img', 'hicolor')):
for img_name in os.listdir(os.path.join('img', 'hicolor',
img_size)):
data_files.append((os.path.join(os.path.abspath(os.sep), 'usr',
'share', 'icons', 'hicolor', img_size, 'apps'), [
os.path.join('img', 'hicolor', img_size, img_name)]))
for img_theme in ('ubuntu-mono-dark', 'ubuntu-mono-light'):
for img_size in os.listdir(os.path.join('img', img_theme)):
for img_name in os.listdir(os.path.join('img', img_theme,
img_size)):
data_files.append((os.path.join(os.path.abspath(os.sep),
'usr', 'share', 'icons', img_theme, 'apps', img_size),
[os.path.join('img', img_theme, img_size, img_name)]))
data_files += [
(os.path.join(os.path.abspath(os.sep), 'usr', 'share',
'pritunl_client'), [
os.path.join('img', 'logo.png'),
os.path.join('img', 'logo_connected_dark.svg'),
os.path.join('img', 'logo_disconnected_dark.svg'),
os.path.join('img', 'logo_connected_light.svg'),
os.path.join('img', 'logo_disconnected_light.svg'),
]),
(os.path.join(os.path.abspath(os.sep), 'usr', 'share',
'applications'), [os.path.join(
'data', 'linux', 'applications',
'pritunl-client-gtk.desktop')]),
(os.path.join(os.path.abspath(os.sep), 'etc', 'xdg', 'autostart'),
[os.path.join('data', 'linux', 'applications',
'pritunl-client-gtk.desktop')]),
(os.path.join(os.path.abspath(os.sep), 'usr', 'share', 'polkit-1',
'actions'), [os.path.join('data', 'linux', 'polkit',
'com.pritunl.client.policy')]),
]
data_files += [
(os.path.join(os.path.abspath(os.sep), 'var', 'log'), [
os.path.join('data', 'var', 'pritunl-client.log'),
os.path.join('data', 'var', 'pritunl-client.log.1'),
]),
(os.path.join(os.path.abspath(os.sep), 'usr', 'share',
'pritunl_client'), [
os.path.join('data', 'scripts', 'update-resolv-conf.sh'),
]),
(os.path.join(os.path.abspath(os.sep), 'usr', 'share',
'pritunl_client'), [
os.path.join('data', 'scripts', 'update-systemd-resolved.sh'),
])
]
console_scripts = [
'pritunl-client = pritunl_client.__main__:client_shell',
]
if install_gtk:
console_scripts += [
'pritunl-client-gtk = pritunl_client.__main__:client_gui',
'pritunl-client-pk-start = pritunl_client.__main__:pk_start',
'pritunl-client-pk-autostart = ' + \
'pritunl_client.__main__:pk_autostart',
'pritunl-client-pk-stop = pritunl_client.__main__:pk_stop',
'pritunl-client-pk-set-autostart = ' + \
'pritunl_client.__main__:pk_set_autostart',
'pritunl-client-pk-clear-autostart = ' + \
'pritunl_client.__main__:pk_clear_autostart',
]
patch_files = []
if install_upstart:
patch_files.append('%s/pritunl-client.conf' % PATCH_DIR)
data_files.append(('/etc/init', ['%s/pritunl-client.conf' % PATCH_DIR]))
data_files.append(('/etc/init.d', ['data/init.d/pritunl-client.sh']))
shutil.copy('data/init/pritunl-client.conf',
'%s/pritunl-client.conf' % PATCH_DIR)
if install_systemd:
patch_files.append('%s/pritunl-client.service' % PATCH_DIR)
data_files.append(('/etc/systemd/system',
['%s/pritunl-client.service' % PATCH_DIR]))
shutil.copy('data/systemd/pritunl-client.service',
'%s/pritunl-client.service' % PATCH_DIR)
for file_name in patch_files:
for line in fileinput.input(file_name, inplace=True):
line = line.replace('%PREFIX%', prefix)
print line.rstrip('\n')
setup(
name='pritunl_client',
version=VERSION,
description='Pritunl VPN Client',
long_description=open('README.md').read(),
author='Pritunl',
author_email='contact@pritunl.com',
url='https://github.com/pritunl/pritunl-client',
download_url='https://github.com/pritunl/pritunl-client/archive/' + \
'%s.tar.gz' % VERSION,
keywords='pritunl, openvpn, vpn, management, client',
packages=[
'pritunl_client',
'pritunl_client.click',
],
license=open('LICENSE').read(),
zip_safe=False,
data_files=data_files,
entry_points={
'console_scripts': console_scripts,
},
platforms=[
'Linux',
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS',
'Programming Language :: Python :: 2.7',
'Topic :: System :: Networking',
]
)