1
by Gabriele N. Tornetta
quickly saved |
1 |
#!/usr/bin/env python
|
2 |
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
|
3 |
### BEGIN LICENSE
|
|
17
by Gabriele N. Tornetta
App substantially complete |
4 |
# Copyright (C) 2012 Gabriele N. Tornetta <phoenix1987@gmail.com>
|
1
by Gabriele N. Tornetta
quickly saved |
5 |
# This program is free software: you can redistribute it and/or modify it
|
6 |
# under the terms of the GNU General Public License version 3, as published
|
|
7 |
# by the Free Software Foundation.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful, but
|
|
10 |
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
11 |
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
12 |
# PURPOSE. See the GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License along
|
|
15 |
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
### END LICENSE
|
|
17 |
||
18 |
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
|
|
19 |
||
20 |
import os |
|
21 |
import sys |
|
22 |
||
23 |
try: |
|
24 |
import DistUtilsExtra.auto |
|
25 |
except ImportError: |
|
26 |
print >> sys.stderr, 'To build gtumbler you need https://launchpad.net/python-distutils-extra' |
|
27 |
sys.exit(1) |
|
28 |
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18' |
|
29 |
||
30 |
def update_config(values = {}): |
|
31 |
||
32 |
oldvalues = {} |
|
33 |
try: |
|
34 |
fin = file('gtumbler_lib/gtumblerconfig.py', 'r') |
|
35 |
fout = file(fin.name + '.new', 'w') |
|
36 |
||
37 |
for line in fin: |
|
38 |
fields = line.split(' = ') # Separate variable from value |
|
39 |
if fields[0] in values: |
|
40 |
oldvalues[fields[0]] = fields[1].strip() |
|
41 |
line = "%s = %s\n" % (fields[0], values[fields[0]]) |
|
42 |
fout.write(line) |
|
43 |
||
44 |
fout.flush() |
|
45 |
fout.close() |
|
46 |
fin.close() |
|
47 |
os.rename(fout.name, fin.name) |
|
48 |
except (OSError, IOError), e: |
|
49 |
print ("ERROR: Can't find gtumbler_lib/gtumblerconfig.py") |
|
50 |
sys.exit(1) |
|
51 |
return oldvalues |
|
52 |
||
53 |
||
54 |
def update_desktop_file(datadir): |
|
55 |
||
56 |
try: |
|
57 |
fin = file('gtumbler.desktop.in', 'r') |
|
58 |
fout = file(fin.name + '.new', 'w') |
|
59 |
||
60 |
for line in fin: |
|
61 |
if 'Icon=' in line: |
|
62 |
line = "Icon=%s\n" % (datadir + 'media/gtumbler.svg') |
|
63 |
fout.write(line) |
|
64 |
fout.flush() |
|
65 |
fout.close() |
|
66 |
fin.close() |
|
67 |
os.rename(fout.name, fin.name) |
|
68 |
except (OSError, IOError), e: |
|
69 |
print ("ERROR: Can't find gtumbler.desktop.in") |
|
70 |
sys.exit(1) |
|
71 |
||
72 |
||
73 |
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto): |
|
74 |
def run(self): |
|
75 |
values = {'__gtumbler_data_directory__': "'%s'" % (self.prefix + '/share/gtumbler/'), |
|
76 |
'__version__': "'%s'" % self.distribution.get_version()} |
|
77 |
previous_values = update_config(values) |
|
78 |
update_desktop_file(self.prefix + '/share/gtumbler/') |
|
79 |
DistUtilsExtra.auto.install_auto.run(self) |
|
80 |
update_config(previous_values) |
|
81 |
||
82 |
||
83 |
||
84 |
##################################################################################
|
|
85 |
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
|
|
86 |
##################################################################################
|
|
87 |
||
88 |
DistUtilsExtra.auto.setup( |
|
89 |
name='gtumbler', |
|
18
by Gabriele N. Tornetta
commit before release |
90 |
version='12.07', |
1
by Gabriele N. Tornetta
quickly saved |
91 |
license='GPL-3', |
4
by Gabriele N. Tornetta
quickly saved |
92 |
author='Gabriele N. Tornetta', |
1
by Gabriele N. Tornetta
quickly saved |
93 |
author_email='phoenix1987@gmail.com', |
4
by Gabriele N. Tornetta
quickly saved |
94 |
description='Graphical PDF Manager', |
15
by Gabriele N. Tornetta
commit before release |
95 |
url='https://launchpad.net/gtumbler', |
11
by Gabriele N. Tornetta
CommandPattern for BoundingBoxes |
96 |
long_description='With gtumbler you can convert many PostScript documents to PDF at once, concatenate many PostScript/PDF documents, crop margins (MediaBox, CropBox, BleedBox, TrimBox and ArtBox), invoke a PDF editor/annotator such as Xournal, PDFedit, or your custom application and much more...', |
1
by Gabriele N. Tornetta
quickly saved |
97 |
cmdclass={'install': InstallAndUpdateDataDirectory} |
98 |
)
|
|
99 |