dev-cpp/libcmis: Fix gdrive 2FA again, restrict tests, use vcs-snapshot
authorAndreas Sturmlechner <asturm@gentoo.org>
Thu, 6 Apr 2017 21:47:49 +0000 (23:47 +0200)
committerAndreas Sturmlechner <asturm@gentoo.org>
Thu, 6 Apr 2017 22:08:38 +0000 (00:08 +0200)
Gentoo-bug: 577926

See also: https://bugs.documentfoundation.org/show_bug.cgi?id=98416

Package-Manager: Portage-2.3.3, Repoman-2.3.1

dev-cpp/libcmis/files/libcmis-0.5.2-fix-gdrive-2fa.patch [new file with mode: 0644]
dev-cpp/libcmis/libcmis-0.5.2_pre20160820-r1.ebuild [new file with mode: 0644]
dev-cpp/libcmis/libcmis-9999.ebuild

diff --git a/dev-cpp/libcmis/files/libcmis-0.5.2-fix-gdrive-2fa.patch b/dev-cpp/libcmis/files/libcmis-0.5.2-fix-gdrive-2fa.patch
new file mode 100644 (file)
index 0000000..3c19e99
--- /dev/null
@@ -0,0 +1,70 @@
+From 1effce6d286ba3a9f467e15074b532d2ba4b7c98 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Szymon=20K=C5=82os?= <eszkadev@gmail.com>
+Date: Wed, 29 Mar 2017 17:45:10 +0200
+Subject: [PATCH] Fix 2FA for Google Drive
+
+---
+ src/libcmis/oauth2-providers.cxx | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/libcmis/oauth2-providers.cxx b/src/libcmis/oauth2-providers.cxx
+index 74c0fec..dd872dd 100644
+--- a/src/libcmis/oauth2-providers.cxx
++++ b/src/libcmis/oauth2-providers.cxx
+@@ -37,6 +37,7 @@
+ #define CHALLENGE_PAGE_ACTION_LEN sizeof( CHALLENGE_PAGE_ACTION ) - 1
+ #define PIN_FORM_ACTION "/signin/challenge/ipp"
+ #define PIN_FORM_ACTION_LEN sizeof( PIN_FORM_ACTION ) - 1
++#define PIN_INPUT_NAME "Pin"
+ using namespace std;
+@@ -152,7 +153,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
+         }
+         loginChallengeLink = "https://accounts.google.com" + loginChallengeLink;
+-        loginChallengePost += "Pin=";
++        loginChallengePost += string( PIN_INPUT_NAME ) + "=";
+         loginChallengePost += string( pin );
+         istringstream loginChallengeIs( loginChallengePost );
+@@ -291,6 +292,8 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
+     if ( reader == NULL ) return 0;
+     bool readInputField = false;
++    bool bIsRightForm = false;
++    bool bHasPinField = false;
+     while ( true )
+     {
+@@ -301,6 +304,12 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
+         // Find the redirect link
+         if ( xmlStrEqual( nodeName, BAD_CAST( "form" ) ) )
+         {
++            // 2FA: Don't add fields form other forms not having pin field
++            if ( bIsRightForm && !bHasPinField )
++                post = string( "" );
++            if ( bIsRightForm && bHasPinField )
++                break;
++
+             xmlChar* action = xmlTextReaderGetAttribute( reader, 
+                                                          BAD_CAST( "action" ));
+@@ -311,7 +320,7 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
+                 bool bChallengePage = ( strncmp( (char*)action,
+                                                  CHALLENGE_PAGE_ACTION,
+                                                  CHALLENGE_PAGE_ACTION_LEN ) == 0 );
+-                bool bIsRightForm = ( strncmp( (char*)action,
++                bIsRightForm = ( strncmp( (char*)action,
+                                                  PIN_FORM_ACTION,
+                                                  PIN_FORM_ACTION_LEN ) == 0 );
+                 if ( ( xmlStrlen( action ) > 0 )
+@@ -332,6 +341,8 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
+                                                        BAD_CAST( "name" ));
+             xmlChar* value = xmlTextReaderGetAttribute( reader, 
+                                                         BAD_CAST( "value" ));
++            if ( name != NULL && strcmp( (char*)name, PIN_INPUT_NAME ) == 0 )
++                bHasPinField = true;
+             if ( ( name != NULL ) && ( value!= NULL ) )
+             {
+                 if ( ( xmlStrlen( name ) > 0) && ( xmlStrlen( value ) > 0) )
diff --git a/dev-cpp/libcmis/libcmis-0.5.2_pre20160820-r1.ebuild b/dev-cpp/libcmis/libcmis-0.5.2_pre20160820-r1.ebuild
new file mode 100644 (file)
index 0000000..08e6cd3
--- /dev/null
@@ -0,0 +1,82 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+if [[ ${PV} = 9999 ]]; then
+       EGIT_REPO_URI="https://github.com/tdf/libcmis.git"
+       SCM_ECLASS="git-r3"
+elif [[ ${PV} = *_pre* ]]; then
+       SCM_ECLASS="vcs-snapshot"
+       snapshot=d2054a12e3f52fff8e96341e8c48f0dcd75e2e2a
+       SRC_URI="https://github.com/tdf/${PN}/archive/${snapshot}.tar.gz -> ${P}.tar.gz"
+       unset snapshot
+else
+       SRC_URI="https://github.com/tdf/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+fi
+inherit alternatives autotools ${SCM_ECLASS}
+unset SCM_ECLASS
+
+DESCRIPTION="C++ client library for the CMIS interface"
+HOMEPAGE="https://github.com/tdf/libcmis"
+
+LICENSE="|| ( GPL-2 LGPL-2 MPL-1.1 )"
+SLOT="0.5"
+
+# Don't move KEYWORDS on the previous line or ekeyword won't work # 399061
+[[ ${PV} == 9999 ]] || \
+KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux"
+
+IUSE="man static-libs test"
+
+COMMON_DEPEND="
+       dev-libs/boost:=
+       dev-libs/libxml2
+       net-misc/curl
+"
+DEPEND="${COMMON_DEPEND}
+       virtual/pkgconfig
+       man? (
+               app-text/docbook2X
+               dev-libs/libxslt
+       )
+       test? (
+               dev-util/cppcheck
+               dev-util/cppunit
+       )
+"
+RDEPEND="${COMMON_DEPEND}
+       !<dev-cpp/libcmis-0.5.0
+"
+
+RESTRICT="test"
+
+PATCHES=( "${FILESDIR}/${PN}-0.5.2-fix-gdrive-2fa.patch" )
+
+src_prepare() {
+       default
+       [[ ${PV} = *_pre* || ${PV} = 9999 ]] && eautoreconf
+}
+
+src_configure() {
+       econf \
+               --program-suffix=-${SLOT} \
+               --disable-werror \
+               $(use_with man) \
+               $(use_enable static-libs static) \
+               $(use_enable test tests) \
+               --enable-client
+}
+
+src_install() {
+       default
+       find "${D}" -name '*.la' -delete || die
+}
+
+pkg_postinst() {
+       alternatives_auto_makesym /usr/bin/cmis-client "/usr/bin/cmis-client-[0-9].[0-9]"
+}
+
+pkg_postrm() {
+       alternatives_auto_makesym /usr/bin/cmis-client "/usr/bin/cmis-client-[0-9].[0-9]"
+}
index 4db743bf442947716e67e86477ef0c0e71c4d26c..603a0334c7de2b51964b5403284966cbc8499ec6 100644 (file)
@@ -1,23 +1,24 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
 
-EGIT_REPO_URI="https://github.com/tdf/libcmis.git"
-[[ ${PV} == 9999 ]] && SCM_ECLASS="git-r3"
-inherit alternatives autotools ${SCM_ECLASS}
-unset SCM_ECLASS
-
-DESCRIPTION="C++ client library for the CMIS interface"
-HOMEPAGE="https://github.com/tdf/libcmis"
-if [[ ${PV} = *_pre* ]]; then
+if [[ ${PV} = 9999 ]]; then
+       EGIT_REPO_URI="https://github.com/tdf/libcmis.git"
+       SCM_ECLASS="git-r3"
+elif [[ ${PV} = *_pre* ]]; then
+       SCM_ECLASS="vcs-snapshot"
        snapshot=d2054a12e3f52fff8e96341e8c48f0dcd75e2e2a
        SRC_URI="https://github.com/tdf/${PN}/archive/${snapshot}.tar.gz -> ${P}.tar.gz"
-       S="${WORKDIR}/${PN}-${snapshot}"
        unset snapshot
-elif [[ ${PV} != 9999 ]] ; then
+else
        SRC_URI="https://github.com/tdf/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
 fi
+inherit alternatives autotools ${SCM_ECLASS}
+unset SCM_ECLASS
+
+DESCRIPTION="C++ client library for the CMIS interface"
+HOMEPAGE="https://github.com/tdf/libcmis"
 
 LICENSE="|| ( GPL-2 LGPL-2 MPL-1.1 )"
 SLOT="0.5"
@@ -26,7 +27,7 @@ SLOT="0.5"
 [[ ${PV} == 9999 ]] || \
 KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux"
 
-IUSE="static-libs man test"
+IUSE="man static-libs test"
 
 COMMON_DEPEND="
        dev-libs/boost:=
@@ -48,6 +49,8 @@ RDEPEND="${COMMON_DEPEND}
        !<dev-cpp/libcmis-0.5.0
 "
 
+RESTRICT="test"
+
 src_prepare() {
        default
        [[ ${PV} = *_pre* || ${PV} = 9999 ]] && eautoreconf