diff options
author | Andrew Wilcox <AWilcox@Wilcox-Tech.com> | 2015-10-08 19:32:55 -0500 |
---|---|---|
committer | Andrew Wilcox <AWilcox@Wilcox-Tech.com> | 2015-10-08 19:32:55 -0500 |
commit | e28c629584d07594c7abe6bc07145d6359d51566 (patch) | |
tree | 69de05283a8065a212079363b4a9bb10c6aa253a | |
parent | 2230cfbae1d8723330845abf11d40505d904bbec (diff) | |
download | apkkit-e28c629584d07594c7abe6bc07145d6359d51566.tar.gz apkkit-e28c629584d07594c7abe6bc07145d6359d51566.tar.bz2 apkkit-e28c629584d07594c7abe6bc07145d6359d51566.tar.xz apkkit-e28c629584d07594c7abe6bc07145d6359d51566.zip |
Package: we can now emit PKGINFO
-rw-r--r-- | apkkit/base/package.py | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/apkkit/base/package.py b/apkkit/base/package.py index 87164e3..e80e08c 100644 --- a/apkkit/base/package.py +++ b/apkkit/base/package.py @@ -1,13 +1,26 @@ +from jinja2 import Template +import os + + """Contains the Package class and related helper classes and functions.""" -pkginfo_template = """ + +pkginfo_template = Template(""" # Generated by APK Kit for Adélie Linux -# {builduser}@{buildhost} {builddate} -pkgname = {name} -pkgver = {ver} -pkgdesc = {desc} -arch = {arch} -""" +# {{ builduser }}@{{ buildhost }} {{ builddate }} +pkgname = {{ package.name }} +pkgver = {{ package.version }} +pkgdesc = {{ package.description }} +arch = {{ package.arch }} +{%- if package.provides %}{%- for provided in package.provides %} +provides = {{ provided }} +{%- endfor %}{%- endif %} +{%- if package.depends %}{%- for depend in package.depends %} +depends = {{ depend }} +{%- endfor %}{%- endif %} +""") +"""The template used for generating .PKGINFO""" + class Package: """The base package class.""" @@ -46,7 +59,7 @@ class Package: """ self._pkgname = name - self._pkgver = version + self._pkgver = str(version) self._pkgdesc = description or name self._url = url self._size = int(size) @@ -85,6 +98,11 @@ class Package: return self._arch @property + def provides(self): + """The libraries and/or virtuals provided by this package.""" + return self._provides + + @property def depends(self): """The dependencies of the package.""" return self._depends @@ -106,6 +124,9 @@ class Package: .. note:: To write a file, see the :py:meth:`.write_pkginfo` helper method. """ + return pkginfo_template.render(builduser=os.environ.get('USER', '?'), + buildhost=os.uname().nodename, + package=self) @classmethod def from_pkginfo(cls, buf): |