summaryrefslogtreecommitdiff
path: root/src/rebar_packages.erl
diff options
context:
space:
mode:
authorKuba Odias <kuba.odias@relayr.io>2019-02-01 10:13:03 +0100
committerKuba Odias <kuba.odias@relayr.io>2019-06-08 06:15:42 +0200
commitc8f7d2af537bfb8ddd95c93781c293d93a0fb02b (patch)
tree4af2a0f9b941f3ebf92a50081fe11ce010a930b8 /src/rebar_packages.erl
parent1328a9a2049bfd511554f21e608444c784b4e6d3 (diff)
Warn when there's mismatch between rebar.lock & original package checksum
Diffstat (limited to 'src/rebar_packages.erl')
-rw-r--r--src/rebar_packages.erl20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl
index c7bbfac..c56a362 100644
--- a/src/rebar_packages.erl
+++ b/src/rebar_packages.erl
@@ -74,13 +74,23 @@ get_package(Dep, Vsn, undefined, Repos, Table, State) ->
get_package(Dep, Vsn, '_', Repos, Table, State);
get_package(Dep, Vsn, Hash, Repos, Table, State) ->
?MODULE:verify_table(State),
- case ets:select(Table, [{#package{key={Dep, ec_semver:parse(Vsn), Repo},
- checksum=Hash,
- _='_'}, [], ['$_']} || Repo <- Repos]) of
+ MatchingPackages = ets:select(Table, [{#package{key={Dep, ec_semver:parse(Vsn), Repo},
+ _='_'}, [], ['$_']} || Repo <- Repos]),
+ PackagesWithProperHash = lists:filter(
+ fun(#package{key = {_Dep, _Vsn, Repo}, checksum = PkgChecksum}) ->
+ if (PkgChecksum =/= Hash) andalso (Hash =/= '_') ->
+ ?WARN("Checksum mismatch for package ~ts-~ts from repo ~ts", [Dep, Vsn, Repo]),
+ false;
+ true ->
+ true
+ end
+ end, MatchingPackages
+ ),
+ case PackagesWithProperHash of
%% have to allow multiple matches in the list for cases that Repo is `_`
[Package | _] ->
{ok, Package};
- _ ->
+ [] ->
not_found
end.
@@ -249,7 +259,7 @@ update_package(Name, RepoConfig=#{name := Repo}, State) ->
Error ->
?DEBUG("Hex get_package request failed: ~p", [Error]),
%% TODO: add better log message. r3_hex_core should export a format_error
- ?WARN("Failed to update package from repo ~ts", [Repo]),
+ ?WARN("Failed to update package ~ts from repo ~ts", [Name, Repo]),
fail
catch
_:Exception ->