Debian Codegraph @

src/CedarBackup3/customize.py

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