CedarBackup2.customize

Package CedarBackup2 :: Module customize |
[hide private]
[frames] | no frames]

# Source Code for Module CedarBackup2.customize

     1  # -*- coding: iso-8859-1 -*-
     2  # vim: set ft=python ts=3 sw=3 expandtab:
     3  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
     4  #
     5  #              C E D A R
     6  #          S O L U T I O N S       "Software done right."
     7  #           S O F T W A R E
     8  #
     9  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    10  #
    11  # Copyright (c) 2010 Kenneth J. Pronovici.
    12  # All rights reserved.
    13  #
    14  # This program is free software; you can redistribute it and/or
    15  # modify it under the terms of the GNU General Public License,
    16  # Version 2, as published by the Free Software Foundation.
    17  #
    18  # This program is distributed in the hope that it will be useful,
    19  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    21  #
    22  # Copies of the GNU General Public License are available from
    23  # the Free Software Foundation website, http://www.gnu.org/.
    24  #
    25  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    26  #
    27  # Author   : Kenneth J. Pronovici <pronovic@ieee.org>
    28  # Language : Python (>= 2.5)
    29  # Project  : Cedar Backup, release 2
    30  # Revision : $Id: customize.py 998 2010-07-07 19:56:08Z pronovic $
    31  # Purpose  : Implements customized behavior.
    32  #
    33  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    34
    35  ########################################################################
    36  # Module documentation
    37  ########################################################################
    38
    39  """
    40  Implements customized behavior.
    41
    42  Some behaviors need to vary when packaged for certain platforms.  For instance,
    43  while Cedar Backup generally uses cdrecord and mkisofs, Debian ships compatible
    44  utilities called wodim and genisoimage. I want there to be one single place
    45  where Cedar Backup is patched for Debian, rather than having to maintain a
    46  variety of patches in different places.
    47
    48  @author: Kenneth J. Pronovici <pronovic@ieee.org>
    49  """
    50
    51  ########################################################################
    52  # Imported modules
    53  ########################################################################
    54
    55  # System modules
    56  import logging
    57
    58
    59  ########################################################################
    60  # Module-wide constants and variables
    61  ########################################################################
    62
    63  logger = logging.getLogger("CedarBackup2.log.customize")
    64
    65  PLATFORM = "standard"
    66  #PLATFORM = "debian"
    67
    68  DEBIAN_CDRECORD = "/usr/bin/wodim"
    69  DEBIAN_MKISOFS = "/usr/bin/genisoimage"
    70
    71
    72  #######################################################################
    73  # Public functions
    74  #######################################################################
    75
    76  ################################
    77  # customizeOverrides() function
    78  ################################
    79
    80 -def customizeOverrides(config, platform=PLATFORM):
    81     """
    82     Modify command overrides based on the configured platform.
    83
    84     On some platforms, we want to add command overrides to configuration.  Each
    85     override will only be added if the configuration does not already contain an
    86     override with the same name.  That way, the user still has a way to choose
    87     their own version of the command if they want.
    88
    89     @param config: Configuration to modify
    90     @param platform: Platform that is in use
    91     """
    92     if platform == "debian":
    93        logger.info("Overriding cdrecord for Debian platform: %s" % DEBIAN_CDRECORD)
    94        config.options.addOverride("cdrecord", DEBIAN_CDRECORD)
    95        logger.info("Overriding mkisofs for Debian platform: %s" % DEBIAN_MKISOFS)
    96        config.options.addOverride("mkisofs", DEBIAN_MKISOFS)
    97