diff --git a/build_deb.py b/build_deb.py index 80b2da7..49722cf 100755 --- a/build_deb.py +++ b/build_deb.py @@ -8,10 +8,10 @@ import shutil import stat import re - +import argparse from version import __version__ - +CHANGELOG_FILE = 'ChangeLog' def _get_changelog(version): with open('ChangeLog-{}'.format(version), 'r') as f: @@ -27,21 +27,29 @@ def _get_distribution(): if __name__ == '__main__': - # Run setup.py to create executable - subprocess.call(['python3', 'setup.py', 'build']) + parser = argparse.ArgumentParser() + + parser.add_argument( + '-r', + '--rev', + type=int, + default=0, + help='Debian Revision number.') + + parser.add_argument( + '-f', + '--force', + action='store_true', + help='Overwrite existing build.') - # Read the current version - if __version__ is None: - exit('Cannot find version in file: {}'.format(VERSION_FILE)) + args = parser.parse_args() - changelog = _get_changelog(__version__) - # Explain architecture= amd64 - # The architecture is AMD64-compatible and Debian AMD64 will run on AMD and - # Intel processors with 64-bit support. - # Because of the technology paternity, Debian uses the name "AMD64". + version = __version__ + if args.rev: + version += '-{}'.format(args.rev) config = dict( - version=__version__, + version=version, name='Jeroen van der Heijden', email='jeroen@transceptor.technology', company='Transceptor Technology', @@ -65,14 +73,34 @@ def _get_distribution(): '''.rstrip(), explain='create and extend a SiriDB time series database', depends='${shlibs:Depends}, ' - '${misc:Depends}', - changelog=changelog.strip() + '${misc:Depends}' ) + with open(CHANGELOG_FILE, 'r') as f: + current_changelog = f.read() + + if '{package} ({version})'.format( + **config) in current_changelog: + if not args.force: + raise ValueError( + 'Version {} already build. Use -r to create a new ' + 'revision number or use -f to overwrite the existing pacakge' + .format(version)) + changelog = None + else: + changelog = _get_changelog(version) + config.update(dict( + changelog=changelog.strip() + )) + + # Run setup.py to create executable + subprocess.call(['python3', 'setup.py', 'build']) + OVERRIDES = open( 'deb/OVERRIDES', 'r').read().strip().format(**config) - CHANGELOG = open( - 'deb/CHANGELOG', 'r').read().strip().format(**config) + if changelog: + CHANGELOG = open( + 'deb/CHANGELOG', 'r').read().strip().format(**config) CONTROL = open( 'deb/CONTROL', 'r').read().strip().format(**config) MANPAGE = open( @@ -124,7 +152,7 @@ def _get_distribution(): else: current_changelog = '' - if '{package} ({version})'.format(**config) not in current_changelog: + if changelog: changelog = CHANGELOG + '\n\n' + current_changelog with open(changelog_file, 'w') as f: diff --git a/main.py b/main.py index f06fe6e..587d624 100755 --- a/main.py +++ b/main.py @@ -1006,7 +1006,7 @@ def parse_create_replica_or_pool(args): '-l', '--log-level', default='info', help='set the log level (ignored in wizard mode)', - choices=['debug', 'info', 'warning', 'error', 'critical']) + choices=['debug', 'info']) subparsers = parser.add_subparsers( dest='action', @@ -1062,18 +1062,25 @@ def parse_create_replica_or_pool(args): args = parser.parse_args() + formatter = logging.Formatter(fmt='%(message)s', style='%') + + logger = logging.getLogger() + logger.setLevel(args.log_level.upper()) + + ch = logging.StreamHandler() + ch.setLevel(logging.DEBUG) + ch.setFormatter(formatter) + logger.addHandler(ch) + if args.version: quit_manage(0, ''' -SiriDB {version} manage tool +SiriDB Manage {version} Maintainer: {maintainer} <{email}> Home-page: http://siridb.net '''.strip().format(version=__version__, maintainer=__maintainer__, email=__email__)) - logger = logging.getLogger() - logger.setLevel(args.log_level.upper()) - # Check for root if not args.noroot and not os.geteuid() == 0: quit_manage(2, diff --git a/version.py b/version.py index b1468bd..28f4601 100644 --- a/version.py +++ b/version.py @@ -1,4 +1,4 @@ __version_info__ = (2, 0, 0) __version__ = '.'.join(map(str, __version_info__)) __maintainer__ = 'Jeroen van der Heijden' -__email__ = 'jeroen@transceptor.technology' \ No newline at end of file +__email__ = 'jeroen@transceptor.technology'