summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Wilcox <AWilcox@Wilcox-Tech.com>2015-10-08 19:32:55 -0500
committerAndrew Wilcox <AWilcox@Wilcox-Tech.com>2015-10-08 19:32:55 -0500
commite28c629584d07594c7abe6bc07145d6359d51566 (patch)
tree69de05283a8065a212079363b4a9bb10c6aa253a
parent2230cfbae1d8723330845abf11d40505d904bbec (diff)
downloadapkkit-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.py37
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):