Commit e28c6295 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

Package: we can now emit PKGINFO

parent 2230cfba
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)
......@@ -84,6 +97,11 @@ class Package:
"""The architecture of the 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."""
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment