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
|
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
# TcosMonitor version __VERSION__
#
# Copyright (c) 2006-2011 Mario Izquierdo <mariodebian@gmail.com>
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# This script is inspired by the debian package python-chardet
import os
import glob
from distutils.core import setup
from distutils.command.build import build
from distutils.command.install_data import install_data as install_data
data_files = []
import sys
def get_debian_version():
f=open('debian/changelog', 'r')
line=f.readline()
f.close()
version=line.split()[1].replace('(','').replace(')','')
return version
class build_locales(build):
def run(self):
os.system("cd po && make")
# parse __VERSION__ in build_scripts
for pyfile in glob.glob( "%s/*.py" %self.build_scripts):
process_version(pyfile)
libdir=self.build_lib + '/tcosmonitor'
for pyfile in glob.glob( "%s/*.py" %libdir):
process_version(pyfile)
extdir=libdir+'/extensions'
for pyfile in glob.glob( "%s/*.py" %extdir):
process_version(pyfile)
build.run(self)
class tcosmonitor_install_data(install_data):
def run(self):
install_data.run(self)
# rename scripts (delete .py extension)
for pyfile in glob.glob(self.install_dir + '/bin/*.py'):
new=pyfile.split('.py')[0]
print(" * Renaming %s => %s" %(pyfile, new ) )
os.rename( pyfile, new )
def process_version(pyfile):
version=get_debian_version()
print("sed -i -e 's/__VERSION__/%s/g' %s" %(version, pyfile) )
os.system("sed -i -e 's/__VERSION__/%s/g' %s" %(version, pyfile) )
for (path, dirs, files) in os.walk("po"):
if "tcosmonitor.mo" in files:
target = path.replace("po", "share/locale", 1)
data_files.append((target, [os.path.join(path, "tcosmonitor.mo")]))
def get_files(ipath):
files = []
for afile in glob.glob('%s/*'%(ipath) ):
if os.path.isfile(afile):
files.append(afile)
return files
# images (menus and buttons)
data_files.append(('share/tcosmonitor/images', get_files("images") ))
data_files.append(('share/pixmaps', ['images/tcos-icon-32x32.png'] ))
# Interface files
data_files.append(('share/tcosmonitor/ui', get_files("ui") ))
# config files and Xsession.d launcher
data_files.append( ('/etc/tcos', ['tcosmonitor.conf']) )
data_files.append( ('/etc/tcos', ['tcos-devices-ng.conf']) )
data_files.append( ('/etc/X11/Xsession.d', ['dbus/81tcos-utils']) )
# Desktop files
data_files.append( ('share/applications/', ['tcosmonitor.desktop',
'tcospersonalize.desktop',
'tcos-volume-manager.desktop']) )
setup(name='TcosMonitor',
description = 'Thin Client Manager for teachers',
version=get_debian_version(),
author = 'Mario Izquierdo',
author_email = 'mariodebian@gmail.com',
url = 'http://www.tcosproject.org',
license = 'GPLv2',
platforms = ['linux'],
keywords = ['thin client', 'teacher monitor', 'ltsp'],
packages=['tcosmonitor', 'tcosmonitor.extensions'],
package_dir = {'':''},
scripts=['tcosmonitor.py', 'tcos-volume-manager.py', 'tcos-devices-ng.py',
'tcospersonalize.py', 'dbus/tcos-dbus-client.py',
'server-utils/tcos-server-utils.py'],
cmdclass = {'build': build_locales, 'install_data' : tcosmonitor_install_data},
data_files=data_files
)
|