nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #!/usr/bin/env python |
2 | |||
3 | # idl2deb - quick hack by W. Martin Borgert <debacle@debian.org> to create |
||
4 | # Debian GNU/Linux packages from idl2wrs modules for Wireshark. |
||
5 | # Copyright 2003, 2008, W. Martin Borgert |
||
6 | |||
7 | # Makefile.am and configure.ac code by: |
||
8 | # Copyright 2001, Ericsson Inc. |
||
9 | # Frank Singleton <frank.singleton@ericsson.com> |
||
10 | # |
||
11 | # Wireshark - Network traffic analyzer |
||
12 | # By Gerald Combs <gerald@wireshark.com> |
||
13 | # Copyright 1998 Gerald Combs |
||
14 | |||
15 | # This program is free software; you can redistribute it and/or |
||
16 | # modify it under the terms of the GNU General Public License |
||
17 | # as published by the Free Software Foundation; either version 2 |
||
18 | # of the License, or (at your option) any later version. |
||
19 | # |
||
20 | # This program is distributed in the hope that it will be useful, |
||
21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
23 | # GNU General Public License for more details. |
||
24 | # |
||
25 | # You should have received a copy of the GNU General Public License |
||
26 | # along with this program; if not, write to the Free Software |
||
27 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
28 | |||
29 | import optparse |
||
30 | import os |
||
31 | import string |
||
32 | import sys |
||
33 | import time |
||
34 | |||
35 | scriptinfo = """idl2deb version 2008-03-10 |
||
36 | Copyright 2003, 2008, W. Martin Borgert |
||
37 | Free software, released under the terms of the GPL.""" |
||
38 | |||
39 | def bootstrap(): |
||
40 | """Generate Makefile.in and configure script.""" |
||
41 | os.system("aclocal") |
||
42 | os.system("autoconf") |
||
43 | os.system("libtoolize --automake --copy --force") |
||
44 | os.system("automake --add-missing --copy --foreign") |
||
45 | |||
46 | def create_file(preserve, filename, content, mode = None): |
||
47 | """Create a file with given content.""" |
||
48 | if preserve and os.path.isfile(filename): |
||
49 | return |
||
50 | f = open(filename, 'w') |
||
51 | f.write(content) |
||
52 | f.close() |
||
53 | if mode: |
||
54 | os.chmod(filename, mode) |
||
55 | |||
56 | def create_files(version, deb, email, idl, name, preserve, iso, rfc): |
||
57 | """Create all files for the .deb build process.""" |
||
58 | base = os.path.basename(idl.lower().split(".idl")[0]) |
||
59 | create_file(preserve, "Makefile.am", """# |
||
60 | |||
61 | plugindir = @plugindir@ |
||
62 | |||
63 | plugin_LTLIBRARIES = %s.la |
||
64 | %s_la_SOURCES = packet-%s.c |
||
65 | %s_la_LDFLAGS = -module -avoid-version |
||
66 | |||
67 | GLIB_CFLAGS = `pkg-config --cflags glib-2.0` |
||
68 | GLIB_LIBS = `pkg-config --libs glib-2.0` |
||
69 | BUILT_SOURCES = packet-%s.c |
||
70 | INCLUDES = -DHAVE_CONFIG -DHAVE_SYS_TYPES_H -DHAVE_SYS_TIME_H \\ |
||
71 | -DHAVE_STDARG_H -D_U_=\"__attribute__((unused))\" \\ |
||
72 | -I/usr/include/wireshark -DWS_VAR_IMPORT=extern $(GLIB_CFLAGS) |
||
73 | LDADD = $(GLIB_LIBS) |
||
74 | |||
75 | # Libs must be cleared, or else libtool won't create a shared module. |
||
76 | # If your module needs to be linked against any particular libraries, |
||
77 | # add them here. |
||
78 | LIBS = |
||
79 | |||
80 | %s_la_DEPENDENCIES = packet-%s-static.o |
||
81 | |||
82 | packet-%s-static.o: packet-%s.c |
||
83 | $(LTCOMPILE) -c -o packet-%s-static.o \\ |
||
84 | -D__WIRESHARK_STATIC__ packet-%s.c |
||
85 | |||
86 | packet-%s.c: """ % ((base,) * 12) + idl + """ |
||
87 | $(IDL2WRS) -I. $< > $@ |
||
88 | """) |
||
89 | |||
90 | create_file(preserve, "configure.ac", """AC_INIT(%s, 1.0) |
||
91 | AC_PROG_LIBTOOL |
||
92 | AM_INIT_AUTOMAKE |
||
93 | AM_MAINTAINER_MODE |
||
94 | AC_PROG_CC |
||
95 | AC_STDC_HEADERS |
||
96 | AC_PROG_INSTALL |
||
97 | AC_SUBST(CFLAGS) |
||
98 | AC_SUBST(CPPFLAGS) |
||
99 | AC_SUBST(LDFLAGS) |
||
100 | PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.2.2) |
||
101 | AC_SUBST(GLIB_CFLAGS) |
||
102 | AC_SUBST(GLIB_LIBS) |
||
103 | IDL2WRS=\"`type -p idl2wrs`\" |
||
104 | AC_SUBST(IDL2WRS) |
||
105 | WIRESHARK_VERSION=\"%s\" |
||
106 | plugindir=\"$libdir/wireshark/plugins/$WIRESHARK_VERSION\" |
||
107 | AC_SUBST(plugindir) |
||
108 | AC_OUTPUT([Makefile]) |
||
109 | """ % (base, version)) |
||
110 | |||
111 | if not os.path.isdir("debian"): |
||
112 | os.mkdir("debian") |
||
113 | |||
114 | create_file(preserve, "debian/rules", """#!/usr/bin/make -f |
||
115 | |||
116 | include /usr/share/cdbs/1/rules/debhelper.mk |
||
117 | include /usr/share/cdbs/1/class/autotools.mk |
||
118 | |||
119 | PREFIX=`pwd`/debian/wireshark-giop-%s |
||
120 | |||
121 | binary-post-install/wireshark-giop-%s:: |
||
122 | rm -f $(PREFIX)/usr/lib/wireshark/plugins/%s/*.a |
||
123 | """ % (base, base, version), 0755) |
||
124 | |||
125 | create_file(preserve, "debian/control", """Source: wireshark-giop-%s |
||
126 | Section: net |
||
127 | Priority: optional |
||
128 | Maintainer: %s <%s> |
||
129 | Standards-Version: 3.6.1.0 |
||
130 | Build-Depends: wireshark-dev, autotools-dev, debhelper, cdbs |
||
131 | |||
132 | Package: wireshark-giop-%s |
||
133 | Architecture: any |
||
134 | Depends: wireshark (= %s), ${shlibs:Depends} |
||
135 | Description: GIOP dissector for CORBA interface %s |
||
136 | This package provides a dissector for GIOP (General Inter-ORB |
||
137 | Protocol) for the Wireshark protocol analyser. It decodes the CORBA |
||
138 | (Common Object Request Broker Architecture) interfaces described |
||
139 | in the IDL (Interface Definition Language) file '%s.idl'. |
||
140 | """ % (base, name, email, base, deb, base, base)) |
||
141 | |||
142 | create_file(preserve, "debian/changelog", |
||
143 | """wireshark-giop-%s (0.0.1-1) unstable; urgency=low |
||
144 | |||
145 | * Automatically created package. |
||
146 | |||
147 | -- %s <%s> %s |
||
148 | """ % (base, name, email, rfc)) |
||
149 | |||
150 | create_file(preserve, "debian/copyright", |
||
151 | """This package has been created automatically by idl2deb on |
||
152 | %s for Debian GNU/Linux. |
||
153 | |||
154 | Wireshark: http://www.wireshark.org/ |
||
155 | |||
156 | Copyright: |
||
157 | |||
158 | GPL, as evidenced by existence of GPL license file \"COPYING\". |
||
159 | (the GNU GPL may be viewed on Debian systems in |
||
160 | /usr/share/common-licenses/GPL) |
||
161 | """ % (iso)) |
||
162 | |||
163 | def get_wrs_version(): |
||
164 | """Detect version of wireshark-dev package.""" |
||
165 | deb = os.popen( |
||
166 | "dpkg-query -W --showformat='${Version}' wireshark-dev").read() |
||
167 | debv = string.find(deb, "-") |
||
168 | if debv == -1: debv = len(deb) |
||
169 | version = deb[string.find(deb, ":")+1:debv] |
||
170 | return version, deb |
||
171 | |||
172 | def get_time(): |
||
173 | """Detect current time and return ISO and RFC time string.""" |
||
174 | currenttime = time.gmtime() |
||
175 | return time.strftime("%Y-%m-%d %H:%M:%S +0000", currenttime), \ |
||
176 | time.strftime("%a, %d %b %Y %H:%M:%S +0000", currenttime) |
||
177 | |||
178 | def main(): |
||
179 | opts = process_opts(sys.argv) |
||
180 | iso, rfc = get_time() |
||
181 | version, deb = get_wrs_version() |
||
182 | create_files(version, deb, |
||
183 | opts.email, opts.idl, opts.name, opts.preserve, |
||
184 | iso, rfc) |
||
185 | bootstrap() |
||
186 | os.system("dpkg-buildpackage " + opts.dbopts) |
||
187 | |||
188 | def process_opts(argv): |
||
189 | """Process command line options.""" |
||
190 | parser = optparse.OptionParser( |
||
191 | version=scriptinfo, |
||
192 | description="""Example: |
||
193 | %prog -e me@foo.net -i bar.idl -n \"My Name\" -d \"-rfakeroot -uc -us\"""") |
||
194 | parser.add_option("-d", "--dbopts", |
||
195 | default="", metavar="opts", |
||
196 | help="options for dpkg-buildpackage") |
||
197 | parser.add_option("-e", "--email", metavar="address", |
||
198 | default="invalid@invalid.invalid", |
||
199 | help="use e-mail address") |
||
200 | parser.add_option("-i", "--idl", metavar="idlfile", |
||
201 | help="IDL file to use (mandatory)") |
||
202 | parser.add_option("-n", "--name", default="No Name", |
||
203 | help="use user name", metavar="name") |
||
204 | parser.add_option("-p", "--preserve", action="store_true", |
||
205 | help="do not overwrite files") |
||
206 | opts, args = parser.parse_args() |
||
207 | if not opts.idl: |
||
208 | print "mandatory IDL file parameter missing" |
||
209 | sys.exit(1) |
||
210 | if not os.access(opts.idl, os.R_OK): |
||
211 | print "IDL file not accessible" |
||
212 | sys.exit(1) |
||
213 | return opts |
||
214 | |||
215 | if __name__ == '__main__': |
||
216 | main() |