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

Guess the main category.

parent 27abc3ff
......@@ -15,7 +15,7 @@
PORTNAME= {{ pkg.portname }}
DISTVERSION= {{ pkg.version }}
CATEGORIES= {{ pkg.categories }}
CATEGORIES= {{ pkg.categories|join(' ') }}
MASTER_SITES= {{ pkg.master_sites }}
PKGNAMEPREFIX= {{ pkg.pkgnameprefix }}
......
......@@ -51,6 +51,17 @@ class TestFreeBSDPackage(unittest.TestCase):
out = self.freebsd_pkg.jinja2_reqformat(req)
self.assertEqual(out, 'foo>0:XXX/foo')
def test_categories(self):
self.freebsd_pkg.output_dir = '/usr/ports/ports-mgmt/py-upt-freebsd'
self.freebsd_pkg.language_category = 'language'
self.assertListEqual(self.freebsd_pkg.categories,
['ports-mgmt', 'language'])
def test_categories_invalid_category(self):
self.freebsd_pkg.output_dir = '/usr/ports/invalid/py-upt-freebsd'
self.freebsd_pkg.language_category = 'language'
self.assertListEqual(self.freebsd_pkg.categories, ['XXX', 'language'])
if __name__ == '__main__':
unittest.main()
......@@ -77,8 +77,35 @@ class FreeBSDPackage(object):
else:
return object.__getattribute__(self, name)
@property
def categories(self):
raise NotImplementedError()
valid_freebsd_categories = [
'accessibility', 'arabic', 'archivers', 'astro',
'audio', 'base', 'benchmarks', 'biology',
'cad', 'chinese', 'comms', 'converters',
'databases', 'deskutils', 'devel', 'dns',
'editors', 'emulators', 'finance', 'french',
'ftp', 'games', 'german', 'graphics',
'hebrew', 'hungarian', 'irc', 'japanese',
'java', 'Keywords', 'korean', 'lang',
'mail', 'math', 'misc', 'multimedia',
'net', 'net-im', 'net-mgmt', 'net-p2p',
'news', 'palm', 'polish', 'ports-mgmt',
'portuguese', 'print', 'russian', 'science',
'security', 'shells', 'sysutils', 'Templates',
'textproc', 'Tools', 'ukrainian', 'vietnamese',
'www', 'x11', 'x11-clocks', 'x11-drivers',
'x11-fm', 'x11-fonts', 'x11-servers', 'x11-themes',
'x11-toolkits', 'x11-wm',
]
try:
_, main_category, _ = self.output_dir.rsplit('/', 2)
if main_category not in valid_freebsd_categories:
raise ValueError
except ValueError:
main_category = 'XXX'
return [main_category, self.language_category]
def jinja2_reqformat(self, req):
freebsd_name = self._freebsd_pkg_name(req.name)
......@@ -188,12 +215,9 @@ class FreeBSDPerlPackage(FreeBSDPackage):
template = 'perl.mk'
default_maintainer = 'perl@FreeBSD.org'
master_sites = 'CPAN'
language_category = 'perl5'
pkgnameprefix = 'p5-'
@property
def categories(self):
return 'perl5'
@staticmethod
def _freebsd_pkg_name(name):
name = name.replace('::', '-')
......@@ -214,12 +238,9 @@ class FreeBSDPythonPackage(FreeBSDPackage):
template = 'python.mk'
default_maintainer = 'python@FreeBSD.org'
master_sites = 'CHEESESHOP'
language_category = 'python'
pkgnameprefix = '${PYTHON_PKGNAMEPREFIX}'
@property
def categories(self):
return 'python'
@staticmethod
def _freebsd_pkg_name(name):
return f'py-{name}'
......
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