Debian Codegraph @

debian/patches/Use-a-fake-relic-package-for-version-info.patch

raw
1 From: Ole Streicher <[email protected]>
2 Date: Sun, 6 Nov 2016 10:24:07 +0100
3 Subject: Use a fake relic package for version info
4
5 The original package depends on a git repository, which is not there
6 when we build the package from a tarball. So, we take the opportunity
7 to take the version info from the Debian changelog.
8
9 This requires the "python(3)-debian" package as build dependency.
10 ---
11 relic/__init__.py | 1 +
12 relic/release.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
13 2 files changed, 53 insertions(+)
14 create mode 100644 relic/__init__.py
15 create mode 100644 relic/release.py
16
17 diff --git a/relic/__init__.py b/relic/__init__.py
18 new file mode 100644
19 index 0000000..8b13789
20 --- /dev/null
21 +++ b/relic/__init__.py
22 @@ -0,0 +1 @@
23 +
24 diff --git a/relic/release.py b/relic/release.py
25 new file mode 100644
26 index 0000000..bf442e7
27 --- /dev/null
28 +++ b/relic/release.py
29 @@ -0,0 +1,52 @@
30 +from collections import namedtuple
31 +import datetime
32 +import dateutil.parser
33 +import os
34 +from debian import changelog
35 +
36 +template = """
37 +__all__ = [
38 + '__version__',
39 + '__version_short__',
40 + '__version_long__',
41 + '__version_post__',
42 + '__version_commit__',
43 + '__version_date__',
44 + '__version_dirty__',
45 + '__build_date__',
46 + '__build_status__'
47 +]
48 +__version__ = '{pep386}'
49 +__version_short__ = '{short}'
50 +__version_long__ = '{long}'
51 +__version_post__ = ''
52 +__version_commit__ = ''
53 +__version_date__ = '{date}'
54 +__version_dirty__ = {dirty}
55 +__build_date__ = '{build_date}'
56 +__build_time__ = '{build_time}'
57 +__build_status__ = 'release' if not __version_dirty__ else 'development'
58 +"""
59 +
60 +def get_info():
61 + DebVersion = namedtuple('DebVersion', ['pep386', 'short', 'long',
62 + 'date', 'dirty'])
63 + with open('debian/changelog') as cl_file:
64 + cl = changelog.Changelog(cl_file)
65 + return DebVersion(pep386=cl.upstream_version,
66 + short=cl.upstream_version,
67 + long=cl.version,
68 + date=dateutil.parser.parse(cl.date),
69 + dirty=(cl.distributions=='UNRELEASED'))
70 +
71 +def write_template(info, module_path, filename='version.py'):
72 + path = os.path.join(module_path, filename)
73 + with open(path, 'w+') as f:
74 + output = template.format(pep386=info.pep386,
75 + short=info.short,
76 + long=info.long,
77 + date=info.date,
78 + build_date=info.date.date(),
79 + build_time=info.date.time(),
80 + dirty=info.dirty)
81 + f.write(output)