[DRE-commits] [SCM] sup-mail.git branch, master, updated. debian/0.12.1-1-6-g58778e0

Per Andersson avtobiff at gmail.com
Tue May 15 01:12:27 UTC 2012


The following commit has been merged in the master branch:
commit e02f541e1160a02d3fd27f9174a0f20a27383ae0
Author: Per Andersson <avtobiff at gmail.com>
Date:   Tue May 15 03:10:59 2012 +0200

    Add patch for gpgme 2.0 support.

diff --git a/debian/patches/0002-Fix-support-for-gpgme-2.0.patch b/debian/patches/0002-Fix-support-for-gpgme-2.0.patch
new file mode 100644
index 0000000..4414fed
--- /dev/null
+++ b/debian/patches/0002-Fix-support-for-gpgme-2.0.patch
@@ -0,0 +1,216 @@
+From: Clint Byrum <clint at ubuntu.com>
+Date: Wed, 16 Nov 2011 23:33:00 -0800
+Subject: Fix support for gpgme 2.0
+
+* Add support for gpgme 2.0 and stay backward compatible with 1.0.
+* Add test suite for lib/sup/crypto.rb.
+
+Taken from http://gitorious.org/sup/mainline/merge_requests/12
+---
+ lib/sup/crypto.rb   |   39 ++++++++++++++++---
+ test/test_crypto.rb |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 140 insertions(+), 6 deletions(-)
+ create mode 100755 test/test_crypto.rb
+
+diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
+index bc96f88..24ecfc2 100644
+--- a/lib/sup/crypto.rb
++++ b/lib/sup/crypto.rb
+@@ -48,10 +48,17 @@ EOS
+     @gpgme_present =
+       begin
+         begin
+-          GPGME.check_version({:protocol => GPGME::PROTOCOL_OpenPGP})
++          begin
++            GPGME.check_version({:protocol => GPGME::PROTOCOL_OpenPGP})
++          rescue TypeError
++            GPGME.check_version(nil)
++          end
+           true
+         rescue GPGME::Error
+           false
++        rescue ArgumentError
++          # gpgme 2.0.0 raises this due to the hash->string conversion
++          false
+         end
+       rescue NameError
+         false
+@@ -65,7 +72,11 @@ EOS
+ 
+     # if gpg2 is available, it will start gpg-agent if required
+     if (bin = `which gpg2`.chomp) =~ /\S/
+-      GPGME.set_engine_info GPGME::PROTOCOL_OpenPGP, bin, nil
++      if GPGME.respond_to?('set_engine_info')
++        GPGME.set_engine_info GPGME::PROTOCOL_OpenPGP, bin, nil
++      else
++        GPGME.gpgme_set_engine_info GPGME::PROTOCOL_OpenPGP, bin, nil
++      end
+     else
+       # check if the gpg-options hook uses the passphrase_callback
+       # if it doesn't then check if gpg agent is present
+@@ -104,7 +115,13 @@ EOS
+                                {:operation => "sign", :options => gpg_opts}) || gpg_opts
+ 
+     begin
+-      sig = GPGME.detach_sign(format_payload(payload), gpg_opts)
++      if GPGME.respond_to?('detach_sign')
++        sig = GPGME.detach_sign(format_payload(payload), gpg_opts)
++      else
++        crypto = GPGME::Crypto.new
++        gpg_opts[:mode] = GPGME::SIG_MODE_DETACH
++        sig = crypto.sign(format_payload(payload), gpg_opts).read
++      end
+     rescue GPGME::Error => exc
+       raise Error, gpgme_exc_msg(exc.message)
+     end
+@@ -137,7 +154,13 @@ EOS
+     recipients = to + [from]
+ 
+     begin
+-      cipher = GPGME.encrypt(recipients, format_payload(payload), gpg_opts)
++      if GPGME.respond_to?('encrypt')
++        cipher = GPGME.encrypt(recipients, format_payload(payload), gpg_opts)
++      else
++        crypto = GPGME::Crypto.new
++        gpg_opts[:recipients] = recipients
++        cipher = crypto.encrypt(format_payload(payload), gpg_opts).read
++      end
+     rescue GPGME::Error => exc
+       raise Error, gpgme_exc_msg(exc.message)
+     end
+@@ -246,7 +269,11 @@ EOS
+                                {:operation => "decrypt", :options => gpg_opts}) || gpg_opts
+     ctx = GPGME::Ctx.new(gpg_opts)
+     cipher_data = GPGME::Data.from_str(format_payload(payload))
+-    plain_data = GPGME::Data.empty
++    if GPGME::Data.respond_to?('empty')
++      plain_data = GPGME::Data.empty
++    else
++      plain_data = GPGME::Data.empty!
++    end
+     begin
+       ctx.decrypt_verify(cipher_data, plain_data)
+     rescue GPGME::Error => exc
+@@ -314,7 +341,7 @@ private
+ 
+   def gpgme_exc_msg msg
+     err_msg = "Exception in GPGME call: #{msg}"
+-    info err_msg
++    #info err_msg
+     err_msg
+   end
+ 
+diff --git a/test/test_crypto.rb b/test/test_crypto.rb
+new file mode 100755
+index 0000000..abb4fba
+--- /dev/null
++++ b/test/test_crypto.rb
+@@ -0,0 +1,107 @@
++#!/usr/bin/ruby
++
++# tests for sup's crypto libs
++#
++# Copyright Clint Byrum <clint at ubuntu.com> 2011. All Rights Reserved.
++#
++# This program is free software; you can redistribute it and/or
++# modify it under the terms of the GNU General Public License
++# as published by the Free Software Foundation; either version 2
++# of the License, or (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++# 02110-1301, USA.
++
++require 'tmpdir'
++require 'test/unit'
++require 'rmail/message'
++require 'rmail/parser'
++require 'sup/util'
++require 'sup/hook'
++require 'sup/contact'
++require 'sup/person'
++require 'sup/account'
++require 'sup/message-chunks'
++require 'sup/crypto'
++require 'stringio'
++
++module Redwood
++
++# These are all singletons
++CryptoManager.init
++Dir.mktmpdir('sup-test') do|f|
++    HookManager.init f
++end
++am = {:default=> {:name => "", :email=>ENV['EMAIL']}}
++AccountManager.init am
++
++class TestCryptoManager < Test::Unit::TestCase
++
++    def setup
++        @from_email = ENV['EMAIL']
++        # Change this or import my public key to make these tests work.
++        @to_email = 'clint at ubuntu.com'
++    end
++
++    def teardown
++    end
++
++    def test_sign
++        if CryptoManager.have_crypto? then
++            signed = CryptoManager.sign @from_email, at to_email,"ABCDEFG"
++            assert_instance_of RMail::Message, signed
++            assert_equal "ABCDEFG", signed.body[0]
++            assert signed.body[1].body.length > 0 , "signature length must be > 0"
++            assert (signed.body[1].body.include? "-----BEGIN PGP SIGNATURE-----") , "Expecting PGP armored data"
++        end
++    end
++
++    def test_encrypt
++        if CryptoManager.have_crypto? then
++            encrypted = CryptoManager.encrypt @from_email, [@to_email], "ABCDEFG"
++            assert_instance_of RMail::Message, encrypted
++            assert (encrypted.body[1].body.include? "-----BEGIN PGP MESSAGE-----") , "Expecting PGP armored data"
++        end
++    end
++
++    def test_sign_and_encrypt
++        if CryptoManager.have_crypto? then
++            encrypted = CryptoManager.sign_and_encrypt @from_email, [@to_email], "ABCDEFG"
++            assert_instance_of RMail::Message, encrypted
++            assert (encrypted.body[1].body.include? "-----BEGIN PGP MESSAGE-----") , "Expecting PGP armored data"
++        end
++    end
++
++    def test_decrypt
++        if CryptoManager.have_crypto? then
++            encrypted = CryptoManager.encrypt @from_email, [@to_email], "ABCDEFG"
++            assert_instance_of RMail::Message, encrypted
++            assert_instance_of String, (encrypted.body[1].body)
++            decrypted = CryptoManager.decrypt encrypted.body[1], true
++            assert_instance_of Array, decrypted
++            assert_instance_of Chunk::CryptoNotice, decrypted[0]
++            assert_instance_of Chunk::CryptoNotice, decrypted[1]
++            assert_instance_of RMail::Message, decrypted[2]
++            assert_equal "ABCDEFG" , decrypted[2].body
++        end
++    end
++
++    def test_verify
++        if CryptoManager.have_crypto?
++            signed = CryptoManager.sign @from_email, @to_email, "ABCDEFG"
++            assert_instance_of RMail::Message, signed
++            assert_instance_of String, (signed.body[1].body)
++            CryptoManager.verify signed.body[0], signed.body[1], true
++        end
++    end
++
++end
++
++end
+-- 
diff --git a/debian/patches/series b/debian/patches/series
index 9fb5e07..500fed9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-Patch-out-all-requires-of-rubygems.patch
+0002-Fix-support-for-gpgme-2.0.patch

-- 
sup-mail.git



More information about the Pkg-ruby-extras-commits mailing list