[erlang-oauth] Ver. 1.4.0

Peter Lemenkov peter at fedoraproject.org
Fri Jan 10 12:56:11 UTC 2014


commit 8f486f4afad910f44d9a556f72777d4e35ecd1ae
Author: Peter Lemenkov <lemenkov at gmail.com>
Date:   Fri Jan 10 16:56:03 2014 +0400

    Ver. 1.4.0
    
    - Ver. 1.4.0 (API incompatible update)
    - Removed compatibility with Fedora < 12, RHEL < 6
    
    Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>

 .gitignore                                         |    1 +
 ...time-switching-with-parse_transform-rewri.patch |   92 ++++++++++++++++++++
 ...-0001-add-support-of-erlang-R15B-in-oauth.patch |   25 ------
 erlang-oauth.spec                                  |   40 +++------
 sources                                            |    2 +-
 5 files changed, 107 insertions(+), 53 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index cf1191c..6a70dd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ erlang-oauth-0.gite8aecf0.tar.bz2
 /tim-erlang-oauth-7d85d3e.tar.gz
 /tim-erlang-oauth-v1.0.1-0-g2c9269b.tar.gz
 /tim-erlang-oauth-v1.1.1-0-g18cee77.tar.gz
+/erlang-oauth-1.4.0.tar.gz
diff --git a/erlang-oauth-0001-Replace-runtime-switching-with-parse_transform-rewri.patch b/erlang-oauth-0001-Replace-runtime-switching-with-parse_transform-rewri.patch
new file mode 100644
index 0000000..85b0135
--- /dev/null
+++ b/erlang-oauth-0001-Replace-runtime-switching-with-parse_transform-rewri.patch
@@ -0,0 +1,92 @@
+From: Tim Fletcher <mail at tfletcher.com>
+Date: Wed, 18 Sep 2013 17:57:06 +0100
+Subject: [PATCH] Replace runtime switching with parse_transform rewriting of
+ crypto:hmac/3
+
+
+diff --git a/Emakefile b/Emakefile
+index a961122..9665af7 100644
+--- a/Emakefile
++++ b/Emakefile
+@@ -1 +1,3 @@
+-{"src/*", [debug_info, warn_unused_vars, warn_unused_import, {outdir, "ebin"}]}.
+\ No newline at end of file
++{"src/crypto_sha_mac.erl", []}.
++
++{"src/oauth.erl", [debug_info, warn_unused_vars, warn_unused_import, {outdir, "ebin"}, {parse_transform, crypto_sha_mac}]}.
+diff --git a/Makefile b/Makefile
+index e4b31b9..b9310b3 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ all: clean compile
+ 
+ clean:
+-	@rm -rf ebin/*.beam
++	@rm -rf ebin/*.beam *.beam
+ 
+ compile:
+ 	@test -d ebin || mkdir ebin
+diff --git a/src/crypto_sha_mac.erl b/src/crypto_sha_mac.erl
+new file mode 100644
+index 0000000..1eb917f
+--- /dev/null
++++ b/src/crypto_sha_mac.erl
+@@ -0,0 +1,29 @@
++-module(crypto_sha_mac).
++
++-export([parse_transform/2]).
++
++parse_transform(Forms, _Options) ->
++  application:load(crypto),
++  crypto:start(),
++  case erlang:function_exported(crypto, hmac, 3) of
++    true ->
++      Forms;
++    false ->
++      io:format("Rewriting crypto:hmac/3 calls with crypto_sha_mac parse transform~n", []),
++      lists:map(fun rewrite/1, Forms)
++  end.
++
++rewrite(Function={function, _, _, _, Clauses}) ->
++  setelement(5, Function, recursive_rewrite(Clauses));
++rewrite(Form) ->
++  Form.
++
++recursive_rewrite(Terms) when is_list(Terms) ->
++  lists:map(fun recursive_rewrite/1, Terms);
++recursive_rewrite({call, L1, {remote, L2, {atom, L3, crypto}, {atom, L4, hmac}}, [{atom, _, sha} | Args]}) ->
++  {call, L1, {remote, L2, {atom, L3, crypto}, {atom, L4, sha_mac}}, Args};
++recursive_rewrite(Term) when is_tuple(Term) ->
++  [Type, Line | Elements] = tuple_to_list(Term),
++  list_to_tuple([Type, Line | lists:map(fun recursive_rewrite/1, Elements)]);
++recursive_rewrite(Term) ->
++  Term.
+diff --git a/src/oauth.erl b/src/oauth.erl
+index d9234f4..d5de04b 100644
+--- a/src/oauth.erl
++++ b/src/oauth.erl
+@@ -128,7 +128,7 @@ hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret) ->
+ 
+ hmac_sha1_signature(BaseString, Consumer, TokenSecret) ->
+   Key = uri_join([consumer_secret(Consumer), TokenSecret]),
+-  base64:encode_to_string(hmac_sha(Key, BaseString)).
++  base64:encode_to_string(crypto:hmac(sha, Key, BaseString)).
+ 
+ hmac_sha1_verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) ->
+   verify_in_constant_time(Signature, hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret)).
+@@ -136,14 +136,6 @@ hmac_sha1_verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) ->
+ hmac_sha1_verify(Signature, BaseString, Consumer, TokenSecret) ->
+   verify_in_constant_time(Signature, hmac_sha1_signature(BaseString, Consumer, TokenSecret)).
+ 
+-hmac_sha(Key, Data) ->
+-  case erlang:function_exported(crypto, hmac, 3) of
+-    true ->
+-      crypto:hmac(sha, Key, Data);
+-    false ->
+-      crypto:sha_mac(Key, Data)
+-  end.
+-
+ rsa_sha1_signature(HttpMethod, URL, Params, Consumer) ->
+   BaseString = signature_base_string(HttpMethod, URL, Params),
+   rsa_sha1_signature(BaseString, Consumer).
diff --git a/erlang-oauth.spec b/erlang-oauth.spec
index 3c80a2b..23ff82e 100644
--- a/erlang-oauth.spec
+++ b/erlang-oauth.spec
@@ -1,21 +1,16 @@
 %global realname oauth
-%global upstream tim
 %global debug_package %{nil}
-%global git_tag 18cee77
-%global patchnumber 0
 
 
 Name:		erlang-%{realname}
-Version:	1.1.1
-Release:	4%{?dist}
+Version:	1.4.0
+Release:	1%{?dist}
 Summary:	An Erlang OAuth implementation
 Group:		Development/Languages
 License:	MIT
-URL:		http://github.com/tim/erlang-oauth
-# wget --no-check-certificate --content-disposition https://github.com/tim/erlang-oauth/tarball/v1.1.1
-Source0:	%{upstream}-erlang-%{realname}-v%{version}-%{patchnumber}-g%{git_tag}.tar.gz
-Patch1:		erlang-oauth-0001-add-support-of-erlang-R15B-in-oauth.patch
-BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+URL:		https://github.com/tim/erlang-oauth
+Source0:	https://github.com/tim/erlang-oauth/archive/v%{version}/%{name}-%{version}.tar.gz
+Patch1:		erlang-oauth-0001-Replace-runtime-switching-with-parse_transform-rewri.patch
 BuildRequires:	erlang-erts
 BuildRequires:	erlang-public_key
 BuildRequires:	erlang-tools
@@ -29,7 +24,6 @@ Requires:	erlang-kernel
 # Error:erlang(public_key:verify/4) in R13B and below
 Requires:	erlang-public_key >= R14B
 Requires:	erlang-stdlib
-Requires:	erlang-xmerl
 
 
 %description
@@ -37,8 +31,8 @@ An Erlang OAuth implementation.
 
 
 %prep
-%setup -q -n %{upstream}-%{name}-%{git_tag}
-%patch1 -p1 -b .R15B
+%setup -q
+%patch1 -p1 -b .R16B01
 
 
 %build
@@ -46,31 +40,23 @@ make %{?_smp_mflags}
 
 
 %install
-rm -rf $RPM_BUILD_ROOT
 install -D -m 644 ebin/%{realname}.app $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}.app
-install -m 644 ebin/*.beam $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/
-
-
-%clean
-rm -rf $RPM_BUILD_ROOT
+install -D -m 644 ebin/%{realname}.beam $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}.beam
 
 
 %files
-%defattr(-,root,root,-)
-%doc License.txt README.txt THANKS.txt
+%doc CHANGELOG.md License.txt README.md THANKS.txt
 %dir %{_libdir}/erlang/lib/%{realname}-%{version}
 %dir %{_libdir}/erlang/lib/%{realname}-%{version}/ebin
 %{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}.app
 %{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}.beam
-%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}_client.beam
-%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}_hmac_sha1.beam
-%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}_http.beam
-%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}_plaintext.beam
-%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}_rsa_sha1.beam
-%{_libdir}/erlang/lib/%{realname}-%{version}/ebin/%{realname}_uri.beam
 
 
 %changelog
+* Fri Jan 10 2014 Peter Lemenkov <lemenkov at gmail.com> - 1.4.0-1
+- Ver. 1.4.0 (API incompatible update)
+- Removed compatibility with Fedora < 12, RHEL < 6
+
 * Sat Aug 03 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.1.1-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 
diff --git a/sources b/sources
index 9cc6e22..4c3e534 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-3f55b5ed326ab1317f2588f908235012  tim-erlang-oauth-v1.1.1-0-g18cee77.tar.gz
+ce6833322e1f02c4d0084395650a4d31  erlang-oauth-1.4.0.tar.gz


More information about the scm-commits mailing list