Skip to content

Commit

Permalink
chore: add auxiliary scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lafirest committed Nov 21, 2023
1 parent 36827df commit d0f4c88
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{plugins, [
coveralls,
pc
pc,
{rebar3_dynamic_plugin, {git, "https://github.com/lafirest/rebar3_dynamic_plugin.git"}}
]}.

{project_plugins, [
erlfmt
]}.

{dynamic_plugin_script, "scripts/sdk_checking.erl"}.

{provider_hooks, [
{pre, [
{compile, dynamic_plugin},
{compile, {pc, compile}},
{clean, {pc, clean}}
]}
Expand Down
29 changes: 29 additions & 0 deletions scripts/fetch_fdb_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -euo pipefail

usage() {
echo "Usage: $0 <deb|rpm> <OUTPUT Directory>"
echo ""
echo "Download the FoundationDB client binary package into specific directory"
exit 1
}

if [ "$#" -ne 3 ]; then
usage
fi

FDB_VERSION="7.1.43"
TYPE="${1}"
OUTPUT="${2}"

case "$TYPE" in
deb)
LINK="https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-clients_${FDB_VERSION}-1_amd64.deb"
;;
rpm)
LINK="https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-clients-${FDB_VERSION}-1.el7.x86_64.rpm"
;;
esac

wget -P "$OUTPUT" "$LINK"
17 changes: 17 additions & 0 deletions scripts/sdk_checking.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-module(sdk_checking).

-export([main/1]).

main(_State) ->
case os:cmd("which fdbcli") of
"" ->
help(),
{error, not_found_foundation_client};
_ ->
ok
end.

help() ->
io:format(">>> Checking SDK dependency failed <<<\n"),
io:format("You should install the FoundationDB client first\n"),
io:format("You can use the 'scripts/fetch_fdb_cli.sh' to download the install packeage\n").

0 comments on commit d0f4c88

Please sign in to comment.