From 2ef49f1d22e86ff5f0b347f2cbb08306376ce854 Mon Sep 17 00:00:00 2001
From: Tristan Cavelier <tristan.cavelier@nexedi.com>
Date: Wed, 24 Feb 2016 14:00:45 +0000
Subject: [PATCH] stack/erp5: add zope promise
 is-process-older-than-dependency-set

---
 stack/erp5/buildout.cfg         |  6 ++++--
 stack/erp5/instance-zope.cfg.in | 13 +++++++++++++
 stack/erp5/instance.cfg.in      |  1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/stack/erp5/buildout.cfg b/stack/erp5/buildout.cfg
index b66c58b3c..884bcef9b 100644
--- a/stack/erp5/buildout.cfg
+++ b/stack/erp5/buildout.cfg
@@ -233,7 +233,7 @@ recipe = slapos.recipe.template:jinja2
 # XXX: "template.cfg" is hardcoded in instanciation recipe
 rendered = ${buildout:directory}/template.cfg
 template = ${:_profile_base_location_}/instance.cfg.in
-md5sum = fdaaac449c92dcd68f0434b244d579f2
+md5sum = 10d02ec69c875e6a55afe3bf79db7bba
 mode = 640
 context =
     key mariadb_link_binary template-mariadb:link-binary
@@ -316,6 +316,7 @@ context =
     key xdamage_location xdamage:location
     key xfixes_location xfixes:location
     key zlib_location zlib:location
+    key extra_path_list eggs:extra-paths
 
 [monitor-template-dummy]
 <= download-base
@@ -339,7 +340,7 @@ md5sum = b0cb0ee97cddc79112a718e065806037
 [template-zope]
 <= download-base
 filename = instance-zope.cfg.in
-md5sum = bac5ff1ded5454749ec0e18d0ae1dae8
+md5sum = 91b830903bde2a60fc589dfb1943e3e3
 link-binary =
   ${aspell:location}/bin/aspell
   ${dmtx-utils:location}/bin/dmtxwrite
@@ -613,6 +614,7 @@ eggs +=
   slapos.toolbox[zodbpack]
 scripts +=
   is-local-tcp-port-opened
+  is-process-older-than-dependency-set
   onetimedownload
   zodbpack
 
diff --git a/stack/erp5/instance-zope.cfg.in b/stack/erp5/instance-zope.cfg.in
index f61455c48..d66893981 100644
--- a/stack/erp5/instance-zope.cfg.in
+++ b/stack/erp5/instance-zope.cfg.in
@@ -317,6 +317,19 @@ hostname = {{ ipv4 }}
 port = {{ port }}
 path = ${directory:promises}/{{ name }}
 
+{% set extra_path_list = [] -%}
+{% set shell_escaped_extra_path_list = [] -%}
+{% for line in parameter_dict['extra-path-list'].splitlines() -%}
+{%   set line = line.strip() -%}
+{%   do extra_path_list.append(line) -%}
+{%   do shell_escaped_extra_path_list.append(line.replace("\x27", "\x27\\\x27\x27")) -%}
+{% endfor -%}
+[{{ section("promise-" ~ name ~ "-is-running-actual-product") }}]
+recipe = slapos.cookbook:wrapper
+command-line = '{{ parameter_dict['bin-directory'] }}/is-process-older-than-dependency-set' -k '{{ "${" ~ conf_parameter_name ~ ":pid-file}" }}' {{ " ".join(shell_escaped_extra_path_list) }}
+wrapper-path = ${directory:promises}/{{ name }}-is-running-actual-product
+parameters-extra = true
+
 {% if use_ipv6 -%}
 [{{ zope_tunnel_section_name }}]
 < = ipv6toipv4-base
diff --git a/stack/erp5/instance.cfg.in b/stack/erp5/instance.cfg.in
index db4de8d95..483bbb1f4 100644
--- a/stack/erp5/instance.cfg.in
+++ b/stack/erp5/instance.cfg.in
@@ -124,6 +124,7 @@ link-binary = {{ dumps(zope_link_binary) }}
 userhosts = {{ userhosts_location }}
 runzope-userhosts-preloaded-template = {{ template_runzope_userhosts_preloaded }}
 template-monitor = {{ dumps(template_monitor) }}
+extra-path-list = {{ dumps(extra_path_list) }}
 
 [dynamic-template-zope]
 <= jinja2-template-base
-- 
2.30.9