Commit 67313146 authored by Michael Hanselmann's avatar Michael Hanselmann

Makefile: Generalize bootstrap script generator

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent c7b86f6c
......@@ -633,28 +633,31 @@ $(REPLACE_VARS_SED): Makefile
echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
} > $@
# Using deferred evaluation
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
test -n "$(MODULE)" || { echo Missing module; exit 1; }
set -e; \
module='$(subst -,_,$(notdir $@))'; \
{ echo '#!/usr/bin/python'; \
echo '# This file is automatically generated, do not edit!'; \
echo "# Edit ganeti.client.$$module instead."; \
echo "# Edit $(MODULE) instead."; \
echo; \
echo '"""Bootstrap script for L{ganeti.client.'"$$module"'}"""'; \
echo '"""Bootstrap script for L{$(MODULE)}"""'; \
echo; \
echo '# pylint: disable-msg=C0103'; \
echo '# C0103: Invalid name'; \
echo; \
echo 'import sys'; \
echo "from ganeti.client import $$module"; \
echo 'import $(MODULE) as main'; \
echo; \
echo '# Temporarily alias commands until bash completion'; \
echo '# generator is changed'; \
echo "if hasattr($$module, \"commands\"):"; \
echo " commands = $$module.commands"; \
echo 'if hasattr(main, "commands"):'; \
echo ' commands = main.commands'; \
echo; \
echo 'if __name__ == "__main__":'; \
echo " sys.exit($$module.Main())"; \
echo ' sys.exit(main.Main())'; \
} > $@
chmod u+x $@
......
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