forked from examachine/pisi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·129 lines (110 loc) · 3.95 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
#!/usr/bin/env python
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# This program 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.
#
# Please read the COPYING file.
#
# Authors: {eray,gurer}@pardus.org.tr
import os
import shutil
import glob
import sys
import inspect
from distutils.core import setup
from distutils.command.install import install
sys.path.insert(0, '.')
import pisi
i18n_domain = "pisi"
i18n_languages = "tr"
class Install(install):
def run(self):
install.run(self)
self.installi18n()
self.installdoc()
self.generateConfigFile()
def installi18n(self):
for lang in i18n_languages.split(' '):
print "Installing '%s' translations..." % lang
os.popen("msgfmt po/%s.po -o po/%s.mo" % (lang, lang))
if not self.prefix:
self.prefix = "/"
destpath = os.path.join(self.prefix, "usr/share/locale/%s/LC_MESSAGES" % lang)
try:
os.makedirs(destpath)
except:
pass
shutil.copy("po/%s.mo" % lang, os.path.join(destpath, "%s.mo" % i18n_domain))
def installdoc(self):
destpath = os.path.join(self.prefix, "usr/share/doc/pisi")
try:
os.makedirs(destpath)
except:
pass
os.chdir('doc')
for pdf in glob.glob('*.pdf'):
print 'Installing', pdf
shutil.copy(pdf, os.path.join(destpath, pdf))
os.chdir('..')
def generateConfigFile(self):
import pisi.configfile
destpath = os.path.join(self.prefix, "etc/pisi/")
try:
os.makedirs(destpath)
except:
pass
pisiconf = open(os.path.join(destpath, "pisi.conf"), "w")
klasses = inspect.getmembers(pisi.configfile, inspect.isclass)
defaults = [klass for klass in klasses if klass[0].endswith('Defaults')]
for d in defaults:
section_name = d[0][:-len('Defaults')].lower()
pisiconf.write("[%s]\n" % section_name)
section_members = [m for m in inspect.getmembers(d[1]) \
if not m[0].startswith('__') \
and not m[0].endswith('__')]
for member in section_members:
pisiconf.write("# %s = %s\n" % (member[0], member[1]))
pisiconf.write('\n')
setup(name="pisi",
version= pisi.__version__,
description="PISI (Packages Installed Successfully as Intended)",
long_description="PISI is the package management system of Pardus Linux.",
license="GNU AGPL-3.0",
author="Eray Ozkural, Baris Metin, S. Caglar Onur",
author_email="eray.ozkural@gmail.com",
url="https://github.com/examachine/pisi",
package_dir = {'': ''},
packages = ['pisi', 'pisi.cli', 'pisi.actionsapi', 'pisi.pxml', 'pisi.search'],
scripts = ['pisi-cli', 'scripts/repostats.py', 'scripts/find-lib-deps.py',
'scripts/lspisi', 'scripts/unpisi',
'scripts/calc-build-order.py', 'scripts/pisish', 'scripts/pisimedia'],
cmdclass = {
'install' : Install
}
)
# the below stuff is really nice but we already have a version
# we can use this stuff for svn snapshots in a separate
# script, or with a parameter I don't know -- exa
PISI_VERSION = pisi.__version__
def getRevision():
import os
try:
p = os.popen("svn info 2> /dev/null")
for line in p.readlines():
line = line.strip()
if line.startswith("Revision:"):
return line.split(":")[1].strip()
except:
pass
# doesn't working in a Subversion directory
return None
def getVersion():
rev = getRevision()
if rev:
return "-r".join([PISI_VERSION, rev])
else:
return PISI_VERSION