Skip to content

Commit

Permalink
Fixes the installation
Browse files Browse the repository at this point in the history
This change set fixes the installer so that the generated escript is deployed in the installation, instead of the escript executable.

Signed-off-by: Fred Dushin <[email protected]>
  • Loading branch information
fadushin committed Oct 16, 2023
1 parent 567ddbf commit 6fac765
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ echo_run mkdir -p "${dest_dir}"
echo_run tar -C "${dest_dir}" -x -f "${tmp_dir}/atomvm_packbeam-${version}.tar"

echo_run mkdir -p "${prefix}/bin"
echo_run sed "s|PACKBEAM_INSTALL_LOCATION|${dest_dir}|g" "${root_dir}/release/packbeam.in" > "${prefix}/bin/packbeam"
echo_run mv "${dest_dir}/bin/packbeam.sh" "${prefix}/bin/packbeam"
echo_run chmod 755 "${prefix}/bin/packbeam"

echo_run rm -rf "${tmp_dir}"
Expand Down
13 changes: 10 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@
{mode, prod},
{generate_start_script, false},
{overlay, [
{copy, "src/packbeam.erl", "bin/packbeam.escript"}
{template, "release/packbeam.in", "bin/packbeam.sh"}
]}
]}.

%% copy and rename escript next to `packbeam.escript` (See escript man page)
%% make sure escriptize is run before we release
{provider_hooks, [
{pre, [
{release, escriptize}
]}
]}.

%% copy the generated escript into the release
{post_hooks, [
{release, "cp ${REBAR_BUILD_DIR}/rel/atomvm_packbeam/erts-${ERLANG_ERTS_VER}/bin/escript ${REBAR_BUILD_DIR}/rel/atomvm_packbeam/bin/packbeam"}
{release, "cp ${REBAR_BUILD_DIR}/bin/packbeam ${REBAR_BUILD_DIR}/rel/atomvm_packbeam/bin/packbeam"}
]}.
10 changes: 8 additions & 2 deletions release/packbeam.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -e
#
# This file is part of AtomVM.
#
Expand All @@ -19,4 +19,10 @@
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
#

exec PACKBEAM_INSTALL_LOCATION/bin/packbeam "$@"
root_dir="$(cd $(dirname $0)/.. && pwd)"
pkg_root="${root_dir}/atomvm_packbeam"

PATH="${pkg_root}/erts-{{ release_erts_version }}/bin:${PATH}"
export PATH

exec ${pkg_root}/bin/packbeam "$@"
11 changes: 2 additions & 9 deletions src/packbeam.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@
%% escript
-export([main/1]).

%%
%% MAINTENANCE NOTE. Due to an issue loading our atomvm_packbeam
%% application from an escript in a release, we need to fall back to
%% a hard-wired version string.
%%
-define(CURRENT_VERSION, "0.7.0").

%%
%% Public API
%%
Expand Down Expand Up @@ -177,10 +170,10 @@ get_version() ->
{_, _, Version} ->
Version;
false ->
?CURRENT_VERSION
"Error! Unable to find atomvm_packbeam in loaded applications"
end;
{error, _Reason} ->
?CURRENT_VERSION
"Error! Unable to load atomvm_packbeam application"
end.

%% @private
Expand Down

0 comments on commit 6fac765

Please sign in to comment.