Skip to content

Commit

Permalink
[WIP]: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Korusuke committed Jun 28, 2019
1 parent 13cd9fd commit b95ed6e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
30 changes: 16 additions & 14 deletions upt_macports/templates/base.Portfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
{%- macro depends(kind, deps) -%}{% if deps %}
depends_{{ kind }}-append \
{%- for dep in deps %}
port:{{ dep|reqformat }}{% if not loop.last %} \
{%- endif -%}
{% endfor -%}
{% endif -%}
{% endmacro -%}
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
{% block portgroup %}
{%- block portgroup %}
{% endblock %}

## Portfile generated/maintained using the Universal Packaging Tool (upt)
## Please check out the commented statements and refer to the guide for more information:
## https://guide.macports.org/#reference.keywords
{% block nameversion %}
{%- block nameversion %}
{% endblock %}

# categories-append
platforms darwin
{% if pkg.upt_pkg.frontend != 'rubygems' -%}
## uncomment the following line if no architecture-dependent files are installed, otherwise remove
# supported_archs noarch
{% endif %}
{% endif -%}
license {{ pkg.licenses }}
## If you would like to keep maintaining this port in the future as described in
## https://guide.macports.org/chunked/project.contributing.html then
Expand All @@ -26,19 +32,15 @@ maintainers nomaintainer

description {{ pkg.upt_pkg.summary }}
long_description ${description}

{% block dist_info %}
{% endblock -%}

{% if pkg.archive_type == 'unknown' and pkg.upt_pkg.frontend != 'rubygems' -%}
{% endblock %}
{%- if pkg.archive_type == 'unknown' and pkg.upt_pkg.frontend != 'rubygems' %}
# Detection of archive type failed
{% elif pkg.archive_type != 'gz' and pkg.upt_pkg.frontend != 'rubygems' %}
{%- elif pkg.archive_type != 'gz' and pkg.upt_pkg.frontend != 'rubygems' %}
{{ "use_%-15s yes"|format(pkg.archive_type) }}
{% endif %}

{%- endif %}
checksums sha256 {{ pkg.upt_pkg.archives[0].sha256 }} \
rmd160 {{ pkg.upt_pkg.archives[0].rmd160 }} \
size {{ pkg.upt_pkg.archives[0].size }}

{% block versions %}
{% endblock %}
{% endblock -%}
25 changes: 7 additions & 18 deletions upt_macports/templates/python.Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PortGroup python 1.0
{% endblock %}
{% block nameversion %}
name {{ pkg._pkgname() }}
{% if pkg._python_root_name() %}
{%- if pkg._python_root_name() %}
python.rootname {{ pkg._python_root_name() }}
{% endif %}
version {{ pkg.upt_pkg.version }}
Expand All @@ -28,25 +28,14 @@ if {${name} ne ${subport}} {
## file that setuptools is indeed used and that the dependency-type is correct.
depends_build-append \
port:py${python.version}-setuptools
{%- if pkg.upt_pkg.requirements.run|length > 0 %}

{%- if pkg.upt_pkg.requirements.run %}
{{ depends('lib', pkg.upt_pkg.requirements.run) }}
{%- endif -%}

depends_lib-append \
{% for i in pkg.upt_pkg.requirements.run|sort(attribute='name') %}
port:py${python.version}-{{i.name}}{% if not loop.last %} \
{% endif %}
{% endfor %}
{% endif %}
{%- if pkg.upt_pkg.requirements.test|length > 0 %}


depends_test-append \
{% for i in pkg.upt_pkg.requirements.test|sort(attribute='name') %}
port:py${python.version}-{{i.name}}{% if not loop.last %} \
{% endif %}
{% endfor %}
{% endif %}

{%- if pkg.upt_pkg.requirements.test %}
{{ depends('test', pkg.upt_pkg.requirements.test) }}
{%- endif %}

livecheck.type none
}
Expand Down
6 changes: 5 additions & 1 deletion upt_macports/upt_macports.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ def create_package(self, upt_pkg, output):
def _render_makefile_template(self):
env = jinja2.Environment(
loader=jinja2.PackageLoader('upt_macports', 'templates'),
trim_blocks=True,
trim_blocks=False,
lstrip_blocks=True,
keep_trailing_newline=True,
)
env.filters['reqformat'] = self.jinja2_reqformat
template = env.get_template(self.template)
return template.render(pkg=self)

Expand Down Expand Up @@ -105,6 +106,9 @@ def _python_root_name(self):
if pypi_name != self.upt_pkg.name.lower():
return pypi_name

def jinja2_reqformat(self, req):
return 'py${python.version}-'+req.name


class MacPortsNpmPackage(MacPortsPackage):
template = 'npm.Portfile'
Expand Down

0 comments on commit b95ed6e

Please sign in to comment.