diff --git a/buildout.cfg b/buildout.cfg index a887036..4bfe6ca 100755 --- a/buildout.cfg +++ b/buildout.cfg @@ -1,8 +1,8 @@ [buildout] extends = - communes.cfg -# communes-dev.cfg +# communes.cfg + communes-dev.cfg # bep.cfg # bep-dev.cfg # charleroi.cfg diff --git a/docker/Dockerfile-base b/docker/Dockerfile-base index 8b44c9c..1e02bd1 100644 --- a/docker/Dockerfile-base +++ b/docker/Dockerfile-base @@ -135,4 +135,4 @@ ENV ZEO_ADDRESS=zeo:8100 \ EXPOSE 8081 ENTRYPOINT ["/plone/docker-entrypoint.sh"] -CMD ["instance"] +CMD [""] diff --git a/docker/Dockerfile-demo b/docker/Dockerfile-demo index af45ef1..9ea1567 100644 --- a/docker/Dockerfile-demo +++ b/docker/Dockerfile-demo @@ -96,4 +96,4 @@ ENV ZEO_ADDRESS=zeo:8100 \ EXPOSE 8081 ENTRYPOINT ["/plone/docker-entrypoint.sh"] -CMD ["instance"] +CMD [""] diff --git a/docker/Dockerfile-dev b/docker/Dockerfile-dev index 207c4f7..38bbbf5 100644 --- a/docker/Dockerfile-dev +++ b/docker/Dockerfile-dev @@ -59,4 +59,4 @@ RUN sed -i "s/\${buildout:directory}\/var/\/data/g" *.cfg \ USER imio EXPOSE 8081 ENTRYPOINT ["/plone/docker-entrypoint.sh"] -CMD ["instance"] \ No newline at end of file +CMD [""] \ No newline at end of file diff --git a/docker/Dockerfile-latest b/docker/Dockerfile-latest index f31c940..3601db6 100644 --- a/docker/Dockerfile-latest +++ b/docker/Dockerfile-latest @@ -94,4 +94,4 @@ ENV ZEO_ADDRESS=zeo:8100 \ EXPOSE 8081 ENTRYPOINT ["/plone/docker-entrypoint.sh"] -CMD ["instance"] +CMD [""] diff --git a/docker/docker-compose-dev.yml b/docker/docker-compose-dev.yml index 2465163..1966781 100644 --- a/docker/docker-compose-dev.yml +++ b/docker/docker-compose-dev.yml @@ -142,7 +142,6 @@ services: # SERVICE_NAME: "worker-cron" maintenance: image: imiobe/iadelib:dev - command: maintenance ports: - "20089:8080" networks: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 57014e4..2051e7f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -148,8 +148,6 @@ services: maintenance: image: imiobe/iadelib:demo-latest - # command: maintenance - entrypoint: bash ports: - "20089:8080" networks: diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 97e9e3c..72a9bb4 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -18,12 +18,12 @@ function wait_for_cron() { INTERVAL=5 set +e SECONDS=0 - response="$($CURL)" - tries=1 + response="404" + tries=0 while [[ $response != "200" && $tries -lt $MAX_TRIES ]] do - echo "Waiting for cron" sleep $INTERVAL + echo "Waiting for cron" response=$($CURL) ((tries+=1)) done @@ -54,7 +54,7 @@ function start() { trap _stop SIGTERM SIGINT $cmd start - # ensure file xists otherwise logtail returns 1 + # ensure file exists otherwise logtail returns 1 touch "/data/log/$HOSTNAME.log" exec "$cmd" "logtail" } @@ -62,11 +62,14 @@ function start() { setup "$1" PRIORIY="instance-cron instance-debug maintenance zeoserver" -if [[ "instance" == "$1" || ! $PRIORIY == *"$1"* ]]; then +if [[ "instance" == "$1" || ( ! $PRIORIY == *"$1"* && $# -gt 0 ) ]]; then wait_for_cron "$1" fi case "$1" in +"") + exit 0 + ;; "maintenance") shift echo "Executing maintenance command : '$*'" diff --git a/lib64/python2.7/config/Makefile b/lib64/python2.7/config/Makefile new file mode 120000 index 0000000..4f75dab --- /dev/null +++ b/lib64/python2.7/config/Makefile @@ -0,0 +1 @@ +/usr/lib64/python2.7/config/Makefile \ No newline at end of file diff --git a/lib64/python2.7/lib-dynload b/lib64/python2.7/lib-dynload new file mode 120000 index 0000000..2cdff3a --- /dev/null +++ b/lib64/python2.7/lib-dynload @@ -0,0 +1 @@ +/usr/lib64/python2.7/lib-dynload \ No newline at end of file diff --git a/lib64/python2.7/os.py b/lib64/python2.7/os.py new file mode 120000 index 0000000..201950a --- /dev/null +++ b/lib64/python2.7/os.py @@ -0,0 +1 @@ +/usr/lib64/python2.7/os.py \ No newline at end of file diff --git a/lib64/python2.7/os.pyc b/lib64/python2.7/os.pyc new file mode 120000 index 0000000..cf20457 --- /dev/null +++ b/lib64/python2.7/os.pyc @@ -0,0 +1 @@ +/usr/lib64/python2.7/os.pyc \ No newline at end of file diff --git a/lib64/python2.7/site.py b/lib64/python2.7/site.py new file mode 100644 index 0000000..262d557 --- /dev/null +++ b/lib64/python2.7/site.py @@ -0,0 +1,190 @@ +# -*- coding: utf-8 -*- +""" +A simple shim module to fix up things on Python 2 only. + +Note: until we setup correctly the paths we can only import built-ins. +""" +import sys + + +def main(): + """Patch what needed, and invoke the original site.py""" + here = __file__ # the distutils.install patterns will be injected relative to this site.py, save it here + config = read_pyvenv() + sys.real_prefix = sys.base_prefix = config["base-prefix"] + sys.base_exec_prefix = config["base-exec-prefix"] + sys.base_executable = config["base-executable"] + global_site_package_enabled = config.get("include-system-site-packages", False) == "true" + rewrite_standard_library_sys_path() + disable_user_site_package() + load_host_site(here) + if global_site_package_enabled: + add_global_site_package() + rewrite_getsitepackages(here) + + +def load_host_site(here): + """trigger reload of site.py - now it will use the standard library instance that will take care of init""" + # we have a duality here, we generate the platform and pure library path based on what distutils.install specifies + # because this is what pip will be using; the host site.py though may contain it's own pattern for where the + # platform and pure library paths should exist + + # notably on Ubuntu there's a patch for getsitepackages to point to + # - prefix + local/lib/pythonx.y/dist-packages + # - prefix + lib/pythonx.y/dist-packages + # while distutils.install.cmd still points both of these to + # - prefix + lib/python2.7/site-packages + + # to facilitate when the two match, or not we first reload the site.py, now triggering the import of host site.py, + # as this will ensure that initialization code within host site.py runs + + reload(sys.modules["site"]) # noqa # call system site.py to setup import libraries + + # and then if the distutils site packages are not on the sys.path we add them via add_site_dir; note we must add + # them by invoking add_site_dir to trigger the processing of pth files + + add_site_dir = sys.modules["site"].addsitedir + for path in get_site_packages_dirs(here): + add_site_dir(path) + + +def get_site_packages_dirs(here): + import json + import os + + site_packages = r""" + ["../site-packages", "../../../lib/python2.7/site-packages"] + """ + + for path in json.loads(site_packages): + yield os.path.abspath(os.path.join(here, path.encode("utf-8"))) + + +sep = "\\" if sys.platform == "win32" else "/" # no os module here yet - poor mans version + + +def read_pyvenv(): + """read pyvenv.cfg""" + config_file = "{}{}pyvenv.cfg".format(sys.prefix, sep) + with open(config_file) as file_handler: + lines = file_handler.readlines() + config = {} + for line in lines: + try: + split_at = line.index("=") + except ValueError: + continue # ignore bad/empty lines + else: + config[line[:split_at].strip()] = line[split_at + 1 :].strip() + return config + + +def rewrite_standard_library_sys_path(): + """Once this site file is loaded the standard library paths have already been set, fix them up""" + exe, prefix, exec_prefix = get_exe_prefixes(base=False) + base_exe, base_prefix, base_exec = get_exe_prefixes(base=True) + exe_dir = exe[: exe.rfind(sep)] + for at, path in enumerate(sys.path): + path = abs_path(path) # replace old sys prefix path starts with new + skip_rewrite = path == exe_dir # don't fix the current executable location, notably on Windows this gets added + skip_rewrite = skip_rewrite + if not skip_rewrite: + sys.path[at] = map_path(path, base_exe, exe_dir, exec_prefix, base_prefix, prefix, base_exec) + + # the rewrite above may have changed elements from PYTHONPATH, revert these if on + if sys.flags.ignore_environment: + return + import os + + python_paths = [] + if "PYTHONPATH" in os.environ and os.environ["PYTHONPATH"]: + for path in os.environ["PYTHONPATH"].split(os.pathsep): + if path not in python_paths: + python_paths.append(path) + sys.path[: len(python_paths)] = python_paths + + +def get_exe_prefixes(base=False): + return tuple(abs_path(getattr(sys, ("base_" if base else "") + i)) for i in ("executable", "prefix", "exec_prefix")) + + +def abs_path(value): + values, keep = value.split(sep), [] + at = len(values) - 1 + while at >= 0: + if values[at] == "..": + at -= 1 + else: + keep.append(values[at]) + at -= 1 + return sep.join(keep[::-1]) + + +def map_path(path, base_executable, exe_dir, exec_prefix, base_prefix, prefix, base_exec_prefix): + if path_starts_with(path, exe_dir): + # content inside the exe folder needs to remap to original executables folder + orig_exe_folder = base_executable[: base_executable.rfind(sep)] + return "{}{}".format(orig_exe_folder, path[len(exe_dir) :]) + elif path_starts_with(path, prefix): + return "{}{}".format(base_prefix, path[len(prefix) :]) + elif path_starts_with(path, exec_prefix): + return "{}{}".format(base_exec_prefix, path[len(exec_prefix) :]) + return path + + +def path_starts_with(directory, value): + return directory.startswith(value if value[-1] == sep else value + sep) + + +def disable_user_site_package(): + """Flip the switch on enable user site package""" + # sys.flags is a c-extension type, so we cannot monkeypatch it, replace it with a python class to flip it + sys.original_flags = sys.flags + + class Flags(object): + def __init__(self): + self.__dict__ = {key: getattr(sys.flags, key) for key in dir(sys.flags) if not key.startswith("_")} + + sys.flags = Flags() + sys.flags.no_user_site = 1 + + +def add_global_site_package(): + """add the global site package""" + import site + + # add user site package + sys.flags = sys.original_flags # restore original + site.ENABLE_USER_SITE = None # reset user site check + # add the global site package to the path - use new prefix and delegate to site.py + orig_prefixes = None + try: + orig_prefixes = site.PREFIXES + site.PREFIXES = [sys.base_prefix, sys.base_exec_prefix] + site.main() + finally: + site.PREFIXES = orig_prefixes + site.PREFIXES + + +# Debian and it's derivatives patch this function. We undo the damage +def rewrite_getsitepackages(here): + site = sys.modules["site"] + + site_package_dirs = get_site_packages_dirs(here) + orig_getsitepackages = site.getsitepackages + + def getsitepackages(): + sitepackages = orig_getsitepackages() + if sys.prefix not in site.PREFIXES or sys.exec_prefix not in site.PREFIXES: + # Someone messed with the prefixes, so we stop patching + return sitepackages + for path in site_package_dirs: + if path not in sitepackages: + sitepackages.insert(0, path) + + return sitepackages + + site.getsitepackages = getsitepackages + + +main() diff --git a/lib64/python2.7/site.pyc b/lib64/python2.7/site.pyc new file mode 100644 index 0000000..d43155c Binary files /dev/null and b/lib64/python2.7/site.pyc differ diff --git a/lib64/python2.7/site.pyo b/lib64/python2.7/site.pyo new file mode 100644 index 0000000..d43155c Binary files /dev/null and b/lib64/python2.7/site.pyo differ diff --git a/sources.cfg b/sources.cfg index 309ad38..e82595d 100644 --- a/sources.cfg +++ b/sources.cfg @@ -55,7 +55,7 @@ imio.zamqp.pm = git ${remotes:imio}/imio.zamqp.pm.git pushurl=${remotes:imio_pus Products.CPUtils = git ${remotes:imio}/Products.CPUtils.git pushurl=${remotes:imio_push}/Products.CPUtils.git # used to test branches on Jenkins, leave branch=master by default -Products.PloneMeeting = git ${remotes:imio}/Products.PloneMeeting.git pushurl=${remotes:imio_push}/Products.PloneMeeting.git branch=master +Products.PloneMeeting = git ${remotes:imio}/Products.PloneMeeting.git pushurl=${remotes:imio_push}/Products.PloneMeeting.git branch=PM-3908_history_tooltip_fix # profiles specific package Products.MeetingCommunes = git ${remotes:imio}/Products.MeetingCommunes.git pushurl=${remotes:imio_push}/Products.MeetingCommunes.git branch=master