Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 May 2022 01:41:15 -0700
From:      "Pat Maddox" <pat@patmaddox.com>
To:        "Dave Cottlehuber" <dch@skunkwerks.at>
Cc:        erlang <freebsd-erlang@FreeBSD.org>
Subject:   Re: package mix release works, port doesn't? (and neither is self-contained)
Message-ID:  <7814C787-2101-45DC-971D-2571E29EF4F6@patmaddox.com>
In-Reply-To: <9B6718AD-FC61-4DBC-8DF1-9FF0E207B945@patmaddox.com>
References:  <42EA9771-2440-49D3-BEFA-05A888F8D90A@patmaddox.com> <A20A5B06-676E-4AF8-940A-3992194B1E80@patmaddox.com> <d2915f8a-2280-4c23-a251-645f1efd0185@www.fastmail.com> <9B6718AD-FC61-4DBC-8DF1-9FF0E207B945@patmaddox.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4 May 2022, at 23:48, Pat Maddox wrote:

> On 4 May 2022, at 7:16, Dave Cottlehuber wrote:
>
>> On Wed, 4 May 2022, at 11:16, Pat Maddox wrote:
>
>>> I still don=E2=80=99t understand why I need an erlang runtime at all =

>>> though,
>>> after the mix release has been built.
>>>
>>> Pat
>>
>> you don't; whether erts is bundled in the release is defined in your
>> mix release config. I'm assuming your ExAmple app picks up whatever
>> the default is, see the hello app for an appropriate example.

I have found the culprit.

mix release sets an ERTS_BIN env var in the startup script: =

https://github.com/elixir-lang/elixir/blob/main/lib/mix/lib/mix/tasks/rel=
ease.ex#L1428

However, the port replaces it: =

https://cgit.freebsd.org/ports/tree/lang/elixir-devel/Makefile#n48

So where mix release produces the following lines in =

ex_ample/releases/0.1.0/elixir:

ERTS_BIN=3D
ERTS_BIN=3D"$SCRIPT_PATH"/../../erts-12.3./bin/

The port changes them to:

ERTS_BIN=3D/usr/local/lib/erlang24/bin/
ERTS_BIN=3D/usr/local/lib/erlang24/bin/

Removing the post-patch target solves the problem: I can run `ex_ample =

start_iex` with no erlang or elixir installed. It uses the erts bundled =

in /usr/local/libexec/ex_ample/erts-12.3.1/.

Removing post-patch however breaks the current lang/elixir-devel build, =

because now erl is not in the path.

We have two scenarios:

1. lang/erlang-runtime24 is installed (and not lang/erlang) - this needs =

the post-patch
2. lang/erlang is installed - this does not need the post-patch, and in =

fact the post-patch breaks the bundled erts in mix releases.

How should we go about solving this? One simple idea is to call `which =

erl` to see if it exists, and if so then we can skip the post-patch.

Another idea is to add a PROVIDES_ERL variable, and make =

lang/erlang-runtime24 add erl to /usr/local/bin, and conflict with =

lang/erlang. If you want full erlang on your system, you could set =

PROVIDES_ERLANG=3Dlang/erlang.

Perhaps it=E2=80=99s even simpler. Instead of:

BUILD_DEPENDS=3D	erlang-runtime${ERLANG_VER}>0:lang/erlang-runtime${ERLAN=
G_VER}
RUN_DEPENDS=3D	erlang-runtime${ERLANG_VER}>0:lang/erlang-runtime${ERLANG_=
VER}

It could be:

DEPENDS=3D	erl:lang/erlang-runtime${ERLANG_VER}

and again lang/erlang-runtime24 would install /usr/local/bin/erl.

I am quite new to FreeBSD ports and makefiles in general though, so am =

interested in a good approach to this.

Pat



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7814C787-2101-45DC-971D-2571E29EF4F6>