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
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.com>
9 # Copyright 1998 Gerald Combs
11 # SPDX-License-Identifier: GPL-2.0-or-later
19 scriptinfo = """idl2deb version 2008-03-10
20 Copyright 2003, 2008, W. Martin Borgert
21 Free software, released under the terms of the GPL."""
23 def create_file(preserve, filename, content, mode = None):
24 """Create a file with given content."""
25 if preserve and os.path.isfile(filename):
27 f = open(filename, 'w')
31 os.chmod(filename, mode)
33 def create_files(version, deb, email, idl, name, preserve, iso, rfc):
34 """Create all files for the .deb build process."""
35 base = os.path.basename(idl.lower().split(".idl")[0])
37 if not os.path.isdir("packaging/debian"):
38 os.mkdir("packaging/debian")
40 create_file(preserve, "packaging/debian/rules", """#!/usr/bin/make -f
42 include /usr/share/cdbs/1/rules/debhelper.mk
43 include /usr/share/cdbs/1/class/autotools.mk
45 PREFIX=`pwd`/packaging/debian/wireshark-giop-%s
47 binary-post-install/wireshark-giop-%s::
48 rm -f $(PREFIX)/usr/lib/wireshark/plugins/%s/*.a
49 """ % (base, base, version), 0o755)
51 create_file(preserve, "packaging/debian/control", """Source: wireshark-giop-%s
55 Standards-Version: 3.6.1.0
56 Build-Depends: wireshark-dev, autotools-dev, debhelper, cdbs
58 Package: wireshark-giop-%s
60 Depends: wireshark (= %s), ${shlibs:Depends}
61 Description: GIOP dissector for CORBA interface %s
62 This package provides a dissector for GIOP (General Inter-ORB
63 Protocol) for the Wireshark protocol analyser. It decodes the CORBA
64 (Common Object Request Broker Architecture) interfaces described
65 in the IDL (Interface Definition Language) file '%s.idl'.
66 """ % (base, name, email, base, deb, base, base))
68 create_file(preserve, "packaging/debian/changelog",
69 """wireshark-giop-%s (0.0.1-1) unstable; urgency=low
71 * Automatically created package.
74 """ % (base, name, email, rfc))
76 create_file(preserve, "packaging/debian/copyright",
77 """This package has been created automatically by idl2deb on
78 %s for Debian GNU/Linux.
80 Wireshark: https://www.wireshark.org/
84 GPL, as evidenced by existence of GPL license file \"COPYING\".
85 (the GNU GPL may be viewed on Debian systems in
86 /usr/share/common-licenses/GPL)
89 def get_wrs_version():
90 """Detect version of wireshark-dev package."""
92 "dpkg-query -W --showformat='${Version}' wireshark-dev").read()
93 debv = string.find(deb, "-")
94 if debv == -1: debv = len(deb)
95 version = deb[string.find(deb, ":")+1:debv]
99 """Detect current time and return ISO and RFC time string."""
100 currenttime = time.gmtime()
101 return time.strftime("%Y-%m-%d %H:%M:%S +0000", currenttime), \
102 time.strftime("%a, %d %b %Y %H:%M:%S +0000", currenttime)
105 opts = process_opts(sys.argv)
106 iso, rfc = get_time()
107 version, deb = get_wrs_version()
108 create_files(version, deb,
109 opts.email, opts.idl, opts.name, opts.preserve,
111 os.system("dpkg-buildpackage " + opts.dbopts)
113 def process_opts(argv):
114 """Process command line options."""
115 parser = optparse.OptionParser(
117 description="""Example:
118 %prog -e me@foo.net -i bar.idl -n \"My Name\" -d \"-rfakeroot -uc -us\"""")
119 parser.add_option("-d", "--dbopts",
120 default="", metavar="opts",
121 help="options for dpkg-buildpackage")
122 parser.add_option("-e", "--email", metavar="address",
123 default="invalid@invalid.invalid",
124 help="use e-mail address")
125 parser.add_option("-i", "--idl", metavar="idlfile",
126 help="IDL file to use (mandatory)")
127 parser.add_option("-n", "--name", default="No Name",
128 help="use user name", metavar="name")
129 parser.add_option("-p", "--preserve", action="store_true",
130 help="do not overwrite files")
131 opts, args = parser.parse_args()
133 print("mandatory IDL file parameter missing")
135 if not os.access(opts.idl, os.R_OK):
136 print("IDL file not accessible")
140 if __name__ == '__main__':