forked from ungleich-public/cdist
Merge branch 'reorg' into 'master'
small reorganization See merge request ungleich-public/cdist!942
This commit is contained in:
commit
bf9d70bb8c
10 changed files with 108 additions and 114 deletions
|
@ -6,15 +6,15 @@ image: code.ungleich.ch:5050/ungleich-public/cdist/cdist-ci:latest
|
||||||
unit_tests:
|
unit_tests:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- ./bin/build-helper version
|
- ./bin/cdist-build-helper version
|
||||||
- ./bin/build-helper test
|
- ./bin/cdist-build-helper test
|
||||||
|
|
||||||
pycodestyle:
|
pycodestyle:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- ./bin/build-helper pycodestyle
|
- ./bin/cdist-build-helper pycodestyle
|
||||||
|
|
||||||
shellcheck:
|
shellcheck:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- ./bin/build-helper shellcheck
|
- ./bin/cdist-build-helper shellcheck
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Maintainers should use ./bin/build-helper script.
|
Maintainers should use ./bin/cdist-build-helper script.
|
||||||
|
|
||||||
Makefile is intended for end users. It can be used for non-maintaining
|
Makefile is intended for end users. It can be used for non-maintaining
|
||||||
targets that can be run from pure source (without git repository).
|
targets that can be run from pure source (without git repository).
|
||||||
|
|
90
bin/cdist
90
bin/cdist
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2010-2016 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2016 Darko Poljak (darko.poljak at gmail.com)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -20,14 +21,83 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
# Wrapper for real script to allow execution from checkout
|
import logging
|
||||||
dir=${0%/*}
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
# Ensure version is present - the bundled/shipped version contains a static version,
|
# try to import cdist and if that fails,
|
||||||
# the git version contains a dynamic version
|
# then add this file's parent dir to
|
||||||
"$dir/build-helper" version
|
# module search path and try again.
|
||||||
|
try:
|
||||||
|
import cdist
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
cdist_dir = os.path.realpath(
|
||||||
|
os.path.join(
|
||||||
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
|
os.pardir))
|
||||||
|
sys.path.insert(0, cdist_dir)
|
||||||
|
import cdist
|
||||||
|
|
||||||
libdir=$(cd "${dir}/../" && pwd -P)
|
import cdist.argparse
|
||||||
export PYTHONPATH="${libdir}"
|
import cdist.banner
|
||||||
|
import cdist.config
|
||||||
|
import cdist.install
|
||||||
|
import cdist.shell
|
||||||
|
import cdist.inventory
|
||||||
|
|
||||||
"$dir/../scripts/cdist" "$@"
|
|
||||||
|
def commandline():
|
||||||
|
"""Parse command line"""
|
||||||
|
|
||||||
|
# preos subcommand hack
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] == 'preos':
|
||||||
|
return cdist.preos.PreOS.commandline(sys.argv[1:])
|
||||||
|
parser, cfg = cdist.argparse.parse_and_configure(sys.argv[1:])
|
||||||
|
args = cfg.get_args()
|
||||||
|
|
||||||
|
# Work around python 3.3 bug:
|
||||||
|
# http://bugs.python.org/issue16308
|
||||||
|
# http://bugs.python.org/issue9253
|
||||||
|
|
||||||
|
# FIXME: catching AttributeError also hides
|
||||||
|
# real problems.. try a different way
|
||||||
|
|
||||||
|
# FIXME: we always print main help, not
|
||||||
|
# the help of the actual parser being used!
|
||||||
|
try:
|
||||||
|
getattr(args, "func")
|
||||||
|
except AttributeError:
|
||||||
|
parser['main'].print_help()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
args.func(args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if sys.version < cdist.MIN_SUPPORTED_PYTHON_VERSION:
|
||||||
|
print('Python >= {} is required on the source host.'.format(
|
||||||
|
cdist.MIN_SUPPORTED_PYTHON_VERSIO), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
exit_code = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
if re.match("__", os.path.basename(sys.argv[0])):
|
||||||
|
import cdist.emulator
|
||||||
|
emulator = cdist.emulator.Emulator(sys.argv)
|
||||||
|
emulator.run()
|
||||||
|
else:
|
||||||
|
commandline()
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
exit_code = 2
|
||||||
|
|
||||||
|
except cdist.Error as e:
|
||||||
|
log = logging.getLogger("cdist")
|
||||||
|
log.error(e)
|
||||||
|
exit_code = 1
|
||||||
|
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
|
@ -495,7 +495,7 @@ eof
|
||||||
;;
|
;;
|
||||||
|
|
||||||
shellcheck-build-helper)
|
shellcheck-build-helper)
|
||||||
${SHELLCHECKCMD} ./bin/build-helper
|
${SHELLCHECKCMD} ./bin/cdist-build-helper
|
||||||
;;
|
;;
|
||||||
|
|
||||||
check-shellcheck)
|
check-shellcheck)
|
|
@ -22,12 +22,26 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import cdist.log
|
import cdist.log
|
||||||
|
|
||||||
|
|
||||||
|
VERSION = 'unknown version'
|
||||||
|
|
||||||
|
try:
|
||||||
import cdist.version
|
import cdist.version
|
||||||
|
|
||||||
|
|
||||||
VERSION = cdist.version.VERSION
|
VERSION = cdist.version.VERSION
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
cdist_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
|
if os.path.isdir(os.path.join(cdist_dir, '.git')):
|
||||||
|
try:
|
||||||
|
VERSION = subprocess.check_output(
|
||||||
|
['git', 'describe', '--always'],
|
||||||
|
cwd=cdist_dir,
|
||||||
|
universal_newlines=True)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
BANNER = """
|
BANNER = """
|
||||||
.. . .x+=:. s
|
.. . .x+=:. s
|
||||||
|
|
|
@ -49,7 +49,7 @@ create version.py:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
./bin/build-helper version
|
./bin/cdist-build-helper version
|
||||||
|
|
||||||
Then you install it with:
|
Then you install it with:
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ Or directly with distutils:
|
||||||
|
|
||||||
python setup.py install
|
python setup.py install
|
||||||
|
|
||||||
Note that `bin/build-helper` script is intended for cdist maintainers.
|
Note that `bin/cdist-build-helper` script is intended for cdist maintainers.
|
||||||
|
|
||||||
|
|
||||||
Available versions in git
|
Available versions in git
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# 2010-2016 Nico Schottelius (nico-cdist at schottelius.org)
|
|
||||||
# 2016 Darko Poljak (darko.poljak at gmail.com)
|
|
||||||
#
|
|
||||||
# This file is part of cdist.
|
|
||||||
#
|
|
||||||
# cdist is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# cdist is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import sys
|
|
||||||
import cdist
|
|
||||||
import cdist.argparse
|
|
||||||
import cdist.banner
|
|
||||||
import cdist.config
|
|
||||||
import cdist.install
|
|
||||||
import cdist.shell
|
|
||||||
import cdist.inventory
|
|
||||||
|
|
||||||
|
|
||||||
def commandline():
|
|
||||||
"""Parse command line"""
|
|
||||||
|
|
||||||
# preos subcommand hack
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'preos':
|
|
||||||
return cdist.preos.PreOS.commandline(sys.argv[1:])
|
|
||||||
parser, cfg = cdist.argparse.parse_and_configure(sys.argv[1:])
|
|
||||||
args = cfg.get_args()
|
|
||||||
|
|
||||||
# Work around python 3.3 bug:
|
|
||||||
# http://bugs.python.org/issue16308
|
|
||||||
# http://bugs.python.org/issue9253
|
|
||||||
|
|
||||||
# FIXME: catching AttributeError also hides
|
|
||||||
# real problems.. try a different way
|
|
||||||
|
|
||||||
# FIXME: we always print main help, not
|
|
||||||
# the help of the actual parser being used!
|
|
||||||
try:
|
|
||||||
getattr(args, "func")
|
|
||||||
except AttributeError:
|
|
||||||
parser['main'].print_help()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
args.func(args)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
if sys.version < cdist.MIN_SUPPORTED_PYTHON_VERSION:
|
|
||||||
print('Python >= {} is required on the source host.'.format(
|
|
||||||
cdist.MIN_SUPPORTED_PYTHON_VERSIO), file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
exit_code = 0
|
|
||||||
|
|
||||||
try:
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
|
|
||||||
if re.match("__", os.path.basename(sys.argv[0])):
|
|
||||||
import cdist.emulator
|
|
||||||
emulator = cdist.emulator.Emulator(sys.argv)
|
|
||||||
emulator.run()
|
|
||||||
else:
|
|
||||||
commandline()
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
exit_code = 2
|
|
||||||
|
|
||||||
except cdist.Error as e:
|
|
||||||
log = logging.getLogger("cdist")
|
|
||||||
log.error(e)
|
|
||||||
exit_code = 1
|
|
||||||
|
|
||||||
sys.exit(exit_code)
|
|
9
setup.py
9
setup.py
|
@ -6,7 +6,7 @@ import subprocess
|
||||||
|
|
||||||
|
|
||||||
# We have it only if it is a git cloned repo.
|
# We have it only if it is a git cloned repo.
|
||||||
build_helper = os.path.join('bin', 'build-helper')
|
build_helper = os.path.join('bin', 'cdist-build-helper')
|
||||||
# Version file path.
|
# Version file path.
|
||||||
version_file = os.path.join('cdist', 'version.py')
|
version_file = os.path.join('cdist', 'version.py')
|
||||||
# If we have build-helper we could be a git repo.
|
# If we have build-helper we could be a git repo.
|
||||||
|
@ -56,12 +56,11 @@ setup(
|
||||||
name="cdist",
|
name="cdist",
|
||||||
packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ],
|
packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ],
|
||||||
package_data={'cdist': package_data},
|
package_data={'cdist': package_data},
|
||||||
scripts=["scripts/cdist", "scripts/cdist-dump", "scripts/cdist-new-type"],
|
scripts=["bin/cdist", "bin/cdist-dump", "bin/cdist-new-type"],
|
||||||
version=cdist.version.VERSION,
|
version=cdist.version.VERSION,
|
||||||
description="A Usable Configuration Management System",
|
description="A Usable Configuration Management System",
|
||||||
author="Nico Schottelius",
|
author="cdist contributors",
|
||||||
author_email="nico-cdist-pypi@schottelius.org",
|
url="https://cdi.st",
|
||||||
url="https://www.cdi.st/",
|
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 6 - Mature",
|
"Development Status :: 6 - Mature",
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
|
|
Loading…
Reference in a new issue