| %% -*- erlang -*- |
| % 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. |
| |
| % |
| % Blacklist some bad releases. |
| % |
| {ok, Version} = file:read_file(filename:join( |
| [code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"] |
| )). |
| |
| % Version may be binary if file has /n at end :( |
| % there is no string:trim/1 in Erlang 19 :( |
| VerString = case Version of |
| V when is_binary(V) -> string:strip(binary_to_list(V), right, $\n); |
| _ -> string:strip(Version, right, $\n) |
| end. |
| VerList = lists:map(fun(X) -> {Int, _} = string:to_integer(X), Int end, |
| string:tokens(VerString, ".")). |
| |
| DisplayMsg = fun(Msg, Args) -> |
| Base = iolist_to_binary(io_lib:format(Msg, Args)), |
| Lines = binary:split(Base, <<"\n">>, [global]), |
| MaxLen = lists:foldl(fun(Line, Acc) -> |
| max(Acc, size(Line)) |
| end, 0, Lines), |
| Decoration = iolist_to_binary(["*" || _ <- lists:seq(1, MaxLen)]), |
| ReNewLined = [[L, "~n"] || L <- Lines], |
| NewLines = ["~n", Decoration, "~n", ReNewLined, Decoration, "~n~n"], |
| MsgBin = iolist_to_binary(NewLines), |
| io:format(binary_to_list(MsgBin), []) |
| end. |
| |
| ErlangTooOld = fun(Ver) -> |
| DisplayMsg( |
| "This version of Erlang (~p) is too old for use with Apache CouchDB.~n~n" |
| "See https://docs.couchdb.org/en/stable/install/unix.html#dependencies~n" |
| "for the latest information on dependencies.", |
| [Ver] |
| ), |
| halt(1) |
| end. |
| |
| NotSupported = fun(Ver) -> |
| DisplayMsg( |
| "This version of Erlang (~p) is not officially supported by Apache~n" |
| "CouchDB. While we do not officially support this version, there~n" |
| "are also no known bugs or incompatibilities.~n~n" |
| "See https://docs.couchdb.org/en/stable/install/unix.html#dependencies~n" |
| "for the latest information on dependencies.", |
| [Ver] |
| ) |
| end. |
| |
| BadErlang = fun(Ver) -> |
| DisplayMsg( |
| "This version of Erlang (~p) is known to contain bugs that directly~n" |
| "affect the correctness of Apache CouchDB.~n~n" |
| "You should *NOT* use this version of Erlang.~n~n" |
| "See https://docs.couchdb.org/en/stable/install/unix.html#dependencies~n" |
| "for the latest information on dependencies.", |
| [Ver] |
| ), |
| case os:getenv("TRAVIS") of |
| "true" -> |
| io:fwrite("Travis run, ignoring bad release. You have been warned!~n"), |
| ok; |
| _ -> |
| halt(1) |
| end |
| end. |
| |
| case VerList of |
| % Leave example around if we have to exlude specific versions |
| % [22, 0, N | _] when N < 5 -> BadErlang(VerString); |
| _ -> ok |
| end. |
| |
| % Set the path to the configuration environment generated |
| % by `./configure`. |
| |
| COUCHDB_ROOT = filename:dirname(SCRIPT). |
| os:putenv("COUCHDB_ROOT", COUCHDB_ROOT). |
| |
| ConfigureEnv = filename:join(COUCHDB_ROOT, "config.erl"). |
| os:putenv("COUCHDB_CONFIG", ConfigureEnv). |
| |
| CouchConfig = case filelib:is_file(ConfigureEnv) of |
| true -> |
| {ok, Result} = file:consult(ConfigureEnv), |
| Result; |
| false -> |
| [] |
| end. |
| |
| os:putenv("COUCHDB_APPS_CONFIG_DIR", filename:join([COUCHDB_ROOT, "rel/apps"])). |
| |
| |
| WithProper = lists:keyfind(with_proper, 1, CouchConfig) == {with_proper, true}. |
| |
| OptionalDeps = case WithProper of |
| true -> |
| [{proper, {url, "https://github.com/proper-testing/proper"}, {tag, "v1.4"}}]; |
| false -> |
| [] |
| end. |
| |
| AddConfig = [ |
| {require_otp_vsn, "23|24|25"}, |
| {deps_error_on_conflict, true}, |
| {deps, [ |
| {proper, {git, "https://github.com/proper-testing/proper", {ref, "cfc29e7615ec0a93ac0be619d33609c2139b57fd"}}}, |
| {config, {git, "https://github.com/jiahuili430/couchdb-config.git", {ref,"0571481ed314c77a6e7e44ec904afa0109860591"}}}, |
| {bear, {git, "https://github.com/jiahuili430/couchdb-bear.git", {ref,"da1e52678d628b394d4bf241ccbe410ab90fd1e3"}}}, |
| {b64url, {git, "https://github.com/apache/couchdb-b64url.git", {ref, "ef4fca0c8d18b963412fc16f5848e95944977927"}}}, |
| {ets_lru, {git, "https://github.com/apache/couchdb-ets-lru.git", {ref, "f1ca157d6f96c9edf343e280709085f9eed1e716"}}}, |
| {ibrowse, {git, "https://github.com/apache/couchdb-ibrowse.git", {ref, "a62d4a6d236729e5869842c70447ad46b3409912"}}}, |
| {jiffy, {git, "https://github.com/apache/couchdb-jiffy.git", {ref, "9ea1b35b6e60ba21dfd4adbd18e7916a831fd7d4"}}}, |
| {mochiweb, {git, "https://github.com/apache/couchdb-mochiweb.git", {ref, "845803a5defa693c546ea7250818f226a52d2891"}}}, |
| {meck, {git, "https://github.com/apache/couchdb-meck.git", {ref, "cc47aab4b64a46a5409c1a93353d44a367b41454"}}}, |
| {recon, {git, "https://github.com/apache/couchdb-recon", {ref, "34194da6d9f8ed25f274e0ebb098dc9e95bcf547"}}}, |
| {khash, {git, "https://github.com/jiahuili430/couchdb-khash", {ref, "4a0e07f7a2870a543510db355d6c2e9c3c1d84b1"}}}, |
| {snappy, {git, "https://github.com/jiahuili430/couchdb-snappy.git", {ref, "536286ada94a3aeee6042d047f3a9c369a5f1475"}}}, |
| {folsom, {git, "https://github.com/jiahuili430/couchdb-folsom.git", {ref, "87f778c1efb11e9caebba328a2cba05453db668c"}}}, |
| {hyper, {git, "https://github.com/jiahuili430/couchdb-hyper.git", {ref, "69fa387bc9cd67dbe2f4649b4ebd2239e879f239"}}} |
| ]}, |
| {plugins, [ic, erlfmt, rebar3_path_deps]}, |
| {erlfmt, [write]}, |
| {erl_opts, [ |
| {i, "../"}, |
| {i, "src/couch_tests/include"}, |
| {i, "src/mochiweb/include"}, |
| {i, "src/rexi/include"}, |
| {i, "src/proper/include"}, |
| {i, "src/folsom/include"}, |
| {i, "src/mem3/include"}, |
| {i, "src/couch_mrview/include"}, |
| {i, "src/couch/include"}, |
| {i, "src/couch_replicator/include"}, |
| {i, "src/meck/test/include"}, |
| {i, "src/couch_log/include"}, |
| {i, "src/dreyfus/include"}, |
| {i, "src/chttpd/include"}, |
| {i, "src/ibrowse/include"}, |
| {i, "src/fabric/include"}, |
| {d, 'COUCHDB_ERLANG_VERSION', VerString} |
| ]}, |
| {eunit_opts, [ |
| verbose, |
| {report, {eunit_progress, [colored, profile]}}, |
| {report, {eunit_surefire, [{dir, "_build/test"}]}} |
| ]}, |
| {project_app_dirs, ["src/*"]}, |
| {eunit_tests, [ |
| %{application, b64url}, |
| {application, chttpd}, |
| %{application, config}, |
| {application, couch_dist}, |
| {application, couch_event}, |
| {application, couch_index}, |
| {application, couch_log}, |
| {application, couch_mrview}, |
| {application, couch_peruser}, |
| {application, couch_plugins}, |
| {application, couch_prometheus}, |
| {application, couch_pse_tests}, |
| {application, couch_replicator}, |
| {application, couch_stats}, |
| {application, couch_tests}, |
| {application, couch}, |
| {application, custodian}, |
| {application, ddoc_cache}, |
| {application, dreyfus}, |
| %{application, ets_lru}, |
| {application, fabric}, |
| {application, global_changes}, |
| {application, ioq}, |
| %{application, jiffy}, |
| {application, jwtf}, |
| {application, ken}, |
| %{application, khash}, |
| {application, mango}, |
| {application, mem3}, |
| %{application, recon}, |
| {application, rexi}, |
| {application, setup}, |
| {application, smoosh}, |
| {application, weatherreport}, |
| {application, couch_epi} |
| ]}, |
| {profiles, [{test, [ |
| {extra_src_dirs, [{"test", [{recursive, true}]}]}, |
| {deps, [ |
| % {b64url, {git, "https://github.com/apache/couchdb-b64url.git", {ref, "ef4fca0c8d18b963412fc16f5848e95944977927"}}}, |
| % {ets_lru, {git, "https://github.com/apache/couchdb-ets-lru.git", {ref, "f1ca157d6f96c9edf343e280709085f9eed1e716"}}}, |
| % {jiffy, {git, "https://github.com/apache/couchdb-jiffy.git", {ref, "9ea1b35b6e60ba21dfd4adbd18e7916a831fd7d4"}}}, |
| % {config, {git, "https://github.com/jiahuili430/couchdb-config.git", {ref,"0571481ed314c77a6e7e44ec904afa0109860591"}}}, |
| % {khash, {git, "https://github.com/jiahuili430/couchdb-khash", {ref, "ee87ab0c6bedf0b2b859a867afe5a4ce0ef422a2"}}} |
| ]} |
| ]}]}, |
| {dialyzer, [ |
| {plt_location, local}, |
| {plt_location, COUCHDB_ROOT}, |
| {plt_extra_apps, [ |
| asn1, compiler, crypto, inets, kernel, runtime_tools, |
| sasl, setup, ssl, stdlib, syntax_tools, xmerl]}, |
| {warnings, [unmatched_returns, error_handling, race_conditions]}]}, |
| {post_hooks, [{compile, "escript support/build_js.escript"}]}, |
| {relx, [ |
| {release, {couchdb, "3.2.2"}, [ |
| %% stdlib |
| asn1, |
| compiler, |
| crypto, |
| inets, |
| runtime_tools, |
| sasl, |
| ssl, |
| syntax_tools, |
| xmerl, |
| |
| %% couchdb |
| b64url, |
| bear, |
| chttpd, |
| config, |
| couch, |
| couch_epi, |
| couch_index, |
| couch_log, |
| couch_mrview, |
| couch_plugins, |
| couch_replicator, |
| couch_stats, |
| couch_tests, |
| couch_event, |
| couch_peruser, |
| couch_dist, |
| custodian, |
| ddoc_cache, |
| dreyfus, |
| ets_lru, |
| fabric, |
| folsom, |
| global_changes, |
| hyper, |
| ibrowse, |
| ioq, |
| jiffy, |
| jwtf, |
| ken, |
| khash, |
| mango, |
| mem3, |
| mochiweb, |
| rexi, |
| setup, |
| smoosh, |
| snappy, |
| weatherreport, |
| couch_prometheus, |
| |
| %% extra |
| recon, |
| triq |
| ]}, |
| |
| {mode, prod}, |
| {overlay_vars, "rel/couchdb.config"}, |
| {sys_config, "rel/files/sys.config"}, |
| {vm_args, "rel/files/vm.args"}, |
| |
| {overlay, [ |
| {copy, "LICENSE", "LICENSE"}, |
| {mkdir, "var/log"}, |
| {copy, "rel/overlay/bin", "bin"}, |
| {copy, "rel/overlay/etc", "etc"}, |
| {copy, "bin/couchjs", "bin/couchjs"}, |
| {copy, "share/server/main.js", "share/server/main.js"}, |
| {copy, "share/server/main-coffee.js", "share/server/main-coffee.js"}, |
| {copy, "bin/weatherreport", "bin/weatherreport"}, |
| {template, "rel/overlay/etc/default.ini", "etc/default.ini"}, |
| {template, "rel/overlay/etc/vm.args", "etc/vm.args"}, |
| {template, "rel/files/couchdb.in", "bin/couchdb"}, |
| {template, "rel/files/couchdb.cmd.in", "bin/couchdb.cmd"} |
| ]} |
| ]} |
| ]. |
| |
| lists:foldl(fun({K, V}, CfgAcc) -> |
| case lists:keyfind(K, 1, CfgAcc) of |
| {K, Existent} when is_list(Existent) andalso is_list(V) -> |
| lists:keystore(K, 1, CfgAcc, {K, Existent ++ V}); |
| false -> |
| lists:keystore(K, 1, CfgAcc, {K, V}) |
| end |
| end, CONFIG, AddConfig). |