2
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
5
# ubuntu-fr <LoCo Team>
6
# kanor <Romain DUBREIL> <contact@kanor.fr>
7
# cm-t <Rudy ANDRÉ> <arudy@ubuntu-fr.org>
8
# olive <Olivier FRAYSSE> <olive@picapo.org>
9
# quesh <Frédéric MANDE> <quesh@quesh.fr>
10
# This program is free software: you can redistribute it and/or modify it
11
# under the terms of the GNU General Public License version 3, as published
12
# by the Free Software Foundation.
14
# This program is distributed in the hope that it will be useful, but
15
# WITHOUT ANY WARRANTY; without even the implied warranties of
16
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17
# PURPOSE. See the GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License along
20
# with this program. If not, see <http://www.gnu.org/licenses/>.
23
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
29
import DistUtilsExtra.auto
31
print >> sys.stderr, 'To build dash-privacy-interface you need https://launchpad.net/python-distutils-extra'
33
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
35
def update_config(libdir, values = {}):
37
filename = os.path.join(libdir, 'dash_privacy_interface_lib/dash_privacy_interfaceconfig.py')
40
fin = file(filename, 'r')
41
fout = file(filename + '.new', 'w')
44
fields = line.split(' = ') # Separate variable from value
45
if fields[0] in values:
46
oldvalues[fields[0]] = fields[1].strip()
47
line = "%s = %s\n" % (fields[0], values[fields[0]])
53
os.rename(fout.name, fin.name)
54
except (OSError, IOError), e:
55
print ("ERROR: Can't find %s" % filename)
60
def move_desktop_file(root, target_data, prefix):
61
# The desktop file is rightly installed into install_data. But it should
62
# always really be installed into prefix, because while we can install
63
# normal data files anywhere we want, the desktop file needs to exist in
64
# the main system to be found. Only actually useful for /opt installs.
66
old_desktop_path = os.path.normpath(root + target_data +
67
'/share/applications')
68
old_desktop_file = old_desktop_path + '/dash-privacy-interface.desktop'
69
desktop_path = os.path.normpath(root + prefix + '/share/applications')
70
desktop_file = desktop_path + '/dash-privacy-interface.desktop'
72
if not os.path.exists(old_desktop_file):
73
print ("ERROR: Can't find", old_desktop_file)
75
elif target_data != prefix + '/':
76
# This is an /opt install, so rename desktop file to use extras-
77
desktop_file = desktop_path + '/extras-dash-privacy-interface.desktop'
79
os.makedirs(desktop_path)
80
os.rename(old_desktop_file, desktop_file)
81
os.rmdir(old_desktop_path)
83
print ("ERROR: Can't rename", old_desktop_file, ":", e)
88
def update_desktop_file(filename, target_pkgdata, target_scripts):
91
fin = file(filename, 'r')
92
fout = file(filename + '.new', 'w')
96
line = "Icon=%s\n" % (target_pkgdata + 'media/dash-privacy-interface.svg')
98
cmd = line.split("=")[1].split(None, 1)
99
line = "Exec=%s" % (target_scripts + 'dash-privacy-interface')
101
line += " %s" % cmd[1].strip() # Add script arguments back
107
os.rename(fout.name, fin.name)
108
except (OSError, IOError), e:
109
print ("ERROR: Can't find %s" % filename)
112
def compile_schemas(root, target_data):
113
if target_data == '/usr/':
114
return # /usr paths don't need this, they will be handled by dpkg
115
schemadir = os.path.normpath(root + target_data + 'share/glib-2.0/schemas')
116
if (os.path.isdir(schemadir) and
117
os.path.isfile('/usr/bin/glib-compile-schemas')):
118
os.system('/usr/bin/glib-compile-schemas "%s"' % schemadir)
121
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
123
DistUtilsExtra.auto.install_auto.run(self)
125
target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
126
target_pkgdata = target_data + 'share/dash-privacy-interface/'
127
target_scripts = '/' + os.path.relpath(self.install_scripts, self.root) + '/'
129
values = {'__dash_privacy_interface_data_directory__': "'%s'" % (target_pkgdata),
130
'__version__': "'%s'" % self.distribution.get_version()}
131
update_config(self.install_lib, values)
133
desktop_file = move_desktop_file(self.root, target_data, self.prefix)
134
update_desktop_file(desktop_file, target_pkgdata, target_scripts)
135
compile_schemas(self.root, target_data)
138
##################################################################################
139
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
140
##################################################################################
142
DistUtilsExtra.auto.setup(
143
name='dash-privacy-interface',
147
author_email='arudy@ubuntu-fr.org',
148
#description='UI for managing …',
149
#long_description='Here a longer description',
150
url='https://launchpad.net/dash-privacy-interface',
151
cmdclass={'install': InstallAndUpdateDataDirectory}