Changeset 1813

Show
Ignore:
Timestamp:
10/13/04 09:45:01 (20 years ago)
Author:
jalet
Message:

Modified installation script to please both me and the Debian packagers

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/setup.py

    r1771 r1813  
    2424# 
    2525# $Log$ 
     26# Revision 1.54  2004/10/13 07:45:01  jalet 
     27# Modified installation script to please both me and the Debian packagers 
     28# 
    2629# Revision 1.53  2004/10/04 21:25:29  jalet 
    2730# dumpykota can now output datas in the XML format 
     
    206209# 
    207210# 
     211 
     212######################################################### 
     213 
     214# 
     215# IMPORTANT : Modify the variable below if needed  
     216# 
     217# 0 - You're NOT trying to build a Debian package  
     218# 
     219# 1 - You ARE trying to build a Debian package 
     220# 
     221DEBIAN_BUILD_PACKAGE = 0 
     222 
     223######################################################### 
     224 
    208225 
    209226import sys 
     
    225242ACTION_ABORT = 1 
    226243 
    227 #ETC_DIR = "./debian/tmp/etc/pykota/" 
    228 ETC_DIR = "/etc/pykota/" 
     244if DEBIAN_BUILD_PACKAGE : 
     245    ETC_DIR = "./debian/tmp/etc/pykota/" 
     246else :     
     247    ETC_DIR = "/etc/pykota/" 
    229248 
    230249def checkOldModule(path) : 
     
    233252    for ext in ["py", "pyc", "pyo"] : 
    234253        fullname = "%s.%s" % (fname, ext) 
    235         if os.path.isfile(fullname) : 
     254        if os.path.isfile(fullname) and not DEBIAN_BUILD_PACKAGE : 
    236255            sys.stderr.write("ERROR : old module %s still exists. Remove it and restart installation.\n" % fullname) 
    237256            sys.stderr.write("INSTALLATION ABORTED !\n") 
     
    272291        sys.stdout.write("NO.\n") 
    273292        sys.stderr.write("ERROR : %s not available !\n" % prompt) 
    274         if helper is not None : 
     293        if helper is not None and not DEBIAN_BUILD_PACKAGE : 
    275294            sys.stdout.write("%s\n" % helper) 
    276295            sys.stdout.write("You may continue safely if you don't need this functionnality.\n") 
    277296        answer = raw_input("%s is missing. Do you want to continue anyway (y/N) ? " % prompt) 
    278         if answer[0:1].upper() == 'Y' : 
     297        if DEBIAN_BUILD_PACKAGE : 
     298            return ACTION_CONTINUE 
     299        elif answer[0:1].upper() == 'Y' : 
    279300            return ACTION_CONTINUE 
    280301        else : 
     
    296317                sys.exit(-1) 
    297318                 
    298         if os.path.isfile("/etc/pykota.conf") : 
     319        if os.path.isfile("/etc/pykota.conf") and not DEBIAN_BUILD_PACKAGE : 
    299320            # upgrade from pre-1.14 to 1.14 and above 
    300321            sys.stdout.write("From version 1.14 on, PyKota expects to find its configuration\nfile in /etc/pykota/ instead of /etc/\n") 
     
    315336        else : 
    316337            # first installation 
    317             if os.path.isfile("conf/pykota.conf.sample") : 
    318                 answer = raw_input("Do you want to install\n\tconf/pykota.conf.sample as /etc/pykota/pykota.conf (y/N) ? ") 
    319                 if answer[0:1].upper() == 'Y' : 
    320                     try : 
    321                         shutil.copy("conf/pykota.conf.sample", os.path.join(ETC_DIR,"pykota.conf"))         
    322                         shutil.copy("conf/pykotadmin.conf.sample", os.path.join(ETC_DIR,"pykotadmin.conf"))         
    323                     except IOError, msg :     
    324                         sys.stderr.write("WARNING : Problem while installing sample configuration files in /etc/pykota/, please do it manually.\n%s\n" % msg) 
    325                     else :     
    326                         sys.stdout.write("Configuration file /etc/pykota/pykota.conf and /etc/pykota/pykotadmin.conf installed.\nDon't forget to adapt these files to your needs.\n") 
     338            if DEBIAN_BUILD_PACKAGE : 
     339                try : 
     340                    shutil.copy("conf/pykota.conf.sample", os.path.join(ETC_DIR,"pykota.conf")) 
     341                    shutil.copy("conf/pykotadmin.conf.sample", os.path.join(ETC_DIR,"pykotadmin.conf")) 
     342                except IOError, msg : 
     343                    sys.stderr.write("WARNING : Problem while installing sample configuration files in /etc/pykota/, please do it manually.\n%s\n" % msg) 
     344            else : 
     345                if os.path.isfile("conf/pykota.conf.sample") : 
     346                    answer = raw_input("Do you want to install\n\tconf/pykota.conf.sample as /etc/pykota/pykota.conf (y/N) ? ") 
     347                    if answer[0:1].upper() == 'Y' : 
     348                        try : 
     349                            shutil.copy("conf/pykota.conf.sample", os.path.join(ETC_DIR,"pykota.conf"))         
     350                            shutil.copy("conf/pykotadmin.conf.sample", os.path.join(ETC_DIR,"pykotadmin.conf"))         
     351                        except IOError, msg :     
     352                            sys.stderr.write("WARNING : Problem while installing sample configuration files in /etc/pykota/, please do it manually.\n%s\n" % msg) 
     353                        else :     
     354                            sys.stdout.write("Configuration file /etc/pykota/pykota.conf and /etc/pykota/pykotadmin.conf installed.\nDon't forget to adapt these files to your needs.\n") 
     355                    else :         
     356                        sys.stderr.write("WARNING : PyKota won't run without a configuration file !\n") 
    327357                else :         
    328                     sys.stderr.write("WARNING : PyKota won't run without a configuration file !\n") 
    329             else :         
    330                 # Problem ? 
    331                 sys.stderr.write("WARNING : PyKota's sample configuration file cannot be found.\nWhat you have downloaded seems to be incomplete,\nor you are not in the pykota directory.\nPlease double check, and restart the installation procedure.\n") 
    332             dummy = raw_input("Please press ENTER when you have read the message above. ") 
     358                    # Problem ? 
     359                    sys.stderr.write("WARNING : PyKota's sample configuration file cannot be found.\nWhat you have downloaded seems to be incomplete,\nor you are not in the pykota directory.\nPlease double check, and restart the installation procedure.\n") 
     360                dummy = raw_input("Please press ENTER when you have read the message above. ") 
    333361    else :     
    334362        # already at 1.14 or above. 
    335363        # Now check if old scripts are still in /usr/bin 
    336364        for script in ["cupspykota", "pykota", "waitprinter.sh", "papwaitprinter.sh", "mailandpopup.sh", "pagecount.pl"] : 
    337             if checkOldScript(script) : 
     365            if checkOldScript(script) and not DEBIAN_BUILD_PACKAGE : 
    338366                sys.stderr.write("WARNING : the %s script is still present in /usr/bin, but the new version will be installed in /usr/share/pykota, please remove the %s script from /usr/bin and double check that your configuration is correct.\n" % (script, script)) 
    339367                if script == "cupspykota" : 
     
    397425                sys.stderr.write("INSTALLATION ABORTED BECAUSE CONFIGURATION INCOMPLETE.\n") 
    398426                sys.exit(-1) 
     427 
     428#### INFO #### 
    399429                 
    400430        # Say something about caching mechanism and disabling job history 
    401         sys.stdout.write("You can now activate the database caching mechanism\nwhich is disabled by default.\nIt is especially recommended with the LDAP backend.\n") 
    402         sys.stdout.write("You can now disable the preservation of the complete\njob history which is enabled by default.\nIt is probably more useful with the LDAP backend.\n") 
    403         sys.stdout.write("PLEASE LOOK AT THE SAMPLE CONFIGURATION FILE conf/pykota.conf.sample\n") 
    404         sys.stdout.write("TO LEARN HOW TO DO\n") 
    405         dummy = raw_input("Please press ENTER when you have read the message above. ") 
    406         sys.stdout.write("\n") 
     431        if not DEBIAN_BUILD_PACKAGE : 
     432            sys.stdout.write("You can now activate the database caching mechanism\nwhich is disabled by default.\nIt is especially recommended with the LDAP backend.\n") 
     433            sys.stdout.write("You can now disable the preservation of the complete\njob history which is enabled by default.\nIt is probably more useful with the LDAP backend.\n") 
     434            sys.stdout.write("PLEASE LOOK AT THE SAMPLE CONFIGURATION FILE conf/pykota.conf.sample\n") 
     435            sys.stdout.write("TO LEARN HOW TO DO\n") 
     436            dummy = raw_input("Please press ENTER when you have read the message above. ") 
     437            sys.stdout.write("\n") 
    407438             
    408439    # change files permissions     
     
    410441    os.chmod(os.path.join(ETC_DIR,"pykotadmin.conf"), 0640) 
    411442     
     443#### INFO #### 
     444 
    412445    # WARNING MESSAGE     
    413     sys.stdout.write("WARNING : IF YOU ARE UPGRADING FROM A PRE-1.19alpha17 TO 1.19alpha17 OR ABOVE\n") 
    414     sys.stdout.write("AND USE THE POSTGRESQL BACKEND, THEN YOU HAVE TO MODIFY YOUR\n") 
    415     sys.stdout.write("DATABASE SCHEMA USING initscripts/postgresql/upgrade-to-1.19.sql\n") 
    416     sys.stdout.write("PLEASE READ DOCUMENTATION IN initscripts/postgresql/ TO LEARN HOW TO DO.\n") 
    417     sys.stdout.write("YOU CAN DO THAT AFTER THE INSTALLATION IS FINISHED, OR PRESS CTRL+C NOW.\n") 
    418     sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION\nOR IF YOU ARE ALREADY RUNNING VERSION 1.19alpha17 OR ABOVE.\n\n") 
    419     dummy = raw_input("Please press ENTER when you have read the message above. ") 
    420      
    421     sys.stdout.write("\n\nWARNING : IF YOU ARE UPGRADING FROM A PRE-1.19alpha10 TO 1.19alpha10 OR ABOVE\n") 
    422     sys.stdout.write("YOU **MUST** MODIFY YOUR /etc/pykota/pykota.conf FILE BECAUSE accounter\n") 
    423     sys.stdout.write("AND requester DIRECTIVES SUPPORTED VALUES HAVE CHANGED.\n\n") 
    424     sys.stdout.write("YOU CAN DO THAT AFTER THE INSTALLATION IS FINISHED, OR PRESS CTRL+C NOW.\n") 
    425     sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION\nOR IF YOU ARE ALREADY RUNNING VERSION 1.19alpha10 OR ABOVE.\n\n") 
    426     dummy = raw_input("Please press ENTER when you have read the message above. ") 
     446    if not DEBIAN_BUILD_PACKAGE : 
     447        sys.stdout.write("WARNING : IF YOU ARE UPGRADING FROM A PRE-1.19alpha17 TO 1.19alpha17 OR ABOVE\n") 
     448        sys.stdout.write("AND USE THE POSTGRESQL BACKEND, THEN YOU HAVE TO MODIFY YOUR\n") 
     449        sys.stdout.write("DATABASE SCHEMA USING initscripts/postgresql/upgrade-to-1.19.sql\n") 
     450        sys.stdout.write("PLEASE READ DOCUMENTATION IN initscripts/postgresql/ TO LEARN HOW TO DO.\n") 
     451        sys.stdout.write("YOU CAN DO THAT AFTER THE INSTALLATION IS FINISHED, OR PRESS CTRL+C NOW.\n") 
     452        sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION\nOR IF YOU ARE ALREADY RUNNING VERSION 1.19alpha17 OR ABOVE.\n\n") 
     453        dummy = raw_input("Please press ENTER when you have read the message above. ") 
     454         
     455        sys.stdout.write("\n\nWARNING : IF YOU ARE UPGRADING FROM A PRE-1.19alpha10 TO 1.19alpha10 OR ABOVE\n") 
     456        sys.stdout.write("YOU **MUST** MODIFY YOUR /etc/pykota/pykota.conf FILE BECAUSE accounter\n") 
     457        sys.stdout.write("AND requester DIRECTIVES SUPPORTED VALUES HAVE CHANGED.\n\n") 
     458        sys.stdout.write("YOU CAN DO THAT AFTER THE INSTALLATION IS FINISHED, OR PRESS CTRL+C NOW.\n") 
     459        sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION\nOR IF YOU ARE ALREADY RUNNING VERSION 1.19alpha10 OR ABOVE.\n\n") 
     460        dummy = raw_input("Please press ENTER when you have read the message above. ") 
    427461     
    428462    # checks if some needed Python modules are there or not. 
    429     modulestocheck = [ ("PygreSQL", "pg", "PygreSQL is mandatory if you want to use PostgreSQL as the quota storage backend.\nSee http://www.pygresql.org"),                                             
    430                        ("mxDateTime", "mx.DateTime", "eGenix' mxDateTime is mandatory for PyKota to work.\nSee http://www.egenix.com"),  
    431                        ("Python-LDAP", "ldap", "Python-LDAP is mandatory if you plan to use an LDAP\ndirectory as the quota storage backend.\nSee http://python-ldap.sf.net"), 
    432                        ("Python-OSD", "pyosd", "Python-OSD is recommended if you plan to use the X Window On Screen Display\nprint quota reminder named pykosd."), 
    433                        ("Python-SNMP", "pysnmp", "Python-SNMP is recommended if you plan to use hardware\naccounting with printers which support SNMP.\nSee http://pysnmp.sf.net"), 
    434                        ("Python-JAXML", "jaxml", "Python-JAXML is recommended if you plan to dump datas in the XML format.\nSee http://www.librelogiciel.com/software/"), 
    435                      ] 
    436     commandstocheck = [("SNMP Tools", "snmpget", "SNMP Tools are needed if you want to use SNMP enabled printers."), ("Netatalk", "pap", "Netatalk is needed if you want to use AppleTalk enabled printers.")] 
    437     for (name, module, helper) in modulestocheck : 
    438         action = checkWithPrompt(name, module=module, helper=helper) 
    439         if action == ACTION_ABORT : 
    440             sys.stderr.write("Aborted !\n") 
    441             sys.exit(-1) 
    442              
    443     # checks if some software are there or not. 
    444     for (name, command, helper) in commandstocheck : 
    445         action = checkWithPrompt(name, command=command, helper=helper) 
    446         if action == ACTION_ABORT : 
    447             sys.stderr.write("Aborted !\n") 
    448             sys.exit(-1) 
     463    if not DEBIAN_BUILD_PACKAGE : 
     464        modulestocheck = [ ("PygreSQL", "pg", "PygreSQL is mandatory if you want to use PostgreSQL as the quota storage backend.\nSee http://www.pygresql.org"),                                             
     465                           ("mxDateTime", "mx.DateTime", "eGenix' mxDateTime is mandatory for PyKota to work.\nSee http://www.egenix.com"),  
     466                           ("Python-LDAP", "ldap", "Python-LDAP is mandatory if you plan to use an LDAP\ndirectory as the quota storage backend.\nSee http://python-ldap.sf.net"), 
     467                           ("Python-OSD", "pyosd", "Python-OSD is recommended if you plan to use the X Window On Screen Display\nprint quota reminder named pykosd."), 
     468                           ("Python-SNMP", "pysnmp", "Python-SNMP is recommended if you plan to use hardware\naccounting with printers which support SNMP.\nSee http://pysnmp.sf.net"), 
     469                           ("Python-JAXML", "jaxml", "Python-JAXML is recommended if you plan to dump datas in the XML format.\nSee http://www.librelogiciel.com/software/"), 
     470                         ] 
     471        commandstocheck = [("SNMP Tools", "snmpget", "SNMP Tools are needed if you want to use SNMP enabled printers."), ("Netatalk", "pap", "Netatalk is needed if you want to use AppleTalk enabled printers.")] 
     472        for (name, module, helper) in modulestocheck : 
     473            action = checkWithPrompt(name, module=module, helper=helper) 
     474            if action == ACTION_ABORT : 
     475                sys.stderr.write("Aborted !\n") 
     476                sys.exit(-1) 
     477                 
     478        # checks if some software are there or not. 
     479        for (name, command, helper) in commandstocheck : 
     480            action = checkWithPrompt(name, command=command, helper=helper) 
     481            if action == ACTION_ABORT : 
     482                sys.stderr.write("Aborted !\n") 
     483                sys.exit(-1) 
    449484             
    450485data_files = []