1 | #! /usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # |
---|
4 | # PyKota : Print Quotas for CUPS |
---|
5 | # |
---|
6 | # (c) 2003, 2004, 2005, 2006, 2007, 2008 Jerome Alet <alet@librelogiciel.com> |
---|
7 | # This program is free software: you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation, either version 3 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # This program is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | # |
---|
20 | # $Id$ |
---|
21 | # |
---|
22 | # |
---|
23 | |
---|
24 | import sys |
---|
25 | import glob |
---|
26 | import os |
---|
27 | import stat |
---|
28 | import shutil |
---|
29 | try : |
---|
30 | from distutils.core import setup |
---|
31 | from distutils.command.install_data import install_data |
---|
32 | except ImportError, msg : |
---|
33 | sys.stderr.write("%s\n" % msg) |
---|
34 | sys.stderr.write("You need the DistUtils Python module.\nunder Debian, you may have to install the python-dev package.\nOf course, YMMV.\n") |
---|
35 | sys.exit(-1) |
---|
36 | |
---|
37 | sys.path.insert(0, "pykota") |
---|
38 | from pykota.version import __version__, __doc__ |
---|
39 | |
---|
40 | if (__version__.upper().find("BROKEN") != -1) and ("--force" not in sys.argv[1:]) : |
---|
41 | 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") |
---|
42 | sys.exit(-1) |
---|
43 | |
---|
44 | data_files = [] |
---|
45 | mofiles = glob.glob(os.sep.join(["po", "*", "*.mo"])) |
---|
46 | for mofile in mofiles : |
---|
47 | lang = mofile.split(os.sep)[1] |
---|
48 | directory = os.sep.join(["share", "locale", lang, "LC_MESSAGES"]) |
---|
49 | data_files.append((directory, [ mofile ])) |
---|
50 | |
---|
51 | docdir = "share/doc/pykota" |
---|
52 | docfiles = ["README", "FAQ", "SECURITY", "COPYING", "LICENSE", "CREDITS", "TODO"] |
---|
53 | if os.path.exists("ChangeLog") : |
---|
54 | docfiles.append("ChangeLog") |
---|
55 | data_files.append((docdir, docfiles)) |
---|
56 | |
---|
57 | docfiles = glob.glob(os.sep.join(["docs", "*.pdf"])) |
---|
58 | docfiles += glob.glob(os.sep.join(["docs", "*.sx?"])) |
---|
59 | data_files.append((docdir, docfiles)) |
---|
60 | |
---|
61 | docfiles = glob.glob(os.sep.join(["docs", "pykota", "*.html"])) |
---|
62 | data_files.append((os.path.join(docdir, "html"), docfiles)) |
---|
63 | |
---|
64 | docfiles = glob.glob(os.sep.join(["openoffice", "*.sx?"])) |
---|
65 | docfiles += glob.glob(os.sep.join(["openoffice", "*.png"])) |
---|
66 | docfiles += glob.glob(os.sep.join(["openoffice", "README"])) |
---|
67 | data_files.append((os.path.join(docdir, "openoffice"), docfiles)) |
---|
68 | |
---|
69 | docfiles = glob.glob(os.sep.join(["qa-assistant", "*.xml"])) |
---|
70 | docfiles += glob.glob(os.sep.join(["qa-assistant", "README"])) |
---|
71 | data_files.append((os.path.join(docdir, "qa-assistant"), docfiles)) |
---|
72 | |
---|
73 | directory = os.sep.join(["share", "man", "man1"]) |
---|
74 | manpages = glob.glob(os.sep.join(["man", "*.1"])) |
---|
75 | data_files.append((directory, manpages)) |
---|
76 | |
---|
77 | modirs = [ os.path.split(os.path.split(mof)[0])[1] for mof in mofiles ] |
---|
78 | for dir in modirs : |
---|
79 | directory = os.sep.join(["share", "man", dir, "man1"]) |
---|
80 | manpages = glob.glob(os.sep.join(["man", dir, "*.1"])) |
---|
81 | data_files.append((directory, manpages)) |
---|
82 | |
---|
83 | directory = os.sep.join(["share", "pykota"]) |
---|
84 | data_files.append((directory, ["checkdeps.py", "bin/cupspykota", \ |
---|
85 | "bin/waitprinter.sh", \ |
---|
86 | "bin/papwaitprinter.sh", \ |
---|
87 | "bin/mailandpopup.sh", \ |
---|
88 | "untested/pjl/pagecount.pjl", \ |
---|
89 | "untested/pjl/status.pjl", \ |
---|
90 | "untested/netatalk/netatalk.sh", \ |
---|
91 | "untested/netatalk/pagecount.ps"])) |
---|
92 | |
---|
93 | data_files.append((os.sep.join([directory, "conf"]), |
---|
94 | ["conf/README", "conf/pykota.conf.sample", |
---|
95 | "conf/pykotadmin.conf.sample"])) |
---|
96 | |
---|
97 | data_files.append((os.sep.join([directory, "cgi-bin"]), |
---|
98 | ["cgi-bin/README", |
---|
99 | "cgi-bin/printquota.cgi", |
---|
100 | "cgi-bin/dumpykota.cgi", |
---|
101 | "cgi-bin/pykotme.cgi"])) |
---|
102 | |
---|
103 | data_files.append((os.sep.join([directory, "logos"]), |
---|
104 | glob.glob(os.sep.join(["logos", "*.jpeg"])) \ |
---|
105 | + glob.glob(os.sep.join(["logos", "*.png"])) \ |
---|
106 | + glob.glob(os.sep.join(["logos", "*.xcf"])))) |
---|
107 | |
---|
108 | data_files.append((os.sep.join([directory, "stylesheets"]), |
---|
109 | glob.glob(os.sep.join(["stylesheets", "*.css"])) \ |
---|
110 | + [ "stylesheets/README" ])) |
---|
111 | |
---|
112 | pgdirectory = os.sep.join([directory, "postgresql"]) |
---|
113 | data_files.append((pgdirectory, ["initscripts/postgresql/README.postgresql", |
---|
114 | "initscripts/postgresql/pykota-postgresql.sql"])) |
---|
115 | |
---|
116 | ldapdirectory = os.sep.join([directory, "ldap"]) |
---|
117 | data_files.append((ldapdirectory, ["initscripts/ldap/README.ldap", |
---|
118 | "initscripts/ldap/README.sunds", |
---|
119 | "initscripts/ldap/pykota.schema", |
---|
120 | "initscripts/ldap/pykota-sunds-indexes.ldif", |
---|
121 | "initscripts/ldap/pykota-schema-sunds.ldif", |
---|
122 | "initscripts/ldap/pykota-sample.ldif"])) |
---|
123 | |
---|
124 | mysqldirectory = os.sep.join([directory, "mysql"]) |
---|
125 | data_files.append((mysqldirectory, ["initscripts/mysql/README.mysql", |
---|
126 | "initscripts/mysql/pykota-mysql.sql"])) |
---|
127 | |
---|
128 | sqlitedirectory = os.sep.join([directory, "sqlite"]) |
---|
129 | data_files.append((sqlitedirectory, ["initscripts/sqlite/README.sqlite", |
---|
130 | "initscripts/sqlite/pykota-sqlite.sql"])) |
---|
131 | |
---|
132 | class MyInstallData(install_data) : |
---|
133 | """A special class to ensure permissions are OK on the cupspykota backend.""" |
---|
134 | def run(self) : |
---|
135 | """Launches the normal installation and then tweaks permissions.""" |
---|
136 | install_data.run(self) |
---|
137 | if not self.dry_run : |
---|
138 | cupspykota = [ filename for filename in self.get_outputs() if filename.endswith("cupspykota") ][0] |
---|
139 | os.chmod(cupspykota, stat.S_IRWXU) |
---|
140 | |
---|
141 | os.umask(022) |
---|
142 | setup(name = "pykota", version = __version__, |
---|
143 | license = "GNU GPL version 3 or later", |
---|
144 | description = __doc__, |
---|
145 | author = "Jerome Alet", |
---|
146 | author_email = "alet@librelogiciel.com", |
---|
147 | url = "http://www.pykota.com", |
---|
148 | packages = [ "pykota", |
---|
149 | "pykota.storages", |
---|
150 | "pykota.loggers", |
---|
151 | "pykota.accounters", |
---|
152 | "pykota.reporters", |
---|
153 | ], |
---|
154 | scripts = [ "bin/pknotify", "bin/pkusers", "bin/pkinvoice", "bin/pksetup", \ |
---|
155 | "bin/pkrefund", "bin/pkturnkey", "bin/pkbcodes", \ |
---|
156 | "bin/pkbanner", "bin/autopykota", "bin/dumpykota", \ |
---|
157 | "bin/pykosd", "bin/edpykota", "bin/repykota", \ |
---|
158 | "bin/warnpykota", "bin/pykotme", "bin/pkprinters" ], |
---|
159 | data_files = data_files, |
---|
160 | cmdclass = { "install_data" : MyInstallData }) |
---|