Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the installation #9

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
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

fadushin marked this conversation as resolved.
Show resolved Hide resolved
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
Loading