You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ei...@apache.org on 2020/04/17 03:13:36 UTC

[couchdb] 02/07: Move rebar.config.script from couch to aegis

This is an automated email from the ASF dual-hosted git repository.

eiri pushed a commit to branch aegis_key_cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit a8c9d8e933c93a5df4e0e337a44ec59b1656f3b2
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Thu Apr 16 16:42:04 2020 -0300

    Move rebar.config.script from couch to aegis
---
 src/aegis/rebar.config.script | 35 +++++++++++++++++++++++++++++++++++
 src/couch/rebar.config.script | 11 +----------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/src/aegis/rebar.config.script b/src/aegis/rebar.config.script
new file mode 100644
index 0000000..27752fe
--- /dev/null
+++ b/src/aegis/rebar.config.script
@@ -0,0 +1,35 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+
+CouchConfig = case filelib:is_file(os:getenv("COUCHDB_CONFIG")) of
+    true ->
+        {ok, Result} = file:consult(os:getenv("COUCHDB_CONFIG")),
+        Result;
+    false ->
+        []
+end.
+
+case lists:keyfind(aegis_key_manager, 1, CouchConfig) of
+    {aegis_key_manager, ""} ->
+        CONFIG;
+    {aegis_key_manager, Module} ->
+        CurrentOpts = case lists:keyfind(erl_opts, 1, CONFIG) of
+            {erl_opts, Opts} -> Opts;
+            false -> []
+        end,
+        AegisOpts = {d, 'AEGIS_KEY_MANAGER', list_to_existing_atom(Module)},
+        NewOpts = [AegisOpts | CurrentOpts],
+        lists:keystore(erl_opts, 1, CONFIG, {erl_opts, NewOpts});
+    _ ->
+        CONFIG
+end.
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index e281eab..91e24d9 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -92,15 +92,6 @@ MD5Config = case lists:keyfind(erlang_md5, 1, CouchConfig) of
         []
 end,
 
-AegisConfig = case lists:keyfind(crypto_module, 1, CouchConfig) of
-    {aegis_key_manager, ""} ->
-        [];
-    {aegis_key_manager, Module} ->
-        [{d, 'AEGIS_KEY_MANAGER', list_to_existing_atom(Module)}];
-    _ ->
-        []
-end,
-
 ProperConfig = case code:lib_dir(proper) of
     {error, bad_name} -> [];
     _ -> [{d, 'WITH_PROPER'}]
@@ -232,7 +223,7 @@ AddConfig = [
         {d, 'COUCHDB_VERSION', Version},
         {d, 'COUCHDB_GIT_SHA', GitSha},
         {i, "../"}
-    ] ++ MD5Config ++ AegisConfig ++ ProperConfig},
+    ] ++ MD5Config ++ ProperConfig},
     {port_env, PortEnvOverrides},
     {eunit_compile_opts, PlatformDefines}
 ].