[packages/erlang-rebar3] Up to 3.27.0; seems to be working
arekm
arekm at pld-linux.org
Thu Mar 12 16:18:22 CET 2026
commit 78679e23ba5dfaf1f7338718110032068882e1f0
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Mar 12 16:18:12 2026 +0100
Up to 3.27.0; seems to be working
erlang-rebar3.spec | 35 +++++-----
relx-template-shebangs.patch | 18 +++++
system-plugin-detection.patch | 153 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 188 insertions(+), 18 deletions(-)
---
diff --git a/erlang-rebar3.spec b/erlang-rebar3.spec
index 859a417..a0c1915 100644
--- a/erlang-rebar3.spec
+++ b/erlang-rebar3.spec
@@ -4,13 +4,17 @@
Summary: Erlang Build Tools
Name: erlang-rebar3
-Version: 3.25.0
-Release: 0.1
+Version: 3.27.0
+Release: 1
License: MIT
Group: Development/Tools
-Source0: https://github.com/erlang/rebar3/tarball/%{version}/rebar3-%{version}.tar.bz2
-# Source0-md5: c4a5482c66a7a5503048ae3b3b6e6ec4
+Source0: https://github.com/erlang/rebar3/archive/refs/tags/%{version}.tar.gz#/rebar3-%{version}.tar.gz
+# Source0-md5: d54596ed2202723169e5bca614fd44f9
Source1: rebar3.escript
+# Use the system escript path in installed relx templates.
+Patch0: relx-template-shebangs.patch
+# Allow packaged Erlang apps to satisfy declared rebar3 plugins.
+Patch1: system-plugin-detection.patch
URL: https://github.com/erlang/rebar3
BuildRequires: erlang >= 2:17
%if %{without bootstrap}
@@ -27,25 +31,20 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
Erlang Build Tools.
%prep
-%setup -qc
-mv erlang-rebar3-*/* .
-%{__rm} -r erlang-rebar3-*
-
-%{__sed} -i -e '1s,/usr/bin/env escript,/usr/bin/escript,' \
- vendor/relx/priv/templates/install_upgrade_escript \
- vendor/relx/priv/templates/nodetool
+%setup -q -n rebar3-%{version}
+%patch 0 -p1
+%patch 1 -p1
%build
ebin_paths=$(perl -e 'print join(":", grep { !/rebar/} (glob("%{_libdir}/erlang/lib/*/ebin"), glob("%{_datadir}/erlang/lib/*/ebin")))')
+export REBAR_OFFLINE=1
%if %{with bootstrap}
-#DIAGNOSTIC=1 \
+DIAGNOSTIC=1 \
./bootstrap bare compile --paths $ebin_paths --separator :
%else
-rm -rf vendor
-#DIAGNOSTIC=1 \
-rebar3 bare compile --paths $ebin_paths --separator :
-install %{SOURCE1} ./rebar3
+DIAGNOSTIC=1 \
+rebar3 as prod escriptize
%endif
%if %{with tests}
@@ -58,9 +57,9 @@ install -d $RPM_BUILD_ROOT%{_bindir} \
$RPM_BUILD_ROOT%{_libdir}/erlang/lib/rebar3-%{version}/ebin
%if %{with bootstrap}
- ldir=bootstrap
+ldir=bootstrap
%else
- ldir=prod
+ldir=prod
%endif
cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/rebar3
diff --git a/relx-template-shebangs.patch b/relx-template-shebangs.patch
new file mode 100644
index 0000000..76da49f
--- /dev/null
+++ b/relx-template-shebangs.patch
@@ -0,0 +1,18 @@
+diff -urN a/vendor/relx/priv/templates/install_upgrade_escript b/vendor/relx/priv/templates/install_upgrade_escript
+--- a/vendor/relx/priv/templates/install_upgrade_escript 2026-02-27 18:45:48.000000000 +0100
++++ b/vendor/relx/priv/templates/install_upgrade_escript 2026-03-12 01:00:00.000000000 +0100
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env escript
++#!/usr/bin/escript
+ %%! -noinput
+ %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+ %% ex: ft=erlang ts=4 sw=4 et
+diff -urN a/vendor/relx/priv/templates/nodetool b/vendor/relx/priv/templates/nodetool
+--- a/vendor/relx/priv/templates/nodetool 2026-02-27 18:45:48.000000000 +0100
++++ b/vendor/relx/priv/templates/nodetool 2026-03-12 01:00:00.000000000 +0100
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env escript
++#!/usr/bin/escript
+ %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+ %% ex: ft=erlang ts=4 sw=4 et
+ %% -------------------------------------------------------------------
diff --git a/system-plugin-detection.patch b/system-plugin-detection.patch
new file mode 100644
index 0000000..f0e52a9
--- /dev/null
+++ b/system-plugin-detection.patch
@@ -0,0 +1,153 @@
+--- a/apps/rebar/src/rebar_plugins.erl
++++ b/apps/rebar/src/rebar_plugins.erl
+@@ -13,6 +13,16 @@
+
+ -include("rebar.hrl").
+
++%% Distro note: upstream expects declared plugins to come from project-local
++%% plugin dirs, the plugin cache, or global rebar3 configuration. Our
++%% packaging model also ships reusable plugins as ordinary Erlang RPMs under
++%% the system OTP library directory. The extra logic added below allows a
++%% declared plugin to be satisfied by such an installed OTP application. When
++%% found, rebar3 registers that app as a plugin dependency, adds its ebin dir
++%% to the normal plugin path handling, and skips the usual plugin fetch/build
++%% flow. This keeps offline RPM builds reproducible while still allowing
++%% packages such as ejabberd to use BuildRequires on erlang-rebar3-* plugins.
++
+ %% ===================================================================
+ %% Public API
+ %% ===================================================================
+@@ -78,7 +88,8 @@
+ filter_existing_plugins(Plugins, State) ->
+ PluginNames = lists:zip(Plugins, rebar_state:deps_names(Plugins)),
+ AllPlugins = rebar_state:all_plugin_deps(State),
+- rebar_utils:filtermap(fun({Plugin, PluginName}) ->
++ rebar_utils:filtermap(fun({Plugin, PluginName0}) ->
++ PluginName = rebar_utils:to_binary(PluginName0),
+ case rebar_app_utils:find(PluginName, AllPlugins) of
+ {ok, _} ->
+ false;
+@@ -109,47 +120,84 @@
+ rebar_state:lock(State3, Locks).
+
+ handle_plugin(Profile, Plugin, State, SrcPlugins, Upgrade) ->
+- try
+- %% Inject top-level src plugins as project apps, so that they get skipped
+- %% by the installation as already seen
+- ProjectApps = rebar_state:project_apps(State),
+- State0 = rebar_state:project_apps(State, SrcPlugins),
+- %% We however have to pick the deps of top-level apps and promote them
+- %% directly to make sure they are installed if they were not also at the top level
+- TopDeps = top_level_deps(State, SrcPlugins),
+- %% Install the plugins
+- {Apps, State1} = rebar_prv_install_deps:handle_deps_as_profile(Profile, State0, [Plugin|TopDeps], Upgrade),
+- {no_cycle, Sorted} = rebar_prv_install_deps:find_cycles(SrcPlugins++Apps),
+- ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []),
+- %% Return things to normal
+- State2 = rebar_state:project_apps(State1, ProjectApps),
+-
+- %% Add already built plugin deps to the code path
+- ToBuildPaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
+- PreBuiltPaths = [Ebin || A <- Sorted,
+- Ebin <- [rebar_app_info:ebin_dir(A)],
+- not lists:member(Ebin, ToBuildPaths)],
+- code:add_pathsa(PreBuiltPaths),
+-
+- %% Build plugin and its deps
+- build_plugins(ToBuild, Sorted, State2),
+-
+- %% Add newly built deps and plugin to code path
+- State3 = rebar_state:update_all_plugin_deps(State2, Sorted),
+- NewCodePaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
+-
+- %% Store plugin code paths so we can remove them when compiling project apps
+- State4 = rebar_state:update_code_paths(State3, all_plugin_deps, PreBuiltPaths++NewCodePaths),
+- rebar_paths:set_paths([plugins], State4),
+-
+- {plugin_providers(Plugin), State4}
+- catch
+- ?WITH_STACKTRACE(C,T,S)
+- ?DEBUG("~p ~p ~p", [C, T, S]),
+- ?WARN("Errors loading plugin ~p. Run rebar3 with DEBUG=1 set to see errors.", [Plugin]),
+- {[], State}
++ case installed_plugin(Plugin, State) of
++ {true, AppInfo} ->
++ State1 = update_installed_plugin(AppInfo, State),
++ {plugin_providers(Plugin), State1};
++ false ->
++ try
++ %% Inject top-level src plugins as project apps, so that they get skipped
++ %% by the installation as already seen
++ ProjectApps = rebar_state:project_apps(State),
++ State0 = rebar_state:project_apps(State, SrcPlugins),
++ %% We however have to pick the deps of top-level apps and promote them
++ %% directly to make sure they are installed if they were not also at the top level
++ TopDeps = top_level_deps(State, SrcPlugins),
++ %% Install the plugins
++ {Apps, State1} = rebar_prv_install_deps:handle_deps_as_profile(Profile, State0, [Plugin|TopDeps], Upgrade),
++ {no_cycle, Sorted} = rebar_prv_install_deps:find_cycles(SrcPlugins++Apps),
++ ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []),
++ %% Return things to normal
++ State2 = rebar_state:project_apps(State1, ProjectApps),
++
++ %% Add already built plugin deps to the code path
++ ToBuildPaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
++ PreBuiltPaths = [Ebin || A <- Sorted,
++ Ebin <- [rebar_app_info:ebin_dir(A)],
++ not lists:member(Ebin, ToBuildPaths)],
++ code:add_pathsa(PreBuiltPaths),
++
++ %% Build plugin and its deps
++ build_plugins(ToBuild, Sorted, State2),
++
++ %% Add newly built deps and plugin to code path
++ State3 = rebar_state:update_all_plugin_deps(State2, Sorted),
++ NewCodePaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
++
++ %% Store plugin code paths so we can remove them when compiling project apps
++ State4 = rebar_state:update_code_paths(State3, all_plugin_deps, PreBuiltPaths++NewCodePaths),
++ rebar_paths:set_paths([plugins], State4),
++
++ {plugin_providers(Plugin), State4}
++ catch
++ ?WITH_STACKTRACE(C,T,S)
++ ?DEBUG("~p ~p ~p", [C, T, S]),
++ ?WARN("Errors loading plugin ~p. Run rebar3 with DEBUG=1 set to see errors.", [Plugin]),
++ {[], State}
++ end
++ end.
++
++installed_plugin(Plugin, State) ->
++ %% code:lib_dir/1 gives us the installed OTP app location. Reuse
++ %% rebar3's normal app discovery so the resulting app_info matches
++ %% what plugin loading expects later on.
++ PluginName = plugin_name(Plugin),
++ case code:lib_dir(PluginName) of
++ {error, bad_name} -> false;
++ Dir -> rebar_app_discover:find_app(Dir, all, State)
+ end.
+
++update_installed_plugin(AppInfo, State) ->
++ %% Mark the packaged app as a plugin dependency and expose its ebin
++ %% directory through the normal plugin path handling. This keeps the
++ %% rest of rebar3 working with the same provider-loading path it uses
++ %% for fetched plugins.
++ Ebin = rebar_app_info:ebin_dir(AppInfo),
++ code:add_patha(Ebin),
++ State1 = rebar_state:update_all_plugin_deps(State, [AppInfo]),
++ State2 = rebar_state:update_code_paths(State1, all_plugin_deps, [Ebin]),
++ rebar_paths:set_paths([plugins], State2),
++ State2.
++
++plugin_name({Plugin, _, _, _}) when is_atom(Plugin) ->
++ Plugin;
++plugin_name({Plugin, _, _}) when is_atom(Plugin) ->
++ Plugin;
++plugin_name({Plugin, _}) when is_atom(Plugin) ->
++ Plugin;
++plugin_name(Plugin) when is_atom(Plugin) ->
++ Plugin.
++
+ build_plugins(MustBuildApps, AllApps, State) ->
+ State1 = rebar_state:deps_to_build(State, MustBuildApps),
+ State2 = rebar_state:all_deps(State1, AllApps),
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/erlang-rebar3.git/commitdiff/78679e23ba5dfaf1f7338718110032068882e1f0
More information about the pld-cvs-commit
mailing list