Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: third_party/twisted_8_1/twisted/scripts/tap2deb.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4
5
6 import sys, os, string, shutil
7
8 from twisted.python import usage
9
10 class MyOptions(usage.Options):
11 optFlags = [["unsigned", "u"]]
12 optParameters = [["tapfile", "t", "twistd.tap"],
13 ["maintainer", "m", "", "The maintainer's name and email in a specific format: "
14 "'John Doe <johndoe@example.com>'"],
15 ["protocol", "p", ""],
16 ["description", "e", ""],
17 ["long_description", "l", ""],
18 ["set-version", "V", "1.0"],
19 ["debfile", "d", None],
20 ["type", "y", "tap", "type of configuration: 'tap', 'xml, 'sou rce' or 'python' for .tac files"]]
21
22 #zsh_altArgDescr = {"foo":"use this description for foo instead"}
23 #zsh_multiUse = ["foo", "bar"]
24 #zsh_mutuallyExclusive = [("foo", "bar"), ("bar", "baz")]
25 zsh_actions = {"type":"(tap xml source python)"}
26 #zsh_actionDescr = {"logfile":"log file name", "random":"random seed"}
27
28 def postOptions(self):
29 if not self["maintainer"]:
30 raise usage.UsageError, "maintainer must be specified."
31
32
33 type_dict = {
34 'tap': 'file',
35 'python': 'python',
36 'source': 'source',
37 'xml': 'xml',
38 }
39
40 def save_to_file(file, text):
41 open(file, 'w').write(text)
42
43
44 def run():
45
46 try:
47 config = MyOptions()
48 config.parseOptions()
49 except usage.error, ue:
50 sys.exit("%s: %s" % (sys.argv[0], ue))
51
52 tap_file = config['tapfile']
53 base_tap_file = os.path.basename(config['tapfile'])
54 protocol = (config['protocol'] or os.path.splitext(base_tap_file)[0])
55 deb_file = config['debfile'] or 'twisted-'+protocol
56 version = config['set-version']
57 maintainer = config['maintainer']
58 description = config['description'] or ('A Twisted-based server for %(protoc ol)s' %
59 vars())
60 long_description = config['long_description'] or 'Automatically created by t ap2deb'
61 twistd_option = type_dict[config['type']]
62 date = string.strip(os.popen('822-date').read())
63 directory = deb_file + '-' + version
64 python_version = '%s.%s' % sys.version_info[:2]
65
66 if os.path.exists(os.path.join('.build', directory)):
67 os.system('rm -rf %s' % os.path.join('.build', directory))
68 os.makedirs(os.path.join('.build', directory, 'debian'))
69
70 shutil.copy(tap_file, os.path.join('.build', directory))
71
72 save_to_file(os.path.join('.build', directory, 'debian', 'README.Debian'),
73 '''This package was auto-generated by tap2deb\n''')
74
75 save_to_file(os.path.join('.build', directory, 'debian', 'conffiles'),
76 '''\
77 /etc/init.d/%(deb_file)s
78 /etc/default/%(deb_file)s
79 /etc/%(base_tap_file)s
80 ''' % vars())
81
82 save_to_file(os.path.join('.build', directory, 'debian', 'default'),
83 '''\
84 pidfile=/var/run/%(deb_file)s.pid
85 rundir=/var/lib/%(deb_file)s/
86 file=/etc/%(tap_file)s
87 logfile=/var/log/%(deb_file)s.log
88 ''' % vars())
89
90 save_to_file(os.path.join('.build', directory, 'debian', 'init.d'),
91 '''\
92 #!/bin/sh
93
94 PATH=/sbin:/bin:/usr/sbin:/usr/bin
95
96 pidfile=/var/run/%(deb_file)s.pid \
97 rundir=/var/lib/%(deb_file)s/ \
98 file=/etc/%(tap_file)s \
99 logfile=/var/log/%(deb_file)s.log
100
101 [ -r /etc/default/%(deb_file)s ] && . /etc/default/%(deb_file)s
102
103 test -x /usr/bin/twistd%(python_version)s || exit 0
104 test -r $file || exit 0
105 test -r /usr/share/%(deb_file)s/package-installed || exit 0
106
107
108 case "$1" in
109 start)
110 echo -n "Starting %(deb_file)s: twistd"
111 start-stop-daemon --start --quiet --exec /usr/bin/twistd%(python_version )s -- \
112 --pidfile=$pidfile \
113 --rundir=$rundir \
114 --%(twistd_option)s=$file \
115 --logfile=$logfile
116 echo "."
117 ;;
118
119 stop)
120 echo -n "Stopping %(deb_file)s: twistd"
121 start-stop-daemon --stop --quiet \
122 --pidfile $pidfile
123 echo "."
124 ;;
125
126 restart)
127 $0 stop
128 $0 start
129 ;;
130
131 force-reload)
132 $0 restart
133 ;;
134
135 *)
136 echo "Usage: /etc/init.d/%(deb_file)s {start|stop|restart|force-reload}" >&2
137 exit 1
138 ;;
139 esac
140
141 exit 0
142 ''' % vars())
143
144 os.chmod(os.path.join('.build', directory, 'debian', 'init.d'), 0755)
145
146 save_to_file(os.path.join('.build', directory, 'debian', 'postinst'),
147 '''\
148 #!/bin/sh
149 update-rc.d %(deb_file)s defaults >/dev/null
150 invoke-rc.d %(deb_file)s start
151 ''' % vars())
152
153 save_to_file(os.path.join('.build', directory, 'debian', 'prerm'),
154 '''\
155 #!/bin/sh
156 invoke-rc.d %(deb_file)s stop
157 ''' % vars())
158
159 save_to_file(os.path.join('.build', directory, 'debian', 'postrm'),
160 '''\
161 #!/bin/sh
162 if [ "$1" = purge ]; then
163 update-rc.d %(deb_file)s remove >/dev/null
164 fi
165 ''' % vars())
166
167 save_to_file(os.path.join('.build', directory, 'debian', 'changelog'),
168 '''\
169 %(deb_file)s (%(version)s) unstable; urgency=low
170
171 * Created by tap2deb
172
173 -- %(maintainer)s %(date)s
174
175 ''' % vars())
176
177 save_to_file(os.path.join('.build', directory, 'debian', 'control'),
178 '''\
179 Source: %(deb_file)s
180 Section: net
181 Priority: extra
182 Maintainer: %(maintainer)s
183 Build-Depends-Indep: debhelper
184 Standards-Version: 3.5.6
185
186 Package: %(deb_file)s
187 Architecture: all
188 Depends: python%(python_version)s-twisted
189 Description: %(description)s
190 %(long_description)s
191 ''' % vars())
192
193 save_to_file(os.path.join('.build', directory, 'debian', 'copyright'),
194 '''\
195 This package was auto-debianized by %(maintainer)s on
196 %(date)s
197
198 It was auto-generated by tap2deb
199
200 Upstream Author(s):
201 Moshe Zadka <moshez@twistedmatrix.com> -- tap2deb author
202
203 Copyright:
204
205 Insert copyright here.
206 ''' % vars())
207
208 save_to_file(os.path.join('.build', directory, 'debian', 'dirs'),
209 '''\
210 etc/init.d
211 etc/default
212 var/lib/%(deb_file)s
213 usr/share/doc/%(deb_file)s
214 usr/share/%(deb_file)s
215 ''' % vars())
216
217 save_to_file(os.path.join('.build', directory, 'debian', 'rules'),
218 '''\
219 #!/usr/bin/make -f
220
221 export DH_COMPAT=1
222
223 build: build-stamp
224 build-stamp:
225 dh_testdir
226 touch build-stamp
227
228 clean:
229 dh_testdir
230 dh_testroot
231 rm -f build-stamp install-stamp
232 dh_clean
233
234 install: install-stamp
235 install-stamp: build-stamp
236 dh_testdir
237 dh_testroot
238 dh_clean -k
239 dh_installdirs
240
241 # Add here commands to install the package into debian/tmp.
242 cp %(base_tap_file)s debian/tmp/etc/
243 cp debian/init.d debian/tmp/etc/init.d/%(deb_file)s
244 cp debian/default debian/tmp/etc/default/%(deb_file)s
245 cp debian/copyright debian/tmp/usr/share/doc/%(deb_file)s/
246 cp debian/README.Debian debian/tmp/usr/share/doc/%(deb_file)s/
247 touch debian/tmp/usr/share/%(deb_file)s/package-installed
248 touch install-stamp
249
250 binary-arch: build install
251
252 binary-indep: build install
253 dh_testdir
254 dh_testroot
255 dh_strip
256 dh_compress
257 dh_installchangelogs
258 dh_fixperms
259 dh_installdeb
260 dh_shlibdeps
261 dh_gencontrol
262 dh_md5sums
263 dh_builddeb
264
265 source diff:
266 @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
267
268 binary: binary-indep binary-arch
269 .PHONY: build clean binary-indep binary-arch binary install
270 ''' % vars())
271
272 os.chmod(os.path.join('.build', directory, 'debian', 'rules'), 0755)
273
274 os.chdir('.build/%(directory)s' % vars())
275 os.system('dpkg-buildpackage -rfakeroot'+ ['', ' -uc -us'][config['unsigned' ]])
276
277 if __name__ == '__main__':
278 run()
279
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/scripts/mktap.py ('k') | third_party/twisted_8_1/twisted/scripts/tap2rpm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698