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 (>= 2.7)
    29  # Project  : Cedar Backup, release 2
    30  # Purpose  : Implements customized behavior.
    31  #
    32  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    33
    34  ########################################################################
    35  # Module documentation
    36  ########################################################################
    37
    38  """
    39  Implements customized behavior.
    40
    41  Some behaviors need to vary when packaged for certain platforms.  For instance,
    42  while Cedar Backup generally uses cdrecord and mkisofs, Debian ships compatible
    43  utilities called wodim and genisoimage. I want there to be one single place
    44  where Cedar Backup is patched for Debian, rather than having to maintain a
    45  variety of patches in different places.
    46
    47  @author: Kenneth J. Pronovici <pronovic@ieee.org>
    48  """
    49
    50  ########################################################################
    51  # Imported modules
    52  ########################################################################
    53
    54  # System modules
    55  import logging
    56
    57
    58  ########################################################################
    59  # Module-wide constants and variables
    60  ########################################################################
    61
    62  logger = logging.getLogger("CedarBackup2.log.customize")
    63
    64  PLATFORM = "standard"
    65  #PLATFORM = "debian"
    66
    67  DEBIAN_CDRECORD = "/usr/bin/wodim"
    68  DEBIAN_MKISOFS = "/usr/bin/genisoimage"
    69
    70
    71  #######################################################################
    72  # Public functions
    73  #######################################################################
    74
    75  ################################
    76  # customizeOverrides() function
    77  ################################
    78
    79 -def customizeOverrides(config, platform=PLATFORM):
    80     """
    81     Modify command overrides based on the configured platform.
    82
    83     On some platforms, we want to add command overrides to configuration.  Each
    84     override will only be added if the configuration does not already contain an
    85     override with the same name.  That way, the user still has a way to choose
    86     their own version of the command if they want.
    87
    88     @param config: Configuration to modify
    89     @param platform: Platform that is in use
    90     """
    91     if platform == "debian":
    92        logger.info("Overriding cdrecord for Debian platform: %s", DEBIAN_CDRECORD)
    93        config.options.addOverride("cdrecord", DEBIAN_CDRECORD)
    94        logger.info("Overriding mkisofs for Debian platform: %s", DEBIAN_MKISOFS)
    95        config.options.addOverride("mkisofs", DEBIAN_MKISOFS)
    96