~ubuntu-branches/ubuntu/utopic/calendarserver/utopic

« back to all changes in this revision

Viewing changes to .pc/secure-python-path.patch/setup.py

  • Committer: Package Import Robot
  • Author(s): Rahul Amaram
  • Date: 2012-05-29 18:12:12 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120529181212-mxjdfncopy6vou0f
Tags: 3.2+dfsg-1
* New upstream release
* Moved from using cdbs to dh sequencer
* Modified calenderserver init.d script based on /etc/init.d/skeleton script
* Removed ldapdirectory.patch as the OpenLDAP directory service has been 
  merged upstream
* Moved package to section "net" as calendarserver is more service than 
  library (Closes: #665859)
* Changed Architecture of calendarserver package to any as the package
  now includes compiled architecture dependent Python extensions
* Unowned files are no longer left on the system upon purging
  (Closes: #668731)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
##
 
4
# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
 
5
#
 
6
# Licensed under the Apache License, Version 2.0 (the "License");
 
7
# you may not use this file except in compliance with the License.
 
8
# You may obtain a copy of the License at
 
9
#
 
10
# http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# Unless required by applicable law or agreed to in writing, software
 
13
# distributed under the License is distributed on an "AS IS" BASIS,
 
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
# See the License for the specific language governing permissions and
 
16
# limitations under the License.
 
17
##
 
18
 
 
19
import sys
 
20
import os
 
21
 
 
22
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "support"))
 
23
 
 
24
from version import version
 
25
 
 
26
def find_modules():
 
27
    modules = [
 
28
        "twisted.plugins",
 
29
    ]
 
30
 
 
31
    for root, dirs, files in os.walk("."):
 
32
        excludes = [
 
33
            ".svn",
 
34
            "_trial_temp",
 
35
            "build",
 
36
        ]
 
37
 
 
38
        if root == ".":
 
39
            excludes.append("data")
 
40
 
 
41
        for exclude in excludes:
 
42
            if exclude in dirs:
 
43
                dirs.remove(exclude)
 
44
 
 
45
        if "__init__.py" in files:
 
46
            modules.append(".".join(root.split(os.path.sep)[1:]))
 
47
 
 
48
    return modules
 
49
 
 
50
#
 
51
# Options
 
52
#
 
53
 
 
54
description = "CalDAV/CardDAV protocol extensions to twext.web2.dav",
 
55
long_description = """
 
56
Extends twisted.web2.dav to implement CalDAV/CardDAV-aware resources and methods.
 
57
"""
 
58
 
 
59
classifiers = None
 
60
 
 
61
#
 
62
# Write version file
 
63
#
 
64
 
 
65
version_string = "%s (%s)" % version()
 
66
version_file = file(os.path.join("calendarserver", "version.py"), "w")
 
67
version_file.write('version = "%s"\n' % version_string)
 
68
version_file.close()
 
69
 
 
70
#
 
71
# Set up Extension modules that need to be built
 
72
#
 
73
 
 
74
from distutils.core import Extension
 
75
 
 
76
extensions = [
 
77
    Extension("twext.python.sendmsg",
 
78
              sources=["twext/python/sendmsg.c"])
 
79
]
 
80
 
 
81
if sys.platform == "darwin":
 
82
    extensions.append(
 
83
        Extension(
 
84
            "calendarserver.platform.darwin._sacl",
 
85
            extra_link_args = ["-framework", "Security"],
 
86
            sources = ["calendarserver/platform/darwin/_sacl.c"]
 
87
        )
 
88
    )
 
89
 
 
90
#
 
91
# Run setup
 
92
#
 
93
 
 
94
def doSetup():
 
95
    from distutils.core import setup
 
