-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·160 lines (138 loc) · 6.78 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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# PyKota : Print Quotas for CUPS
#
# (c) 2003-2013 Jerome Alet <alet@librelogiciel.com>
# 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 3 of the License, or
# (at your option) any later version.
#
# This program 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, see <http://www.gnu.org/licenses/>.
#
# $Id$
#
#
import sys
import glob
import os
import stat
import shutil
try :
from distutils.core import setup
from distutils.command.install_data import install_data
except ImportError, msg :
sys.stderr.write("%s\n" % msg)
sys.stderr.write("You need the DistUtils Python module.\nunder Debian, you may have to install the python-dev package.\nOf course, YMMV.\n")
sys.exit(-1)
sys.path.insert(0, "pykota")
from pykota.version import __version__, __doc__
if (__version__.upper().find("BROKEN") != -1) and ("--force" not in sys.argv[1:]) :
sys.stderr.write("THIS DEVELOPMENT VERSION OF PYKOTA IS BROKEN. YOU MUST NOT USE IT. YOU SHOULD DOWNLOAD AN EARLIER RELEASE INSTEAD, EITHER THROUGH AN ENTRY PASS, OR BY DOWNLOADING THE LATEST STABLE TAG FROM SUBVERSION.\n")
sys.exit(-1)
data_files = []
mofiles = glob.glob(os.sep.join(["po", "*", "*.mo"]))
for mofile in mofiles :
lang = mofile.split(os.sep)[1]
directory = os.sep.join(["share", "locale", lang, "LC_MESSAGES"])
data_files.append((directory, [ mofile ]))
docdir = "share/doc/pykota"
docfiles = ["README", "FAQ", "SECURITY", "COPYING", "LICENSE", "CREDITS", "TODO"]
if os.path.exists("ChangeLog") :
docfiles.append("ChangeLog")
data_files.append((docdir, docfiles))
docfiles = glob.glob(os.sep.join(["docs", "*.pdf"]))
docfiles += glob.glob(os.sep.join(["docs", "*.sx?"]))
data_files.append((docdir, docfiles))
docfiles = glob.glob(os.sep.join(["docs", "pykota", "*.html"]))
data_files.append((os.path.join(docdir, "html"), docfiles))
docfiles = glob.glob(os.sep.join(["openoffice", "*.sx?"]))
docfiles += glob.glob(os.sep.join(["openoffice", "*.png"]))
docfiles += glob.glob(os.sep.join(["openoffice", "README"]))
data_files.append((os.path.join(docdir, "openoffice"), docfiles))
docfiles = glob.glob(os.sep.join(["qa-assistant", "*.xml"]))
docfiles += glob.glob(os.sep.join(["qa-assistant", "README"]))
data_files.append((os.path.join(docdir, "qa-assistant"), docfiles))
directory = os.sep.join(["share", "man", "man1"])
manpages = glob.glob(os.sep.join(["man", "*.1"]))
data_files.append((directory, manpages))
modirs = [ os.path.split(os.path.split(mof)[0])[1] for mof in mofiles ]
for dir in modirs :
directory = os.sep.join(["share", "man", dir, "man1"])
manpages = glob.glob(os.sep.join(["man", dir, "*.1"]))
data_files.append((directory, manpages))
directory = os.sep.join(["share", "pykota"])
data_files.append((directory, ["checkdeps.py", "bin/cupspykota", \
"bin/waitprinter.sh", \
"bin/papwaitprinter.sh", \
"bin/mailandpopup.sh", \
"untested/pjl/pagecount.pjl", \
"untested/pjl/status.pjl", \
"untested/netatalk/netatalk.sh", \
"untested/netatalk/pagecount.ps"]))
data_files.append((os.sep.join([directory, "conf"]),
["conf/README", "conf/pykota.conf.sample",
"conf/pykotadmin.conf.sample"]))
data_files.append((os.sep.join([directory, "cgi-bin"]),
["cgi-bin/README",
"cgi-bin/printquota.cgi",
"cgi-bin/dumpykota.cgi",
"cgi-bin/pykotme.cgi"]))
data_files.append((os.sep.join([directory, "logos"]),
glob.glob(os.sep.join(["logos", "*.jpeg"])) \
+ glob.glob(os.sep.join(["logos", "*.png"])) \
+ glob.glob(os.sep.join(["logos", "*.xcf"]))))
data_files.append((os.sep.join([directory, "stylesheets"]),
glob.glob(os.sep.join(["stylesheets", "*.css"])) \
+ [ "stylesheets/README" ]))
pgdirectory = os.sep.join([directory, "postgresql"])
data_files.append((pgdirectory, ["initscripts/postgresql/README.postgresql",
"initscripts/postgresql/pykota-postgresql.sql"]))
ldapdirectory = os.sep.join([directory, "ldap"])
data_files.append((ldapdirectory, ["initscripts/ldap/README.ldap",
"initscripts/ldap/README.sunds",
"initscripts/ldap/pykota.schema",
"initscripts/ldap/pykota-sunds-indexes.ldif",
"initscripts/ldap/pykota-schema-sunds.ldif",
"initscripts/ldap/pykota-sample.ldif"]))
mysqldirectory = os.sep.join([directory, "mysql"])
data_files.append((mysqldirectory, ["initscripts/mysql/README.mysql",
"initscripts/mysql/pykota-mysql.sql"]))
sqlitedirectory = os.sep.join([directory, "sqlite"])
data_files.append((sqlitedirectory, ["initscripts/sqlite/README.sqlite",
"initscripts/sqlite/pykota-sqlite.sql"]))
class MyInstallData(install_data) :
"""A special class to ensure permissions are OK on the cupspykota backend."""
def run(self) :
"""Launches the normal installation and then tweaks permissions."""
install_data.run(self)
if not self.dry_run :
cupspykota = [ filename for filename in self.get_outputs() if filename.endswith("cupspykota") ][0]
os.chmod(cupspykota, stat.S_IRWXU)
os.umask(022)
setup(name = "pykota", version = __version__,
license = "GNU GPL version 3 or later",
description = __doc__,
author = "Jerome Alet",
author_email = "alet@librelogiciel.com",
url = "http://www.pykota.com",
packages = [ "pykota",
"pykota.storages",
"pykota.loggers",
"pykota.accounters",
"pykota.reporters",
],
scripts = [ "bin/pknotify", "bin/pkusers", "bin/pkinvoice", "bin/pksetup", \
"bin/pkrefund", "bin/pkturnkey", "bin/pkbcodes", \
"bin/pkbanner", "bin/autopykota", "bin/dumpykota", \
"bin/pykosd", "bin/edpykota", "bin/repykota", \
"bin/warnpykota", "bin/pykotme", "bin/pkprinters" ],
data_files = data_files,
cmdclass = { "install_data" : MyInstallData })