1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 02_asn2deb.dpatch by <fpeters@debian.org>
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: asn2deb - create Debian packages from ASN.1 files
8 diff -urNad --exclude=CVS --exclude=.svn ./asn2deb /tmp/dpep-work.5BSR7A/ethereal-0.10.11/asn2deb
9 --- ./asn2deb 1970-01-01 01:00:00.000000000 +0100
10 +++ /tmp/dpep-work.5BSR7A/ethereal-0.10.11/asn2deb 2005-07-17 19:37:02.000000000 +0200
12 +#!/usr/bin/env python
14 +# asn2deb - quick hack by W. Borgert <debacle@debian.org> to create
15 +# Debian GNU/Linux packages from ASN.1 files for Ethereal.
16 +# Copyright 2004, W. Borgert
18 +# ASN.1 module for Ethereal, use of snacc type table:
19 +# Copyright 2003, Matthijs Melchior <matthijs.melchior@xs4all.nl>
21 +# Wireshark - Network traffic analyzer
22 +# By Gerald Combs <gerald@wireshark.org>
23 +# Copyright 1998 Gerald Combs
25 +# This program is free software; you can redistribute it and/or
26 +# modify it under the terms of the GNU General Public License
27 +# as published by the Free Software Foundation; either version 2
28 +# of the License, or (at your option) any later version.
30 +# This program is distributed in the hope that it will be useful,
31 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
32 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 +# GNU General Public License for more details.
35 +# You should have received a copy of the GNU General Public License
36 +# along with this program; if not, write to the Free Software
37 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 +import getopt, os, string, sys, time
41 +scriptinfo = """asn2deb version 2004-02-17
42 +Copyright 2004, W. Borgert
43 +Free software, released under the terms of the GPL."""
45 +options = {'asn': None,
47 + 'email': "invalid@invalid.invalid",
54 + """Generate Makefile.in and configure script."""
55 + os.system("aclocal-1.7")
56 + os.system("autoconf")
57 + os.system("automake-1.7 --add-missing --copy --foreign")
59 +def create_file(filename, content, mode = None):
60 + """Create a file with given content."""
62 + if options['preserve'] and os.path.isfile(filename):
64 + f = open(filename, 'w')
68 + os.chmod(filename, mode)
70 +def create_files(version, deb, email, asn, name, iso, rfc):
71 + """Create all files for the .deb build process."""
72 + base = asn.lower()[:-5]
73 + create_file("Makefile.am", """#
75 +BUILT_SOURCES = %s.tt
76 +asn1ttdir = $(datadir)/ethereal/asn1
79 +%s.tt: """ % ((base,) * 3) + asn + """
80 + snacc -u /usr/include/snacc/asn1/asn-useful.asn1 -T $@ $<
83 + create_file("configure.ac", """AC_INIT(%s, 1.0)
87 +SNACC=\"`type -p snacc`\"
89 +dnl ETHEREAL_VERSION=\"%s\"
90 +dnl plugindir=\"$prefix/share/ethereal/asn.1\"
91 +dnl AC_SUBST(plugindir)
92 +AC_OUTPUT([Makefile])
93 +""" % (base, version))
95 + if not os.path.isdir("debian"):
98 + create_file("debian/rules", """#!/usr/bin/make -f
100 +include /usr/share/cdbs/1/rules/debhelper.mk
101 +include /usr/share/cdbs/1/class/autotools.mk
103 +PREFIX=`pwd`/debian/ethereal-asn1-%s
105 +binary-post-install/ethereal-asn1-%s::
106 + rm -f $(PREFIX)/usr/lib/ethereal/plugins/%s/*.a
107 +""" % (base, base, version), 0755)
109 + create_file("debian/control", """Source: ethereal-asn1-%s
113 +Standards-Version: 3.6.1.0
114 +Build-Depends: snacc, autotools-dev, debhelper, cdbs
116 +Package: ethereal-asn1-%s
118 +Depends: ethereal (= %s)
119 +Description: ASN.1/BER dissector for %s
120 + This package provides a type table for decoding BER (Basic Encoding
121 + Rules) data over TCP or UDP, described by an ASN.1 (Abstract Syntax
122 + Notation 1) file '%s.asn1'.
123 +""" % (base, name, email, base, deb, base, base))
125 + create_file("debian/changelog",
126 + """ethereal-asn1-%s (0.0.1-1) unstable; urgency=low
128 + * Automatically created package.
131 +""" % (base, name, email, rfc + "\n (" + iso + ")"))
133 + create_file("debian/copyright",
134 + """This package has been created automatically be asn2deb on
135 +%s for Debian GNU/Linux.
137 +Ethereal: http://www.ethereal.com/
141 +GPL, as evidenced by existence of GPL license file \"COPYING\".
142 +(the GNU GPL may be viewed on Debian systems in
143 +/usr/share/common-licenses/GPL)
146 +def get_eth_version():
147 + """Detect version of ethereal-dev package."""
149 + "dpkg-query -W --showformat='${Version}' ethereal-dev").read()
150 + debv = string.find(deb, "-")
151 + if debv == -1: debv = len(deb)
152 + version = deb[string.find(deb, ":")+1:debv]
153 + return version, deb
156 + """Detect current time and return ISO and RFC time string."""
157 + currenttime = time.gmtime()
158 + return time.strftime("%Y-%m-%d %H:%M:%S +0000", currenttime), \
159 + time.strftime("%a, %d %b %Y %H:%M:%S +0000", currenttime)
163 + process_opts(sys.argv)
164 + iso, rfc = get_time()
165 + version, deb = get_eth_version()
166 + create_files(version, deb,
167 + options['email'], options['asn'], options['name'],
170 + os.system("dpkg-buildpackage " + options['dbopts'])
172 +def process_opts(argv):
173 + """Process command line options."""
176 + opts, args = getopt.getopt(argv[1:], "a:d:e:hn:pv",
184 + except getopt.GetoptError:
188 + if o in ("-a", "--asn"):
190 + if o in ("-d", "--dbopts"):
191 + options['dbopts'] = a
192 + if o in ("-e", "--email"):
193 + options['email'] = a
194 + if o in ("-h", "--help"):
195 + options['help'] = 1
196 + if o in ("-n", "--name"):
197 + options['name'] = a
198 + if o in ("-p", "--preserve"):
199 + options['preserve'] = 1
200 + if o in ("-v", "--version"):
201 + options['version'] = 1
202 + if options['help']:
205 + if options['version']:
208 + if not options['asn']:
209 + print "mandatory ASN.1 file parameter missing"
211 + if not os.access(options['asn'], os.R_OK):
212 + print "ASN.1 file not accessible"
216 + """Print usage help."""
217 + print "Usage: " + name + " <parameters>\n" + \
218 + "Parameters are\n" + \
219 + " --asn -a asn1file, ASN.1 file to use (mandatory)\n" + \
220 + " --dbopts -d opts, options for dpkg-buildpackage\n" + \
221 + " --email -e address, use e-mail address\n" + \
222 + " --help -h, print help and exit\n" + \
223 + " --name -n name, use user name\n" + \
224 + " --preserve -p, do not overwrite files\n" + \
225 + " --version -v, print version and exit\n" + \
227 + name + " -e me@foo.net -a bar.asn1 -n \"My Name\" " + \
228 + "-d \"-rfakeroot -uc -us\""
229 +if __name__ == '__main__':
231 diff -urNad --exclude=CVS --exclude=.svn ./asn2deb.dbk /tmp/dpep-work.5BSR7A/ethereal-0.10.11/asn2deb.dbk
232 --- ./asn2deb.dbk 1970-01-01 01:00:00.000000000 +0100
233 +++ /tmp/dpep-work.5BSR7A/ethereal-0.10.11/asn2deb.dbk 2005-07-17 19:37:02.000000000 +0200
235 +<?xml version='1.0' encoding='ISO-8859-1'?>
236 +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
237 +"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
238 + <!ENTITY command "<command>asn2deb</command>">
239 + <!ENTITY email "<email>debacle@debian.org</email>">
240 + <!ENTITY author "W. Borgert">
241 + <!ENTITY debian "<productname>Debian GNU/Linux</productname>">
250 + <firstname>W.</firstname>
251 + <surname>Borgert</surname>
256 + <holder>&author;</holder>
258 + <date>2004-02-18</date>
260 + <keyword>ASN.1</keyword>
261 + <keyword>BER</keyword>
262 + <keyword>Ethereal</keyword>
266 + <revnumber>1</revnumber>
267 + <date>2004-02-18</date>
268 + <authorinitials>debacle</authorinitials>
269 + <revremark>First version.</revremark>
274 + <refentrytitle>asn2deb</refentrytitle>
276 + <manvolnum>1</manvolnum>
279 + <refname>asn2deb</refname>
281 + <refpurpose>create a Debian package for BER monitoring from ASN.1</refpurpose>
286 + <arg>-a <replaceable>ASN.1 file</replaceable></arg>
287 + <arg>--asn=<replaceable>ASN.1 file</replaceable></arg>
288 + <arg><option>-d <replaceable>opts</replaceable></option></arg>
289 + <arg><option>--dbopts=<replaceable>opts</replaceable></option></arg>
290 + <arg><option>-e <replaceable>address</replaceable></option></arg>
291 + <arg><option>--email=<replaceable>address</replaceable></option></arg>
292 + <arg><option>-h</option></arg>
293 + <arg><option>--help</option></arg>
294 + <arg><option>-n <replaceable>name</replaceable></option></arg>
295 + <arg><option>--name=<replaceable>name</replaceable></option></arg>
296 + <arg><option>-p</option></arg>
297 + <arg><option>--preserve</option></arg>
298 + <arg><option>-v</option></arg>
299 + <arg><option>--version</option></arg>
303 + <title>Description</title>
305 + <para>This manual page documents briefly the
306 + <command>asn2deb</command> command.</para>
308 + <para>&command; takes an ASN.1 file as input and creates a Debian
309 + package from it. The package contains a loadable type table file
310 + for the ethereal network analyser. The type table is generated by
311 + the ASN.1 compiler <command>snacc</command>.</para>
314 + <title>Options</title>
318 + <term><option>-a <replaceable>ASN.1 file</replaceable></option>
319 + <option>--asn=<replaceable>ASN.1 file</replaceable></option></term>
321 + <para>ASN.1 file to use (mandatory).</para>
325 + <term><option>-d <replaceable>opts</replaceable></option>
326 + <option>--dbopts=<replaceable>opts</replaceable></option></term>
328 + <para>options for dpkg-buildpackage.</para>
332 + <term><option>-e <replaceable>address</replaceable></option>
333 + <option>--email=<replaceable>address</replaceable></option></term>
335 + <para>use e-mail address.</para>
339 + <term><option>-h</option>
340 + <option>--help</option>
343 + <para>print help and exit.</para>
347 + <term><option>-n <replaceable>name</replaceable></option>
348 + <option>--name=<replaceable>name</replaceable></option></term>
350 + <para>use user name.</para>
354 + <term><option>-p</option>
355 + <option>--preserve</option></term>
357 + <para>do not overwrite files.</para>
361 + <term><option>-v</option>
362 + <option>--version</option></term>
364 + <para>print version and exit.</para>
369 + <para>Example:</para>
371 + <programlisting>/usr/bin/asn2deb -e me@foo.net -a bar.asn1 \
372 +-n "My Name" -d "-rfakeroot -uc -us"</programlisting>
376 + <title>See Also</title>
378 + <para>A lot of tools are used, which you have to
379 + <command>apt-get install</command>: ethereal-dev, python,
380 + cdbs, autotools-dev, debhelper, dpkg-dev, snacc.</para>
384 + <title>Copying</title>
386 + <para>This manual page was written by &author; &email; for
387 + &debian; (but may be used by others). Permission is granted to
388 + copy, distribute and/or modify this document under the terms of
389 + the GNU General Public License, Version 2 or any later
390 + version published by the Free Software Foundation.</para>