diff options
-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): |