[695] | 1 | #! /usr/bin/env python |
---|
[1144] | 2 | # -*- coding: ISO-8859-15 -*- |
---|
[695] | 3 | # |
---|
[3259] | 4 | # PyKota : Print Quotas for CUPS |
---|
[695] | 5 | # |
---|
[3133] | 6 | # (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com> |
---|
[3259] | 7 | # This program is free software: you can redistribute it and/or modify |
---|
[873] | 8 | # it under the terms of the GNU General Public License as published by |
---|
[3259] | 9 | # the Free Software Foundation, either version 3 of the License, or |
---|
[873] | 10 | # (at your option) any later version. |
---|
[3259] | 11 | # |
---|
[873] | 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 |
---|
[3259] | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
[695] | 19 | # |
---|
| 20 | # $Id$ |
---|
| 21 | # |
---|
[2028] | 22 | # |
---|
[695] | 23 | |
---|
| 24 | import sys |
---|
| 25 | import glob |
---|
| 26 | import os |
---|
[3005] | 27 | import stat |
---|
[884] | 28 | import shutil |
---|
[996] | 29 | try : |
---|
| 30 | from distutils.core import setup |
---|
[3005] | 31 | from distutils.command.install_data import install_data |
---|
[997] | 32 | except ImportError, msg : |
---|
| 33 | sys.stderr.write("%s\n" % msg) |
---|
[996] | 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) |
---|
[695] | 36 | |
---|
| 37 | sys.path.insert(0, "pykota") |
---|
| 38 | from pykota.version import __version__, __doc__ |
---|
| 39 | |
---|
| 40 | data_files = [] |
---|
| 41 | mofiles = glob.glob(os.sep.join(["po", "*", "*.mo"])) |
---|
| 42 | for mofile in mofiles : |
---|
| 43 | lang = mofile.split(os.sep)[1] |
---|
| 44 | directory = os.sep.join(["share", "locale", lang, "LC_MESSAGES"]) |
---|
| 45 | data_files.append((directory, [ mofile ])) |
---|
[839] | 46 | |
---|
[1592] | 47 | docdir = "share/doc/pykota" |
---|
[3156] | 48 | docfiles = ["README", "FAQ", "SECURITY", "COPYING", "LICENSE", "CREDITS", "TODO"] |
---|
| 49 | if os.path.exists("ChangeLog") : |
---|
| 50 | docfiles.append("ChangeLog") |
---|
[1297] | 51 | data_files.append((docdir, docfiles)) |
---|
[1279] | 52 | |
---|
[1307] | 53 | docfiles = glob.glob(os.sep.join(["docs", "*.pdf"])) |
---|
[1658] | 54 | docfiles += glob.glob(os.sep.join(["docs", "*.sx?"])) |
---|
[1307] | 55 | data_files.append((docdir, docfiles)) |
---|
| 56 | |
---|
| 57 | docfiles = glob.glob(os.sep.join(["docs", "pykota", "*.html"])) |
---|
| 58 | data_files.append((os.path.join(docdir, "html"), docfiles)) |
---|
| 59 | |
---|
[1658] | 60 | docfiles = glob.glob(os.sep.join(["openoffice", "*.sx?"])) |
---|
[1307] | 61 | docfiles += glob.glob(os.sep.join(["openoffice", "*.png"])) |
---|
| 62 | docfiles += glob.glob(os.sep.join(["openoffice", "README"])) |
---|
| 63 | data_files.append((os.path.join(docdir, "openoffice"), docfiles)) |
---|
| 64 | |
---|
[3214] | 65 | docfiles = glob.glob(os.sep.join(["qa-assistant", "*.xml"])) |
---|
| 66 | docfiles += glob.glob(os.sep.join(["qa-assistant", "README"])) |
---|
| 67 | data_files.append((os.path.join(docdir, "qa-assistant"), docfiles)) |
---|
| 68 | |
---|
[839] | 69 | directory = os.sep.join(["share", "man", "man1"]) |
---|
| 70 | manpages = glob.glob(os.sep.join(["man", "*.1"])) |
---|
| 71 | data_files.append((directory, manpages)) |
---|
[695] | 72 | |
---|
[1829] | 73 | modirs = [ os.path.split(os.path.split(mof)[0])[1] for mof in mofiles ] |
---|
| 74 | for dir in modirs : |
---|
| 75 | directory = os.sep.join(["share", "man", dir, "man1"]) |
---|
| 76 | manpages = glob.glob(os.sep.join(["man", dir, "*.1"])) |
---|
| 77 | data_files.append((directory, manpages)) |
---|
| 78 | |
---|
[1345] | 79 | directory = os.sep.join(["share", "pykota"]) |
---|
[2383] | 80 | data_files.append((directory, ["checkdeps.py", "bin/cupspykota", \ |
---|
[2469] | 81 | "bin/waitprinter.sh", \ |
---|
[2383] | 82 | "bin/papwaitprinter.sh", \ |
---|
| 83 | "bin/mailandpopup.sh", \ |
---|
| 84 | "untested/pjl/pagecount.pjl", \ |
---|
| 85 | "untested/pjl/status.pjl", \ |
---|
| 86 | "untested/netatalk/netatalk.sh", \ |
---|
| 87 | "untested/netatalk/pagecount.ps"])) |
---|
[1345] | 88 | |
---|
[1905] | 89 | data_files.append((os.sep.join([directory, "conf"]), ["conf/README", "conf/pykota.conf.sample", "conf/pykotadmin.conf.sample"])) |
---|
| 90 | |
---|
[2175] | 91 | data_files.append((os.sep.join([directory, "cgi-bin"]), ["cgi-bin/README", "cgi-bin/printquota.cgi", "cgi-bin/dumpykota.cgi", "cgi-bin/pykotme.cgi"])) |
---|
[1905] | 92 | |
---|
[1911] | 93 | 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"])))) |
---|
[1907] | 94 | |
---|
[2508] | 95 | data_files.append((os.sep.join([directory, "stylesheets"]), glob.glob(os.sep.join(["stylesheets", "*.css"])) + [ "stylesheets/README" ])) |
---|
| 96 | |
---|
[1905] | 97 | pgdirectory = os.sep.join([directory, "postgresql"]) |
---|
| 98 | data_files.append((pgdirectory, ["initscripts/postgresql/README.postgresql", "initscripts/postgresql/pykota-postgresql.sql"])) |
---|
| 99 | |
---|
| 100 | ldapdirectory = os.sep.join([directory, "ldap"]) |
---|
| 101 | data_files.append((ldapdirectory, ["initscripts/ldap/README.ldap", "initscripts/ldap/pykota.schema", "initscripts/ldap/pykota-sample.ldif"])) |
---|
| 102 | |
---|
[2638] | 103 | mysqldirectory = os.sep.join([directory, "mysql"]) |
---|
| 104 | data_files.append((mysqldirectory, ["initscripts/mysql/README.mysql", "initscripts/mysql/pykota-mysql.sql"])) |
---|
| 105 | |
---|
[2748] | 106 | sqlitedirectory = os.sep.join([directory, "sqlite"]) |
---|
| 107 | data_files.append((sqlitedirectory, ["initscripts/sqlite/README.sqlite", "initscripts/sqlite/pykota-sqlite.sql"])) |
---|
| 108 | |
---|
[3005] | 109 | class MyInstallData(install_data) : |
---|
| 110 | """A special class to ensure permissions are OK on the cupspykota backend.""" |
---|
| 111 | def run(self) : |
---|
| 112 | """Launches the normal installation and then tweaks permissions.""" |
---|
| 113 | install_data.run(self) |
---|
| 114 | if not self.dry_run : |
---|
| 115 | cupspykota = [ filename for filename in self.get_outputs() if filename.endswith("cupspykota") ][0] |
---|
| 116 | os.chmod(cupspykota, stat.S_IRWXU) |
---|
| 117 | |
---|
[2434] | 118 | os.umask(022) |
---|
[695] | 119 | setup(name = "pykota", version = __version__, |
---|
[3259] | 120 | license = "GNU GPL version 3 or later", |
---|
[695] | 121 | description = __doc__, |
---|
| 122 | author = "Jerome Alet", |
---|
| 123 | author_email = "alet@librelogiciel.com", |
---|
[2909] | 124 | url = "http://www.pykota.com", |
---|
[1483] | 125 | packages = [ "pykota", "pykota.storages", "pykota.loggers", "pykota.accounters", "pykota.reporters" ], |
---|
[3033] | 126 | scripts = [ "bin/pknotify", "bin/pkusers", "bin/pkinvoice", "bin/pksetup", \ |
---|
[3063] | 127 | "bin/pkrefund", "bin/pkturnkey", "bin/pkbcodes", "bin/pkmail", \ |
---|
[2699] | 128 | "bin/pkbanner", "bin/autopykota", "bin/dumpykota", \ |
---|
| 129 | "bin/pykosd", "bin/edpykota", "bin/repykota", \ |
---|
| 130 | "bin/warnpykota", "bin/pykotme", "bin/pkprinters" ], |
---|
[3005] | 131 | data_files = data_files, |
---|
| 132 | cmdclass = { "install_data" : MyInstallData }) |
---|