96
 
 
97
    dist = setup(
 
98
        name             = "Calendar and Contacts Server",
 
99
        version          = version_string,
 
100
        description      = description,
 
101
        long_description = long_description,
 
102
        url              = None,
 
103
        classifiers      = classifiers,
 
104
        author           = "Apple Inc.",
 
105
        author_email     = None,
 
106
        license          = None,
 
107
        platforms        = ["all"],
 
108
        packages         = find_modules(),
 
109
        package_data     = {
 
110
                             "twistedcaldav": [
 
111
                               "*.html",
 
112
                               "zoneinfo/*.ics",
 
113
                               "zoneinfo/*/*.ics",
 
114
                               "zoneinfo/*/*/*.ics",
 
115
                               "images/*/*.jpg",
 
116
                             ],
 
117
                             "calendarserver.webadmin": [
 
118
                                 "*.html"
 
119
                             ],
 
120
                             "twistedcaldav.directory": [
 
121
                                 "*.html"
 
122
                             ],
 
123
                             "txdav.common.datastore": [
 
124
                               "sql_schema/*.sql",
 
125
                               "sql_schema/*/*.sql",
 
126
                               "sql_schema/*/*/*.sql",
 
127
                             ],
 
128
                           },
 
129
        scripts          = [
 
130
                             "bin/caldavd",
 
131
                             "bin/calendarserver_export",
 
132
                            #"bin/calendarserver_load_augmentdb",
 
133
                            #"bin/calendarserver_make_partition",
 
134
                            #"bin/calendarserver_manage_augments",
 
135
                             "bin/calendarserver_manage_principals",
 
136
                             "bin/calendarserver_command_gateway",
 
137
                             "bin/calendarserver_purge_events",
 
138
                             "bin/calendarserver_purge_attachments",
 
139
                             "bin/calendarserver_purge_principals",
 
140
                             "bin/calendarserver_migrate_resources",
 
141
                             "bin/calendarserver_monitor_notifications",
 
142
                             "bin/calendarserver_bootstrap_database",
 
143
                           ],
 
144
        data_files       = [ ("/etc/caldavd", ["conf/caldavd.plist", "conf/sudoers.plist",
 
145
                                               "conf/auth/accounts.xml", "conf/auth/accounts.dtd",
 
146
                                               "conf/servertoserver.xml", "conf/servertoserver.dtd",
 
147
                                               "conf/resources.xml"]) ],
 
148
        ext_modules      = extensions,
 
149
        py_modules       = [],
 
150
    )
 
151
 
 
152
    if "install" in dist.commands:
 
153
        install_obj = dist.command_obj["install"]
 
154
        if install_obj.root is None:
 
155
            return
 
156
        install_scripts = os.path.normpath(install_obj.install_scripts)
 
157
        install_lib = os.path.normpath(install_obj.install_lib)
 
158
        root = os.path.normpath(install_obj.root)
 
159
        base = os.path.normpath(install_obj.install_base)
 
160
 
 
161
        if root:
 
162
            install_lib = install_lib[len(root):]
 
163
 
 
164
        for script in dist.scripts:
 
165
            scriptPath = os.path.join(install_scripts, os.path.basename(script))
 
166
 
 
167
            print "rewriting %s" % (scriptPath,)
 
168
 
 
169
            script = []
 
170
 
 
171
            fileType = None
 
172
 
 
173
            for line in file(scriptPath, "r"):
 
174
                if not fileType:
 
175
                    if line.startswith("#!"):
 
176
                        if "python" in line.lower():
 
177
                            fileType = "python"
 
178
                        elif "sh" in line.lower():
 
179
                            fileType = "sh"
 
180
 
 
181
                line = line.rstrip("\n")
 
182
                if fileType == "sh":
 
183
                    if line == "#PYTHONPATH":
 
184
                        script.append('PYTHONPATH="%s:$PYTHONPATH"' % (install_lib,))
 
185
                    elif line == "#PATH":
 
186
                        script.append('PATH="%s:$PATH"' % (os.path.join(base, "bin"),))
 
187
                    else:
 
188
                        script.append(line)
 
189
 
 
190
                elif fileType == "python":
 
191
                    if line == "#PYTHONPATH":
 
192
                        script.append('PYTHONPATH="%s"' % (install_lib,))
 
193
                    elif line == "#PATH":
 
194
                        script.append('PATH="%s"' % (os.path.join(base, "bin"),))
 
195
                    else:
 
196
                        script.append(line)
 
197
 
 
198
                else:
 
199
                    script.append(line)
 
200
 
 
201
            newScript = open(scriptPath, "w")
 
202
            newScript.write("\n".join(script))
 
203
            newScript.close()
 
204
 
 
205
 
 
206
 
 
207
if __name__ == "__main__":
 
208
    doSetup()
 
209
 
 
210