3 # Copyright (C) 2013 W. Trevor King <wking@tremily.us>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 """Catalyst is a release building tool used by Gentoo Linux"""
21 from __future__ import print_function
23 import codecs as _codecs
24 from distutils.core import setup as _setup, Command as _Command
27 from catalyst import __version__
28 from catalyst.version import set_release_version as _set_release_version
29 from catalyst.version import get_version as _get_version
32 _this_dir = _os.path.dirname(__file__)
33 package_name = 'catalyst'
34 tag = '{0}-{1}'.format(package_name, __version__)
37 if _os.path.sep != '/':
38 raise NotImplementedError('Non-POSIX paths are not supported')
40 def files(root, target):
41 """Iterate through all the file paths under `root`
43 Distutils wants all paths to be written in the Unix convention
44 (i.e. slash-separated) [1], so that's what we'll do here.
46 [1]: http://docs.python.org/2/distutils/setupscript.html#writing-the-setup-script
48 for dirpath, dirnames, filenames in _os.walk(root):
49 key = _os.path.join(target, dirpath)
50 filepaths = [_os.path.join(dirpath, filename)
51 for filename in filenames]
52 yield (key, filepaths)
55 _data_files = [('/etc/catalyst', ['etc/catalyst.conf','etc/catalystrc']),
56 ('/usr/share/man/man1', ['files/catalyst.1']),
57 ('/usr/share/man/man5', ['files/catalyst-config.5', 'files/catalyst-spec.5'])
59 _data_files.extend(files('livecd', 'lib/catalyst/'))
60 _data_files.extend(files('targets', 'lib/catalyst/'))
63 class set_version(_Command):
64 '''Saves the specified release version information
67 description = "hardcode script's version using VERSION from environment"
68 user_options = [] # [(long_name, short_name, desc),]
70 def initialize_options (self):
73 def finalize_options (self):
78 version = _os.environ['VERSION']
80 print("Try setting 'VERSION=x.y.z' on the command line... Aborting")
82 _set_release_version(version)
83 __version__ = _get_version()
84 print("Version set to:\n", __version__)
90 maintainer='Gentoo Release Engineering',
91 maintainer_email='releng@gentoo.org',
92 url='http://www.gentoo.org/proj/en/releng/{0}/'.format(package_name),
93 download_url='http://git.overlays.gentoo.org/gitweb/?p=proj/{0}.git;a=snapshot;h={1};sf=tgz'.format(package_name, tag),
94 license='GNU General Public License (GPL)',
97 long_description=_codecs.open(
98 _os.path.join(_this_dir, 'README'), 'r', 'utf-8').read(),
100 'Development Status :: 5 - Production/Stable',
101 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
102 'Intended Audience :: System Administrators',
103 'Operating System :: POSIX',
104 'Topic :: System :: Archiving :: Packaging',
105 'Topic :: System :: Installation/Setup',
106 'Topic :: System :: Software Distribution',
107 'Programming Language :: Python :: 2',
108 'Programming Language :: Python :: 2.6',
109 'Programming Language :: Python :: 2.7',
111 scripts=['bin/{0}'.format(package_name)],
114 '{0}.arch'.format(package_name),
115 '{0}.base'.format(package_name),
116 '{0}.targets'.format(package_name),
118 data_files=_data_files,
119 provides=[package_name],
121 'set_version': set_version