uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
139
pkgs/development/tools/build-managers/rebar3/default.nix
Normal file
139
pkgs/development/tools/build-managers/rebar3/default.nix
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
{ lib, stdenv, fetchFromGitHub, fetchgit,
|
||||
fetchHex, erlang, makeWrapper,
|
||||
writeScript, common-updater-scripts, coreutils, git, gnused, nix, rebar3-nix }:
|
||||
|
||||
let
|
||||
version = "3.18.0";
|
||||
owner = "erlang";
|
||||
deps = import ./rebar-deps.nix { inherit fetchFromGitHub fetchgit fetchHex; };
|
||||
rebar3 = stdenv.mkDerivation rec {
|
||||
pname = "rebar3";
|
||||
inherit version erlang;
|
||||
|
||||
# How to obtain `sha256`:
|
||||
# nix-prefetch-url --unpack https://github.com/erlang/rebar3/archive/${version}.tar.gz
|
||||
src = fetchFromGitHub {
|
||||
inherit owner;
|
||||
repo = pname;
|
||||
rev = version;
|
||||
sha256 = "09648hzc2mnjwf9klm20cg4hb5rn2xv2gmzcg98ffv37p5yfl327";
|
||||
};
|
||||
|
||||
buildInputs = [ erlang ];
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p _checkouts _build/default/lib/
|
||||
|
||||
${toString (lib.mapAttrsToList (k: v: ''
|
||||
cp -R --no-preserve=mode ${v} _checkouts/${k}
|
||||
'') deps)}
|
||||
|
||||
# Bootstrap script expects the dependencies in _build/default/lib
|
||||
# TODO: Make it accept checkouts?
|
||||
for i in _checkouts/* ; do
|
||||
ln -s $(pwd)/$i $(pwd)/_build/default/lib/
|
||||
done
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
HOME=. escript bootstrap
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
HOME=. escript ./rebar3 ct
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp rebar3 $out/bin/rebar3
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = "https://github.com/rebar/rebar3";
|
||||
description = "Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases";
|
||||
|
||||
longDescription = ''
|
||||
rebar is a self-contained Erlang script, so it's easy to distribute or
|
||||
even embed directly in a project. Where possible, rebar uses standard
|
||||
Erlang/OTP conventions for project structures, thus minimizing the amount
|
||||
of build configuration work. rebar also provides dependency management,
|
||||
enabling application writers to easily re-use common libraries from a
|
||||
variety of locations (hex.pm, git, hg, and so on).
|
||||
'';
|
||||
|
||||
platforms = lib.platforms.unix;
|
||||
maintainers = lib.teams.beam.members;
|
||||
license = lib.licenses.asl20;
|
||||
};
|
||||
|
||||
passthru.updateScript = writeScript "update.sh" ''
|
||||
#!${stdenv.shell}
|
||||
set -ox errexit
|
||||
PATH=${
|
||||
lib.makeBinPath [
|
||||
common-updater-scripts
|
||||
coreutils
|
||||
git
|
||||
gnused
|
||||
nix
|
||||
(rebar3WithPlugins { globalPlugins = [rebar3-nix]; })
|
||||
]
|
||||
}
|
||||
latest=$(list-git-tags | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
|
||||
if [ "$latest" != "${version}" ]; then
|
||||
nixpkgs="$(git rev-parse --show-toplevel)"
|
||||
nix_path="$nixpkgs/pkgs/development/tools/build-managers/rebar3"
|
||||
update-source-version rebar3 "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
|
||||
tmpdir=$(mktemp -d)
|
||||
cp -R $(nix-build $nixpkgs --no-out-link -A rebar3.src)/* "$tmpdir"
|
||||
(cd "$tmpdir" && rebar3 as test nix lock -o "$nix_path/rebar-deps.nix")
|
||||
else
|
||||
echo "rebar3 is already up-to-date"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
rebar3WithPlugins = { plugins ? [ ], globalPlugins ? [ ] }:
|
||||
let
|
||||
pluginLibDirs = map (p: "${p}/lib/erlang/lib") (lib.unique (plugins ++ globalPlugins));
|
||||
globalPluginNames = lib.unique (map (p: p.packageName) globalPlugins);
|
||||
rebar3Patched = (rebar3.overrideAttrs (old: {
|
||||
|
||||
# skip-plugins.patch is necessary because otherwise rebar3 will always
|
||||
# try to fetch plugins if they are not already present in _build.
|
||||
#
|
||||
# global-deps.patch makes it possible to use REBAR_GLOBAL_PLUGINS to
|
||||
# instruct rebar3 to always load a certain plugin. It is necessary since
|
||||
# REBAR_GLOBAL_CONFIG_DIR doesn't seem to work for this.
|
||||
patches = [ ./skip-plugins.patch ./global-plugins.patch ];
|
||||
|
||||
# our patches cause the tests to fail
|
||||
doCheck = false;
|
||||
}));
|
||||
in stdenv.mkDerivation {
|
||||
pname = "rebar3-with-plugins";
|
||||
inherit (rebar3) version;
|
||||
nativeBuildInputs = [ erlang makeWrapper ];
|
||||
unpackPhase = "true";
|
||||
|
||||
# Here we extract the rebar3 escript (like `rebar3_prv_local_install.erl`) and
|
||||
# add plugins to the code path.
|
||||
|
||||
installPhase = ''
|
||||
erl -noshell -eval '
|
||||
{ok, Escript} = escript:extract("${rebar3Patched}/bin/rebar3", []),
|
||||
{archive, Archive} = lists:keyfind(archive, 1, Escript),
|
||||
{ok, _} = zip:extract(Archive, [{cwd, "'$out/lib'"}]),
|
||||
init:stop(0)
|
||||
'
|
||||
cp ${./rebar_ignore_deps.erl} rebar_ignore_deps.erl
|
||||
erlc -o $out/lib/rebar/ebin rebar_ignore_deps.erl
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${erlang}/bin/erl $out/bin/rebar3 \
|
||||
--set REBAR_GLOBAL_PLUGINS "${toString globalPluginNames} rebar_ignore_deps" \
|
||||
--suffix-each ERL_LIBS ":" "$out/lib ${toString pluginLibDirs}" \
|
||||
--add-flags "+sbtu +A1 -noshell -boot start_clean -s rebar3 main -extra"
|
||||
'';
|
||||
};
|
||||
in { inherit rebar3 rebar3WithPlugins; }
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
|
||||
index f2d22233..bee2cf18 100644
|
||||
--- a/src/rebar_plugins.erl
|
||||
+++ b/src/rebar_plugins.erl
|
||||
@@ -30,7 +30,8 @@ project_plugins_install(State) ->
|
||||
top_level_install(State) ->
|
||||
Profiles = rebar_state:current_profiles(State),
|
||||
lists:foldl(fun(Profile, StateAcc) ->
|
||||
- Plugins = rebar_state:get(State, {plugins, Profile}, []),
|
||||
+ Plugins = rebar_state:get(State, {plugins, Profile}, [])
|
||||
+ ++ [list_to_atom(P) || P <- string:lexemes(os:getenv("REBAR_GLOBAL_PLUGINS", ""), " ")],
|
||||
handle_plugins(Profile, Plugins, StateAcc)
|
||||
end, State, Profiles).
|
||||
|
||||
118
pkgs/development/tools/build-managers/rebar3/rebar-deps.nix
Normal file
118
pkgs/development/tools/build-managers/rebar3/rebar-deps.nix
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# Generated by rebar3_nix
|
||||
let fetchOnly = { src, ... }: src;
|
||||
in { builder ? fetchOnly, fetchHex, fetchgit, fetchFromGitHub, overrides ? (x: y: { }) }:
|
||||
let
|
||||
self = packages // (overrides self packages);
|
||||
packages = with self; {
|
||||
ssl_verify_fun = builder {
|
||||
name = "ssl_verify_fun";
|
||||
version = "1.1.6";
|
||||
src = fetchHex {
|
||||
pkg = "ssl_verify_fun";
|
||||
version = "1.1.6";
|
||||
sha256 = "sha256-vbDSRx9FPIj/OQjnaG+G+b4yfQZcwewW+kVAGX6gRoA=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
relx = builder {
|
||||
name = "relx";
|
||||
version = "4.6.0";
|
||||
src = fetchHex {
|
||||
pkg = "relx";
|
||||
version = "4.6.0";
|
||||
sha256 = "sha256-L/gTHGMJPGIcazfcUtGyhIqTiIZYS0twHTW9vkN39Qk=";
|
||||
};
|
||||
beamDeps = [ bbmustache ];
|
||||
};
|
||||
providers = builder {
|
||||
name = "providers";
|
||||
version = "1.9.0";
|
||||
src = fetchHex {
|
||||
pkg = "providers";
|
||||
version = "1.9.0";
|
||||
sha256 = "sha256-0ofodEBqFQVghkKwo9tbaNato/KrABrsh+f018efwBc=";
|
||||
};
|
||||
beamDeps = [ erlware_commons getopt ];
|
||||
};
|
||||
getopt = builder {
|
||||
name = "getopt";
|
||||
version = "1.0.1";
|
||||
src = fetchHex {
|
||||
pkg = "getopt";
|
||||
version = "1.0.1";
|
||||
sha256 = "sha256-U+Grg7nOtlyWctPno1uAkum9ybPugHIUcaFhwQxZlZw=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
eunit_formatters = builder {
|
||||
name = "eunit_formatters";
|
||||
version = "0.5.0";
|
||||
src = fetchHex {
|
||||
pkg = "eunit_formatters";
|
||||
version = "0.5.0";
|
||||
sha256 = "sha256-1si6ITQklE5uBbvAl8MgAc3Qq+OSXQJFTyKbINaHY8k=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
erlware_commons = builder {
|
||||
name = "erlware_commons";
|
||||
version = "1.5.0";
|
||||
src = fetchHex {
|
||||
pkg = "erlware_commons";
|
||||
version = "1.5.0";
|
||||
sha256 = "sha256-PnxvsrpMKbDdXf6dAxtmRJ4giOzsGoFGW9n94F7X0Ns=";
|
||||
};
|
||||
beamDeps = [ cf ];
|
||||
};
|
||||
cth_readable = builder {
|
||||
name = "cth_readable";
|
||||
version = "1.5.1";
|
||||
src = fetchHex {
|
||||
pkg = "cth_readable";
|
||||
version = "1.5.1";
|
||||
sha256 = "sha256-aGVBoi7+bKWkGgR7OVFsLdKPs8reXySi8ZFFs5Z/nYA=";
|
||||
};
|
||||
beamDeps = [ cf ];
|
||||
};
|
||||
cf = builder {
|
||||
name = "cf";
|
||||
version = "0.3.1";
|
||||
src = fetchHex {
|
||||
pkg = "cf";
|
||||
version = "0.3.1";
|
||||
sha256 = "sha256-MV6NRH06SwK82/o5etA7u5iKbgqm9E063Q9OPDv5dnI=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
certifi = builder {
|
||||
name = "certifi";
|
||||
version = "2.8.0";
|
||||
src = fetchHex {
|
||||
pkg = "certifi";
|
||||
version = "2.8.0";
|
||||
sha256 = "sha256-asfvwcb4YAsI1iUpLUu/WE4UhHzhtrXETZg9Jz4Ql+o=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
bbmustache = builder {
|
||||
name = "bbmustache";
|
||||
version = "1.12.2";
|
||||
src = fetchHex {
|
||||
pkg = "bbmustache";
|
||||
version = "1.12.2";
|
||||
sha256 = "sha256-aIszpNXMLVH1da3ws2g/xAo4MUovFQkG7c/Hf1tXezs=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
meck = builder {
|
||||
name = "meck";
|
||||
version = "0.8.13";
|
||||
src = fetchHex {
|
||||
pkg = "meck";
|
||||
version = "0.8.13";
|
||||
sha256 = "sha256-008BPBVttRrVfMVWiRuXIOahwd9f4uFa+ZnITWzr6xo=";
|
||||
};
|
||||
beamDeps = [ ];
|
||||
};
|
||||
};
|
||||
in self
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
%% This module, when loaded as a plugin, overrides the default `install_deps`
|
||||
%% provider and erases the dependencies from the rebar3 state, when
|
||||
%% REBAR_IGNORE_DEPS is true.
|
||||
|
||||
-module(rebar_ignore_deps).
|
||||
|
||||
-export([init/1, do/1, format_error/1]).
|
||||
|
||||
init(State0) ->
|
||||
case os:getenv("REBAR_IGNORE_DEPS", "") of
|
||||
"" ->
|
||||
{ok, State0};
|
||||
_ ->
|
||||
do_init(State0)
|
||||
end.
|
||||
|
||||
do_init(State0) ->
|
||||
State1 = rebar_state:allow_provider_overrides(State0, true),
|
||||
Provider = providers:create(
|
||||
[
|
||||
{name, install_deps}, %% override the default install_deps provider
|
||||
{module, ?MODULE},
|
||||
{bare, false},
|
||||
{deps, [app_discovery]},
|
||||
{example, undefined},
|
||||
{opts, []},
|
||||
{short_desc, ""},
|
||||
{desc, ""}
|
||||
]),
|
||||
State2 = rebar_state:add_provider(State1, Provider),
|
||||
{ok, rebar_state:allow_provider_overrides(State2, false)}.
|
||||
|
||||
do(State0) ->
|
||||
io:format("Ignoring deps...~n"),
|
||||
Profiles = rebar_state:current_profiles(State0),
|
||||
State = lists:foldl(fun(P, Acc0) ->
|
||||
Acc = rebar_state:set(Acc0, {deps, P}, []),
|
||||
rebar_state:set(Acc, {parsed_deps, P}, [])
|
||||
end, State0, Profiles),
|
||||
{ok, State}.
|
||||
|
||||
format_error(Reason) ->
|
||||
io_lib:format("~p", [Reason]).
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
|
||||
index f2d22233..c61fa553 100644
|
||||
--- a/src/rebar_plugins.erl
|
||||
+++ b/src/rebar_plugins.erl
|
||||
@@ -106,31 +106,9 @@ handle_plugins(Profile, Plugins, State, Upgrade) ->
|
||||
State3 = rebar_state:set(State2, deps_dir, DepsDir),
|
||||
rebar_state:lock(State3, Locks).
|
||||
|
||||
-handle_plugin(Profile, Plugin, State, Upgrade) ->
|
||||
+handle_plugin(_Profile, Plugin, State, _Upgrade) ->
|
||||
try
|
||||
- {Apps, State2} = rebar_prv_install_deps:handle_deps_as_profile(Profile, State, [Plugin], Upgrade),
|
||||
- {no_cycle, Sorted} = rebar_prv_install_deps:find_cycles(Apps),
|
||||
- ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []),
|
||||
-
|
||||
- %% Add already built plugin deps to the code path
|
||||
- ToBuildPaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
|
||||
- PreBuiltPaths = [Ebin || A <- Apps,
|
||||
- Ebin <- [rebar_app_info:ebin_dir(A)],
|
||||
- not lists:member(Ebin, ToBuildPaths)],
|
||||
- code:add_pathsa(PreBuiltPaths),
|
||||
-
|
||||
- %% Build plugin and its deps
|
||||
- build_plugins(ToBuild, Apps, State2),
|
||||
-
|
||||
- %% Add newly built deps and plugin to code path
|
||||
- State3 = rebar_state:update_all_plugin_deps(State2, Apps),
|
||||
- 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}
|
||||
+ {plugin_providers(Plugin), State}
|
||||
catch
|
||||
?WITH_STACKTRACE(C,T,S)
|
||||
?DEBUG("~p ~p ~p", [C, T, S]),
|
||||
@@ -138,15 +116,6 @@ handle_plugin(Profile, Plugin, State, Upgrade) ->
|
||||
{[], State}
|
||||
end.
|
||||
|
||||
-build_plugins(MustBuildApps, AllApps, State) ->
|
||||
- State1 = rebar_state:deps_to_build(State, MustBuildApps),
|
||||
- State2 = rebar_state:all_deps(State1, AllApps),
|
||||
- State3 = rebar_state:set(State2, deps_dir, ?DEFAULT_PLUGINS_DIR),
|
||||
- {Args, Extra} = rebar_state:command_parsed_args(State),
|
||||
- State4 = rebar_state:command_parsed_args(State3, {[{deps_only, true}|Args], Extra}),
|
||||
- rebar_prv_compile:do(State4),
|
||||
- ok.
|
||||
-
|
||||
plugin_providers({Plugin, _, _, _}) when is_atom(Plugin) ->
|
||||
validate_plugin(Plugin);
|
||||
plugin_providers({Plugin, _, _}) when is_atom(Plugin) ->
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
diff --git a/test/rebar_file_utils_SUITE.erl b/test/rebar_file_utils_SUITE.erl
|
||||
index d771a82..05cfbf7 100644
|
||||
--- a/test/rebar_file_utils_SUITE.erl
|
||||
+++ b/test/rebar_file_utils_SUITE.erl
|
||||
@@ -34,13 +34,11 @@
|
||||
|
||||
all() ->
|
||||
[{group, tmpdir},
|
||||
- {group, reset_dir},
|
||||
{group, mv},
|
||||
path_from_ancestor,
|
||||
canonical_path,
|
||||
absolute_path,
|
||||
normalized_path,
|
||||
- resolve_link,
|
||||
split_dirname,
|
||||
mv_warning_is_ignored].
|
||||
Loading…
Add table
Add a link
Reference in a new issue