Mailinglist Archive: zypp-devel (24 mails)

< Previous Next >
Re: [zypp-devel] [PATCH 2/2] Add support for using libproxy to find proxies
  • From: "Duncan Mac-Vicar P." <dmacvicar@xxxxxxx>
  • Date: Mon, 22 Nov 2010 12:50:52 +0100
  • Message-id: <4CEA591C.3070908@xxxxxxx>
On 11/20/2010 02:16 PM, David Woodhouse wrote:
This one probably isn't ready to apply as-is, but it's working for me
right now. Problems include:

- it should have proper CMake magic to find and build against (and
optionally *not* build against) libproxy.

- it probably shouldn't unconditionally subvert the old code which
looks in /etc/sysconfig/proxy for per-url-scheme information.

- There's a memory leak when we return a proxy specified by libproxy.

David, thanks a lot for the patches

I have applied the first one locally as is. It only changes the API to do it more powerful, but the behavior is basically unchanged. (and thanks a lot for separating the patches in that logical way)

For the second one, I added a real check for libproxy, and compiled the files conditionally. If libproxy is found, then it is used, otherwise the default Sysconfig one is used. May be we should remove the Sysconfig one completely then.

However once I build, the testcases fail.

The following tests FAILED:
12 - Fetcher_test (Failed)
17 - MediaSetAccess_test (Failed)
24 - RepoInfo_test (Failed)
48 - MirrorList_test (Failed)
Errors while running CTest

--
Duncan Mac-Vicar P. - Novell® Making IT Work As One™
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0629b1f..fffec8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,6 +110,14 @@ FIND_PACKAGE(EXPAT REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED)
FIND_PACKAGE(Udev REQUIRED)

+FIND_PACKAGE(libproxy)
+IF ( NOT LIBPROXY_FOUND )
+ MESSAGE( FATAL_ERROR " libproxy not found" )
+ELSE ( NOT LIBPROXY_FOUND )
+ INCLUDE_DIRECTORIES( ${LIBPROXY_INCLUDE_DIR} )
+ ADD_DEFINITIONS(-D_WITH_LIBPROXY_SUPPORT_)
+ENDIF( NOT LIBPROXY_FOUND )
+
FIND_PROGRAM( DOXYGEN doxygen )
IF ( NOT DOXYGEN )
MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the
documentation." )
diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt
index d4f4682..7a0aebc 100644
--- a/zypp/CMakeLists.txt
+++ b/zypp/CMakeLists.txt
@@ -324,13 +324,20 @@ INSTALL( FILES
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/media
)

+IF ( LIBPROXY_FOUND )
+ SET(zypp_media_proxyinfo_libproxy_SRCS media/proxyinfo/ProxyInfoLibproxy.cc)
+ SET(zypp_media_proxyinfo_libproxy_HEADERS
media/proxyinfo/ProxyInfoLibproxy.h)
+ENDIF( LIBPROXY_FOUND )
+
SET( zypp_media_proxyinfo_SRCS
media/proxyinfo/ProxyInfoSysconfig.cc
+ ${zypp_media_proxyinfo_libproxy_SRCS}
)

SET( zypp_media_proxyinfo_HEADERS
media/proxyinfo/ProxyInfoImpl.h
media/proxyinfo/ProxyInfoSysconfig.h
+ ${zypp_media_proxyinfo_libproxy_HEADERS}
media/proxyinfo/ProxyInfos.h
)

@@ -912,6 +919,7 @@ TARGET_LINK_LIBRARIES(zypp ${OPENSSL_LIBRARIES} )
TARGET_LINK_LIBRARIES(zypp ${CRYPTO_LIBRARIES} )
TARGET_LINK_LIBRARIES(zypp ${SIGNALS_LIBRARY} )
TARGET_LINK_LIBRARIES(zypp ${UDEV_LIBRARY} )
+TARGET_LINK_LIBRARIES(zypp ${LIBPROXY_LIBRARIES} )

