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