Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
otp: [21, 22, 23, 24, 25]
otp: [25, 26, 27]
fail-fast: false
container:
image: erlang:${{ matrix.otp }}
steps:
- uses: actions/checkout@v3
- name: Test

- name: Mark Git directory as safe
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git fetch --unshallow
git fetch --tags

- name: Run CI
shell: bash
run: make ci
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
deps
*.beam
ebin/*.app
ebin/*.beam
setup_gen
xtest/releases
xtest/testapp-*/ebin
Expand Down
1 change: 1 addition & 0 deletions Emakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}.
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,28 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2025 Ulf Wiger <ulf@wiger.net>


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.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ eunit: compile
${REBAR3} eunit

test: eunit compile_test
ERL_LIBS=${PWD}/_build/test/lib ./setup_gen test xtest/test.conf xtest/releases/1
ERL_LIBS=${PWD}/_build/test/lib ./setup_gen -v -name test -conf xtest/test.conf -out xtest/releases/1

run_test:
erl -boot xtest/releases/1/start -config xtest/releases/1/sys
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ in [`setup`](http://github.com/uwiger/setup/blob/master/doc/setup.md).
<tr><td><a href="http://github.com/uwiger/setup/blob/master/doc/setup.md" class="module">setup</a></td></tr>
<tr><td><a href="http://github.com/uwiger/setup/blob/master/doc/setup_file.md" class="module">setup_file</a></td></tr>
<tr><td><a href="http://github.com/uwiger/setup/blob/master/doc/setup_gen.md" class="module">setup_gen</a></td></tr>
<tr><td><a href="http://github.com/uwiger/setup/blob/master/doc/setup_lib.md" class="module">setup_lib</a></td></tr></table>
<tr><td><a href="http://github.com/uwiger/setup/blob/master/doc/setup_lib.md" class="module">setup_lib</a></td></tr>
<tr><td><a href="http://github.com/uwiger/setup/blob/master/doc/setup_zomp.md" class="module">setup_zomp</a></td></tr></table>

3 changes: 2 additions & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ in [`setup`](setup.md).
<tr><td><a href="setup.md" class="module">setup</a></td></tr>
<tr><td><a href="setup_file.md" class="module">setup_file</a></td></tr>
<tr><td><a href="setup_gen.md" class="module">setup_gen</a></td></tr>
<tr><td><a href="setup_lib.md" class="module">setup_lib</a></td></tr></table>
<tr><td><a href="setup_lib.md" class="module">setup_lib</a></td></tr>
<tr><td><a href="setup_zomp.md" class="module">setup_zomp</a></td></tr></table>

2 changes: 1 addition & 1 deletion doc/edoc-info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%% encoding: UTF-8
{application,setup}.
{modules,[setup,setup_file,setup_gen,setup_lib]}.
{modules,[setup,setup_file,setup_gen,setup_lib,setup_zomp]}.
13 changes: 12 additions & 1 deletion doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ Example:
```


### <a name="Running_in_Zomp_(zx)">Running in Zomp (zx)</a> ###

Setup detects if it's running in a Zomp context, and then maps
the directory names to sensible `zx` defaults:
* `home()` : `ZompDir/etc/Realm/App/Vsn`
* `data_dir()`: `ZompDir/var/Realm/App/Vsn/setup.data`
* `log_dir() : `ZompDir/log/Realm/App`

By default, setup will not automatically verify these directories.


### <a name="Customizing_setup">Customizing setup</a> ###

The following environment variables can be used to customize `setup`:
Expand Down Expand Up @@ -135,7 +146,7 @@ other mode hooks by explicitly calling [`run_hooks/1`](#run_hooks-1).
the directories used by setup actually exist. This behavior can be disabled through
the environment variable `{verify_directories, false}`. This can be desirable
if setup is used mainly e.g. for environment variable expansion, but not for
disk storage.
disk storage. If running in a Zomp context, the default is `false`.
* `{run_timeout, Millisecs}` - Set a time limit for how long it may take for
setup to process the setup hooks. Default is `infinity`. If the timeout
is exceeded, the application start sequence will be aborted, which will
Expand Down
42 changes: 41 additions & 1 deletion doc/setup_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Function Index ##


<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#close-1">close/1</a></td><td></td></tr><tr><td valign="top"><a href="#consult-1">consult/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#consult/1" href="file.md#consult-1"><code>file:consult/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#consult_binary-1">consult_binary/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#consult/1" href="file.md#consult-1"><code>file:consult/1</code></a>, but operates directly on a binary.</td></tr><tr><td valign="top"><a href="#eval_binary-1">eval_binary/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/1" href="file.md#script-1"><code>file:script/1</code></a>, but operates directly on a binary.</td></tr><tr><td valign="top"><a href="#eval_binary-2">eval_binary/2</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/2" href="file.md#script-2"><code>file:script/2</code></a>, but operates directly on a binary.</td></tr><tr><td valign="top"><a href="#list_dir-1">list_dir/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#list_dir/1" href="file.md#list_dir-1"><code>file:list_dir/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#open-2">open/2</a></td><td></td></tr><tr><td valign="top"><a href="#read_file-1">read_file/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#read_file/1" href="file.md#read_file-1"><code>file:read_file/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#script-1">script/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/1" href="file.md#script-1"><code>file:script/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#script-2">script/2</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/2" href="file.md#script-2"><code>file:script/2</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr></table>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#close-1">close/1</a></td><td></td></tr><tr><td valign="top"><a href="#consult-1">consult/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#consult/1" href="file.md#consult-1"><code>file:consult/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#consult_binary-1">consult_binary/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#consult/1" href="file.md#consult-1"><code>file:consult/1</code></a>, but operates directly on a binary.</td></tr><tr><td valign="top"><a href="#eval_binary-1">eval_binary/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/1" href="file.md#script-1"><code>file:script/1</code></a>, but operates directly on a binary.</td></tr><tr><td valign="top"><a href="#eval_binary-2">eval_binary/2</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/2" href="file.md#script-2"><code>file:script/2</code></a>, but operates directly on a binary.</td></tr><tr><td valign="top"><a href="#list_dir-1">list_dir/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#list_dir/1" href="file.md#list_dir-1"><code>file:list_dir/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#open-2">open/2</a></td><td></td></tr><tr><td valign="top"><a href="#path_consult-2">path_consult/2</a></td><td></td></tr><tr><td valign="top"><a href="#path_open-3">path_open/3</a></td><td></td></tr><tr><td valign="top"><a href="#path_script-2">path_script/2</a></td><td></td></tr><tr><td valign="top"><a href="#path_script-3">path_script/3</a></td><td></td></tr><tr><td valign="top"><a href="#read_file-1">read_file/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#read_file/1" href="file.md#read_file-1"><code>file:read_file/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#script-1">script/1</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/1" href="file.md#script-1"><code>file:script/1</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr><tr><td valign="top"><a href="#script-2">script/2</a></td><td>Like <a docgen-rel="seemfa" docgen-href="file#script/2" href="file.md#script-2"><code>file:script/2</code></a>, but supports paths into <code>zip</code> and <code>escript</code> archives.</td></tr></table>


<a name="functions"></a>
Expand Down Expand Up @@ -93,6 +93,46 @@ producing a result.

`open(File, Opts) -> any()`

<a name="path_consult-2"></a>

### path_consult/2 ###

<pre><code>
path_consult(Path, Filename) -&gt; {ok, Terms, FullName} | {error, Reason}
</code></pre>

<ul class="definitions"><li><code>Path = [Dir]</code></li><li><code>Dir = <a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a></code></li><li><code>Filename = <a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a></code></li><li><code>Terms = [term()]</code></li><li><code>FullName = <a href="http://www.erlang.org/doc/man/file.html#type-filename_all">file:filename_all()</a></code></li><li><code>Reason = <a href="http://www.erlang.org/doc/man/file.html#type-posix">file:posix()</a> | badarg | terminated | system_limit | {Line::integer(), Mod::module(), Term::term()}</code></li></ul>

<a name="path_open-3"></a>

### path_open/3 ###

<pre><code>
path_open(Path, Filename, Modes) -&gt; {ok, IoDevice, FullName} | {error, Reason}
</code></pre>

<ul class="definitions"><li><code>Path = [Dir::<a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a>]</code></li><li><code>Filename = <a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a></code></li><li><code>Modes = [<a href="http://www.erlang.org/doc/man/file.html#type-mode">file:mode()</a> | directory]</code></li><li><code>IoDevice = <a href="http://www.erlang.org/doc/man/file.html#type-io_device">file:io_device()</a></code></li><li><code>FullName = <a href="http://www.erlang.org/doc/man/file.html#type-filename_all">file:filename_all()</a></code></li><li><code>Reason = <a href="http://www.erlang.org/doc/man/file.html#type-posix">file:posix()</a> | badarg | system_limit</code></li></ul>

<a name="path_script-2"></a>

### path_script/2 ###

<pre><code>
path_script(Path, Filename) -&gt; {ok, Value, FullName} | {error, Reason}
</code></pre>

<ul class="definitions"><li><code>Path = [Dir::<a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a>]</code></li><li><code>Filename = <a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a></code></li><li><code>Value = term()</code></li><li><code>FullName = <a href="http://www.erlang.org/doc/man/file.html#type-filename_all">file:filename_all()</a></code></li><li><code>Reason = <a href="http://www.erlang.org/doc/man/file.html#type-posix">file:posix()</a> | badarg | terminated | system_limit | {Line::integer(), Mod::module(), Term::term()}</code></li></ul>

<a name="path_script-3"></a>

### path_script/3 ###

<pre><code>
path_script(Path, Filename, Bindings) -&gt; {ok, Value, FullName} | {error, Reason}
</code></pre>

<ul class="definitions"><li><code>Path = [Dir::<a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a>]</code></li><li><code>Filename = <a href="http://www.erlang.org/doc/man/file.html#type-name_all">file:name_all()</a></code></li><li><code>Bindings = <a href="http://www.erlang.org/doc/man/erl_eval.html#type-binding_struct">erl_eval:binding_struct()</a></code></li><li><code>Value = term()</code></li><li><code>FullName = <a href="http://www.erlang.org/doc/man/file.html#type-filename_all">file:filename_all()</a></code></li><li><code>Reason = <a href="http://www.erlang.org/doc/man/file.html#type-posix">file:posix()</a> | badarg | terminated | system_limit | {Line::integer(), Mod::module(), Term::term()}</code></li></ul>

<a name="read_file-1"></a>

### read_file/1 ###
Expand Down
42 changes: 42 additions & 0 deletions doc/setup_zomp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@


# Module setup_zomp #
* [Function Index](#index)
* [Function Details](#functions)

<a name="index"></a>

## Function Index ##


<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#default_dir-1">default_dir/1</a></td><td></td></tr><tr><td valign="top"><a href="#is_zomp_context-0">is_zomp_context/0</a></td><td></td></tr><tr><td valign="top"><a href="#setup_conf_path-0">setup_conf_path/0</a></td><td></td></tr><tr><td valign="top"><a href="#update_env-0">update_env/0</a></td><td></td></tr></table>


<a name="functions"></a>

## Function Details ##

<a name="default_dir-1"></a>

### default_dir/1 ###

`default_dir(X1) -> any()`

<a name="is_zomp_context-0"></a>

### is_zomp_context/0 ###

`is_zomp_context() -> any()`

<a name="setup_conf_path-0"></a>

### setup_conf_path/0 ###

`setup_conf_path() -> any()`

<a name="update_env-0"></a>

### update_env/0 ###

`update_env() -> any()`

16 changes: 16 additions & 0 deletions ebin/setup.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{application,setup,
[{description,"Generic setup utility for Erlang-based systems"},
{vsn,"3.0.0"},
{registered,[]},
{applications,[kernel,stdlib]},
{mod,{setup_app,[]}},
{start_phases,[{run_setup,[]}]},
{env,[]},
{maintainers,["Ulf Wiger"]},
{licenses,["Apache 2.0"]},
{links,[{"Github","https://github.com/uwiger/setup"}]},
{files,["src","c_src","include","rebar.config.script","priv",
"rebar.config","rebar.lock","README*","readme*",
"LICENSE*","license*","NOTICE","Makefile"]},
{modules,[setup,setup_app,setup_file,setup_file_io_server,
setup_gen,setup_lib,setup_srv,setup_sup]}]}.
7 changes: 5 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
%% -*- mode: erlang; erlang-indent-level: 4; indent-tabs-mode: nil -*-
{minimum_otp_vsn, "21.0"}.
{minimum_otp_vsn, "27.0"}.
{erl_opts, [debug_info]}.
{plugins, [{zx_rebar_plugin, {git, "https://git.qpq.swiss/QPQ-AG/zx_rebar_plugin",
{branch, "master"}}}]}.
{deps, [{zx, {zx, "https://gitlab.com/zxq9/zx", {ref, "2a0437f4"}, "0.14.0"}}]}.
{profiles,
[
{doc, [
Expand All @@ -24,7 +27,7 @@
]}
]}.

{dialyzer, [{plt_extra_apps, [sasl]}]}.
{dialyzer, [{plt_extra_apps, [sasl, zx]}]}.

{post_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)",
escriptize,
Expand Down
6 changes: 5 additions & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
[].
[{<<"zx">>,
{zx,"https://gitlab.com/zxq9/zx",
{ref,"2a0437f416f94596e4e3b403603dbd028727742d"},
"0.14.0"},
0}].
2 changes: 1 addition & 1 deletion src/setup.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{application, setup,
[
{description, "Generic setup application for Erlang-based systems"},
{vsn, git},
{vsn, "zomp"},
{registered, []},
{applications, [
kernel,
Expand Down
14 changes: 14 additions & 0 deletions src/setup.app.src.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%% -*- erlang-mode; erlang-indent-level: 4; indent-tabs-mode: nil -*-

[{application, Name, Opts}] = CONFIG.
case lists:keyfind(vsn, 1, Opts) of
{vsn, "zomp"} ->
ZompMetaF = filename:join(filename:dirname(filename:dirname(SCRIPT)), "zomp.meta"),
{ok, ZMeta} = file:consult(ZompMetaF),
{_, {_, _, {Vmaj,Vmin,Vpatch}}} = lists:keyfind(package_id, 1, ZMeta),
VsnStr = unicode:characters_to_list(io_lib:fwrite("~w.~w.~w", [Vmaj, Vmin, Vpatch])),
Opts1 = lists:keyreplace(vsn, 1, Opts, {vsn, VsnStr}),
[{application, Name, Opts1}];
_ ->
CONFIG
end.
Loading
Loading