INSTALL(TARGETS zypp LIBRARY DESTINATION ${LIB_INSTALL_DIR} )

diff --git a/zypp/media/MediaCurl.cc b/zypp/media/MediaCurl.cc
index bf06908..0699e59 100644
--- a/zypp/media/MediaCurl.cc
+++ b/zypp/media/MediaCurl.cc
@@ -295,7 +295,7 @@ void fillSettingsFromUrl( const Url &url, TransferSettings
&s )
}
s.setProxy(proxy);
s.setProxyEnabled(true);
- }
+ }
}

// HTTP authentication type
@@ -326,7 +326,11 @@ void fillSettingsFromUrl( const Url &url, TransferSettings
&s )
*/
void fillSettingsSystemProxy( const Url&url, TransferSettings &s )
{
+#ifdef _WITH_LIBPROXY_SUPPORT_
+ ProxyInfo proxy_info (ProxyInfo::ImplPtr(new ProxyInfoLibproxy()));
+#else
ProxyInfo proxy_info (ProxyInfo::ImplPtr(new ProxyInfoSysconfig("proxy")));
+#endif
s.setProxyEnabled( proxy_info.useProxyFor( url ) );
if ( s.proxyEnabled() )
s.setProxy(proxy_info.proxy(url));
@@ -465,9 +469,9 @@ Url MediaCurl::clearQueryString(const Url &url) const

TransferSettings & MediaCurl::settings()
{
- return _settings;
+ return _settings;
}
-
+

void MediaCurl::setCookieFile( const Pathname &fileName )
{
@@ -487,17 +491,17 @@ void MediaCurl::checkProtocol(const Url &url) const
std::string scheme( url.getScheme());
bool found = false;
for(proto=curl_info->protocols; !found && *proto; ++proto)
- {
+ {
if( scheme == std::string((const char *)*proto))
found = true;
- }
+ }
if( !found)
- {
+ {
std::string msg("Unsupported protocol '");
msg += scheme;
- msg += "'";
+ msg += "'";
ZYPP_THROW(MediaBadUrlException(_url, msg));
- }
+ }
}
}

@@ -525,7 +529,7 @@ void MediaCurl::setupEasy()

// create non persistant settings
// so that we don't add headers twice
- TransferSettings vol_settings(_settings);
+ TransferSettings vol_settings(_settings);

// add custom headers
vol_settings.addHeader(anonymousIdHeader());
@@ -643,7 +647,7 @@ void MediaCurl::setupEasy()
{
SET_OPTION(CURLOPT_NOPROXY, "*");
}
-
+
/** Speed limits */
if ( _settings.minDownloadSpeed() != 0 )
{
@@ -676,7 +680,7 @@ void MediaCurl::setupEasy()
++it )
{
MIL << "HEADER " << *it << std::endl;
-
+
_customHeaders = curl_slist_append(_customHeaders, it->c_str());
if ( !_customHeaders )
ZYPP_THROW(MediaCurlInitException(_url));
@@ -997,7 +1001,7 @@ void MediaCurl::evaluateCurlCode( const Pathname &filename,
bool MediaCurl::doGetDoesFileExist( const Pathname & filename ) const
{
DBG << filename.asString() << endl;
-
+
if(!_url.isValid())
ZYPP_THROW(MediaBadUrlException(_url));

diff --git a/zypp/media/proxyinfo/ProxyInfos.h
b/zypp/media/proxyinfo/ProxyInfos.h
index 9cfe78a..408b9f3 100644
--- a/zypp/media/proxyinfo/ProxyInfos.h
+++ b/zypp/media/proxyinfo/ProxyInfos.h
@@ -16,5 +16,8 @@
#include <list>

#include "zypp/media/proxyinfo/ProxyInfoSysconfig.h"
+#ifdef _WITH_LIBPROXY_SUPPORT_
+#include "zypp/media/proxyinfo/ProxyInfoLibproxy.h"
+#endif

#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOS_H
< Previous Next >
Follow Ups
References