Commit e2e6529f authored by Cyril Roelandt's avatar Cyril Roelandt
Browse files

Initial commit.

parents
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
.static_storage/
.media/
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
# Changelog
All notable changes to this project will be documented in this file.
Based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Unreleased]
Copyright 2018 Cyril Roelandt
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include CHANGELOG
include LICENSE
include README.md
include tox.ini
[metadata]
name = upt-freebsd
version = 0.1
description = FreeBSD backend for upt
long_description = file: README.md
author = Cyril Roelandt
author_email = tipecaml@gmail.com
url= https://framagit.org/upt/upt-freebsd
requires_python = >= 3.6
classifiers =
Development Status :: 3 - Alpha
License :: OSI Approved :: BSD License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3 :: Only
[options]
packages = find:
install_requires =
jinja2
upt
[options.entry_points]
upt.backends =
freebsd = upt_freebsd.upt_freebsd:FreeBSDBackend
[options.extras_require]
test =
from setuptools import setup
setup()
[tox]
envlist=flake8,py36
[testenv]
commands = python -m unittest
[testenv:flake8]
basepython = python3
deps = flake8
commands = flake8 upt_freebsd/
# $FreeBSD$
PORTNAME= {{ pkg.name }}
DISTVERSION= {{ pkg.version }}
CATEGORIES= {{ pkg.categories }}
MASTER_SITES= {{ pkg.master_sites }}
PKGNAMEPREFIX= {{ pkg.pkgnameprefix }}
MAINTAINER= {{ pkg.maintainer }}
COMMENT= {{ pkg.summary }}
LICENSE= {{ pkg.licenses }}
LICENSE_FILE= ${WRKSRC}/XXX
{% block use %}{% endblock %}
.include <bsd.port.mk>
{% extends 'base.mk' %}
{% block use %}
USES= perl5
USE_PERL5= XXX
{% endblock %}
{% extends 'base.mk' %}
{% block use %}
USES= python
USE_PYTHON= autoplist distutils
{% endblock %}
# Copyright 2018 Cyril Roelandt
#
# Licensed under the 3-clause BSD license. See the LICENSE file.
import jinja2
import upt
class FreeBSDPackage(object):
default_maintainer = 'XXX'
def __init__(self, upt_pkg):
self.upt_pkg = upt_pkg
def __getattribute__(self, name):
if name in ['homepage', 'name', 'summary', 'version']:
return self.upt_pkg.__getattribute__(name)
else:
return object.__getattribute__(self, name)
def render(self):
env = jinja2.Environment(
loader=jinja2.PackageLoader('upt_freebsd', 'templates'),
trim_blocks=True,
)
template = env.get_template(self.template)
return template.render(pkg=self)
def categories(self):
raise NotImplementedError()
@property
def licenses(self):
spdx2freebsd = {
'AGPL-3.0': 'AGPLv3',
'Artistic-1.0': 'ART10',
'Artistic-2.0': 'ART20',
'Apache-1.0': 'APACHE10',
'Apache-1.1': 'APACHE11',
'Apache-2.0': 'APACHE20',
'BSL-1.0': 'BSL',
'BSD-2-Clause': 'BSD2CLAUSE',
'BSD-3-Clause': 'BSD3CLAUSE',
'BSD-4-Clause': 'BSD4CLAUSE',
'ClArtistic': 'ClArtistic',
'CC0-1.0': 'CC0-1.0',
'CC-BY-NC-SA-2.0': 'CC-BY-NC-SA-2.0',
'CC-BY-NC-SA-2.5': 'CC-BY-NC-SA-2.5',
'CC-BY-NC-SA-3.0': 'CC-BY-NC-SA-3.0',
'CC-BY-NC-SA-4.0': 'CC-BY-NC-SA-4.0',
'CC-BY-ND-3.0': 'CC-BY-ND-3.0',
'CC-BY-SA-2.5': 'CC-BY-SA-2.5',
'CC-BY-3.0': 'CC-BY-3.0',
'CC-BY-SA-3.0': 'CC-BY-SA-3.0',
'CC-BY-4.0': 'CC-BY-4.0',
'CC-BY-SA-4.0': 'CC-BY-4.0',
'CDDL-1.0': 'CDDL',
'EPL-1.0': 'EPL',
'EPL-2.0': 'EPL',
'GFDL-1.2': 'GFDL',
'GFDL-1.3': 'GFDL',
'GPL-1.0': 'GPLv1',
'GPL-1.0+': 'GPLv1+',
'GPL-2.0': 'GPLv2',
'GPL-2.0+': 'GPLv2+',
'GPL-3.0': 'GPLv3',
'GPL-3.0+': 'GPLv3+',
'ISC': 'ISCL',
'LGPL-2.0': 'LGPL20',
'LGPL-2.0+': 'LGPL20+',
'LGPL-2.1': 'LGPL21',
'LGPL-2.1+': 'LGPL21+',
'LGPL-3.0': 'LGPL3',
'LGPL-3.0+': 'LGPL3+',
'LPPL-1.2': 'LPPL12',
'LPPL-1.3c': 'LPPL13c',
'MIT': 'MIT',
'MPL-1.0': 'MPL10',
'MPL-1.1': 'MPL11',
'MPL-2.0': 'MPL20',
'NCSA': 'NSCA',
'OFL-1.1': 'OFL11',
'OpenSSL': 'OpenSSL',
'PHP-3.01': 'PHP301',
'PostgreSQL': 'PostgreSQL',
'Python-2.0': 'PSFL',
'Ruby': 'RUBY',
'WTFPL': 'WTFPL',
'Zlib': 'ZLIB',
'ZPL-2.1': 'ZPL21'
}
return ' '.join([spdx2freebsd.get(upt_license.spdx_identifier, 'XXX')
for upt_license in self.upt_pkg.licenses])
@property
def maintainer(self):
# TODO: use ~/.porttools if it exists.
return self.default_maintainer
@property
def pkgnameprefix(self):
raise NotImplementedError()
class FreeBSDPerlPackage(FreeBSDPackage):
template = 'perl.mk'
default_maintainer = 'perl@FreeBSD.org'
master_sites = 'CPAN'
pkgnameprefix = 'p5-'
@property
def categories(self):
return 'perl5'
class FreeBSDPythonPackage(FreeBSDPackage):
template = 'python.mk'
default_maintainer = 'python@FreeBSD.org'
master_sites = 'CHEESESHOP'
pkgnameprefix = '${PYTHON_PKGNAMEPREFIX}'
@property
def categories(self):
return 'python'
class FreeBSDBackend(upt.Backend):
name = 'freebsd'
def create_package(self, upt_pkg, output=None):
pkg_classes = {
'cpan': FreeBSDPerlPackage,
'pypi': FreeBSDPythonPackage,
}
try:
pkg_cls = pkg_classes[upt_pkg.frontend]
except KeyError:
raise upt.UnhandledFrontendError(self.name, upt_pkg.frontend)
print(pkg_cls(upt_pkg).render())
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