*flymake.h.gch
CMakeLists.txt.user*
zypp/APIConfig.h
+.vscode
ENDIF (DEBIAN)
IF ( ENABLE_DEVEL_BUILD )
- MESSAGE( WARNING "Zypp devel build enabled, do not do this in production" )
- SET( ZYPP_RPM_BINARY "${CMAKE_BINARY_DIR}/tools/zypp-rpm/zypp-rpm")
+ MESSAGE( WARNING "Zypp devel build enabled, do not do this in production" )
+ SET( ZYPP_RPM_BINARY "${CMAKE_BINARY_DIR}/tools/zypp-rpm/zypp-rpm")
ELSE()
- SET( ZYPP_RPM_BINARY "${ZYPP_LIBEXEC_INSTALL_DIR}/zypp-rpm")
+ SET( ZYPP_RPM_BINARY "${ZYPP_LIBEXEC_INSTALL_DIR}/zypp-rpm")
ENDIF( ENABLE_DEVEL_BUILD )
message ( "Using zypp-rpm from path: ${ZYPP_RPM_BINARY}" )
endif()
if( RPM_LIB_VER VERSION_GREATER_EQUAL "5.0.0" )
- MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
- ADD_DEFINITIONS(-D_RPM_5)
+ MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
+ ADD_DEFINITIONS(-D_RPM_5)
endif ()
ENDIF( NOT RPM_FOUND)
####################################################################
ADD_SUBDIRECTORY( zypp-proto )
ADD_SUBDIRECTORY( zypp-core )
+ADD_SUBDIRECTORY( zypp-media )
+ADD_SUBDIRECTORY( zypp-curl )
ADD_SUBDIRECTORY( zypp )
# do not build devel by default
ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
#
SET(LIBZYPP_MAJOR "17")
SET(LIBZYPP_COMPATMINOR "22")
-SET(LIBZYPP_MINOR "28")
-SET(LIBZYPP_PATCH "8")
+SET(LIBZYPP_MINOR "29")
+SET(LIBZYPP_PATCH "0")
#
-# LAST RELEASED: 17.28.8 (22)
+# LAST RELEASED: 17.29.0 (22)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
#=======
#include <zypp/base/Debug.h>
#include <zypp/base/Functional.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/ProvideNumericId>
#include <zypp/base/Flags.h>
#include <zypp/AutoDispose.h>
#include <zypp/base/Debug.h>
#include <zypp/base/Functional.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/ProvideNumericId>
#include <zypp/base/Flags.h>
#include <zypp/base/StrMatcher.h>
#include <zypp/AutoDispose.h>
#include <zypp/base/Debug.h>
#include <zypp/base/Functional.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/ProvideNumericId>
#include <zypp/base/Flags.h>
#include <zypp/AutoDispose.h>
<HR><!-- ====================================================================== -->
\section plugins-intro Introduction
-Plugins allow to extend the ZYpp package manager without the need to change
+Plugins allow one to extend the ZYpp package manager without the need to change
code. Plugins are designed as external programs so that they can be written in any language.
\section plugin-protocols Plugin protocols
%{_datadir}/cmake/Modules/*
%{_includedir}/zypp
%{_includedir}/zypp-core
+%{_includedir}/zypp-media
+%{_includedir}/zypp-curl
+%{_libdir}/pkgconfig/libzypp.pc
+%{_libdir}/pkgconfig/libzypp.pc
%{_libdir}/pkgconfig/libzypp.pc
%files devel-doc
-------------------------------------------------------------------
+Thu Dec 23 16:01:31 CET 2021 - ma@suse.de
+
+- Use the default zypp.conf settings if no zypp.conf exists
+ (bsc#1193488)
+- Fix wrong encoding of iso: URL components (bsc#954813)
+- Handle armv8l as armv7hl compatible userland.
+- Introduce zypp-curl a sublibrary for CURL related code.
+- zypp-rpm: Increase rpm loglevel if ZYPP_RPM_DEBUG is set.
+- Save all signatures associated with a public key in its
+ PublicKeyData.
+- version 17.29.0 (22)
+
+-------------------------------------------------------------------
Thu Nov 11 15:12:44 CET 2021 - ma@suse.de
- Disable logger in the child after fork (bsc#1192436)
Thu Mar 12 18:38:30 CET 2009 - ma@suse.de
- Add Resolver::setSolveSrcPackages. Per default disable solving
- of source package dependencies. We will later allow to enable
+ of source package dependencies. We will later allow enabling
it per package.
- version 6.3.0 (2)
-------------------------------------------------------------------
Fri Jan 9 17:01:10 CET 2009 - jkupec@suse.cz
-- handle HTTP 503 reponses as temporary errors (bnc #462545)
+- handle HTTP 503 responses as temporary errors (bnc #462545)
-------------------------------------------------------------------
Thu Dec 18 22:26:18 CET 2008 - ma@suse.de
-------------------------------------------------------------------
Tue Apr 1 21:54:10 CEST 2008 - ma@suse.de
-- Extend sat::WhatProvides to allow to query for possible providers
+- Extend sat::WhatProvides allows one to query for possible providers
of a collection of capabilies. E.g. all providers of a packages
requirements.
- Fixed retrieval of translated texts from .solv files, provided the
Fri Mar 14 14:27:43 CET 2008 - dmacvicar@suse.de
- look for openssl in cmake, actually we build require it
-- explicitely link against openssl and crypto, required to
+- explicitly link against openssl and crypto, required to
compile in all platforms/distros.
-------------------------------------------------------------------
- Added flag to MediaManager::isUseableAttachPoint, whether
to check against system mount entries or not.
-- Disallow to use the attachpoints of another media handlers
+- Disallows one to use the attachpoints of another media handlers
as source path in MediaDIR.
- rev 2917
Fri Mar 31 13:27:09 CEST 2006 - mt@suse.de
- Implemented several hal get/set/removeDeviceProperty wrappers
-- Improved HalException to allow to fetch HAL/DBUS error componets
+- Improved HalException allows one to fetch HAL/DBUS error componets
- rev 2830
-------------------------------------------------------------------
SET( XGETTEXT_OPTIONS ${XGETTEXT_OPTIONS} --package-name=${POT_NAME} --default-domain=${POT_NAME} )
SET( _abs_POT_FILE_DEPENDS )
-SET( POT_FILE_DEPENDS ${POT_FILE_DEPENDS_ZYPP} ${POT_FILE_DEPENDS_ZYPP_CORE} )
+SET( POT_FILE_DEPENDS ${POT_FILE_DEPENDS_ZYPP} ${POT_FILE_DEPENDS_ZYPP_CORE} ${POT_FILE_DEPENDS_ZYPP_MEDIA} ${POT_FILE_DEPENDS_ZYPP_CURL} )
FOREACH( _currentDepends ${POT_FILE_DEPENDS} )
SET( _abs_POT_FILE_DEPENDS ${_abs_POT_FILE_DEPENDS} ${LIBZYPP_SOURCE_DIR}/${_currentDepends} )
ENDFOREACH()
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "تسمح بتثبيت PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "permet instal·lar el PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "umožnit instalaci PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "giv tillade til installation af PTF'en %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "Erlauben das PTF %1% zu installieren"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "permitir la instalación de PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "lubage paigaldada PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "salli asentaa PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "autoriser l'installation du PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "permitir a instalación de PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "memungkinkan untuk memasang PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "consentire installazione di PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "PTF %1% のインストールを許可する"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "toestaan de PTF %1% te installeren"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "permitir instalar o PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "разрешить установку PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "umožniť inštaláciu PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "дозволити встановити PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
"Project-Id-Version: YaST (@memory@)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-26 11:04+0200\n"
-"PO-Revision-Date: 2021-07-26 20:11+0000\n"
-"Last-Translator: Dingzhong Chen <wsxy162@gmail.com>\n"
+"PO-Revision-Date: 2021-11-30 09:11+0000\n"
+"Last-Translator: Hillwood Yang <hillwoodroc@gmail.com>\n"
"Language-Team: Chinese (China) <https://l10n.opensuse.org/projects/libzypp/"
"master/zh_CN/>\n"
"Language: zh_CN\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.7.1\n"
+"X-Generator: Weblate 4.8.1\n"
#: zypp/CountryCode.cc:50
msgid "Unknown country: "
#: zypp/repo/SUSEMediaVerifier.cc:104
#, boost-format
msgid "Expected medium %1%/%2% identified by file '%3%' with content:"
-msgstr ""
+msgstr "由'%3%' 文件标识的预期介质 %1%/%2% 内容为:"
#. [lhs][rhs] 0 = installed; 1 = to be installed
#. TranslatorExplanation %1%(filename) %2%(package1) %3%(package2)
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "允许安装 PTF %1%"
#. translator: %1% is a package name
"install %1% from vendor %2%\n"
" replacing %3% from vendor %4%"
msgstr ""
+"由供应商 %2% 安装 %1% 代替\n"
+"由供应商 %4% 安装 %3%"
#: zypp/solver/detail/SATResolver.cc:1507
#, boost-format
#: zypp/target/TargetImpl.cc:2619
msgid "Executing the transaction failed because of the following problems:"
-msgstr ""
+msgstr "由于以下问题执行操作失败:"
#. TranslatorExplanation after semicolon is error message
#. TranslatorExplanation the colon is followed by an error message
#: zypp-core/zyppng/io/forkspawnengine.cc:111
#: zypp-core/zyppng/io/forkspawnengine.cc:359
msgid "Invalid spawn arguments given."
-msgstr ""
+msgstr "子参数无效。"
#: zypp-core/zyppng/io/forkspawnengine.cc:174
msgid "Unable to create control pipe."
-msgstr ""
+msgstr "无法创建控制管道。"
#: zypp-core/zyppng/io/forkspawnengine.cc:240
#, c-format, boost-format
#: zypp-core/zyppng/io/forkspawnengine.cc:306
#, c-format, boost-format
msgid "Can't exec '%s', chdir failed (%s)."
-msgstr ""
+msgstr "无法执行 '%s',chdir 失败 (%s) 。"
#: zypp-core/zyppng/io/forkspawnengine.cc:309
#, c-format, boost-format
msgid "Can't exec '%s', chroot failed (%s)."
-msgstr ""
+msgstr "无法执行 '%s',chroot 失败 (%s)。"
#: zypp-core/zyppng/io/forkspawnengine.cc:312
#, c-format, boost-format
msgid "Can't exec '%s', exec failed (%s)."
-msgstr ""
+msgstr "无法执行 '%s',执行失败 (%s)。"
#: zypp-core/zyppng/io/forkspawnengine.cc:316
#, c-format, boost-format
msgid "Can't exec '%s', unexpected error."
-msgstr ""
+msgstr "无法执行 '%s',意外错误。"
#~ msgid "%s does not belong to a distupgrade repository"
#~ msgstr "%s 不属于发行版升级源"
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr "允許安裝 PTF %1%"
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#. translator: %1% is a package name
#: zypp/solver/detail/SATResolver.cc:1452
#, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
msgstr ""
#. translator: %1% is a package name
#include <zypp/base/LogControl.h>
#include <zypp/base/LogTools.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/IOStream.h>
#include <zypp/base/Flags.h>
#include <zypp/ZYppFactory.h>
#include <zypp/Url.h>
#include <zypp/Pathname.h>
#include <zypp/base/PtrTypes.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
#include <functional>
#include <zypp/Url.h>
#include <zypp/PathInfo.h>
#include <zypp/base/Easy.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-media/auth/AuthData>
-#include <zypp/media/CredentialFileReader.h>
+#include <zypp-media/auth/CredentialFileReader>
using std::cout;
using std::endl;
#include <zypp/Url.h>
#include <zypp/TmpPath.h>
-#include <zypp/media/CredentialFileReader.cc>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-media/auth/CredentialFileReader>
+#include <zypp-media/auth/CredentialManager>
#include <zypp/PathInfo.h>
#include <vector>
#include <boost/test/unit_test.hpp>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/parser/MetaLinkParser>
using namespace zypp;
using namespace zypp::media;
#include "TestSetup.h"
#include <zypp/parser/HistoryLogReader.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
using namespace zypp;
#include <boost/test/unit_test.hpp>
#include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/parser/IniDict>
#include <zypp/Url.h>
#include <zypp/PathInfo.h>
#include <boost/test/unit_test.hpp>
#include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/parser/IniParser.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/parser/IniParser>
#include <zypp/Url.h>
#include <zypp/PathInfo.h>
// Boost.Test
#include <boost/test/unit_test.hpp>
-#include <zypp/base/GzStream.h>
+#include <zypp-core/base/GzStream>
#include <zypp/Pathname.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
BOOST_AUTO_TEST_CASE(gz_simple_read_write)
{
scr.open( "/bin/cat" );
BOOST_CHECK_EQUAL( scr.isOpen(), true );
BOOST_CHECK_EQUAL( (scr.getPid() != PluginScript::NotConnected ), true );
- BOOST_CHECK_EQUAL( scr.script(), "/bin/cat" ); // set after successfull open
+ BOOST_CHECK_EQUAL( scr.script(), "/bin/cat" ); // set after successful open
BOOST_CHECK_THROW( scr.open( "/bin/ls" ), PluginScriptException ); // already open
BOOST_CHECK_EQUAL( scr.isOpen(), true ); // stay with "/bin/cat"
#include <boost/test/unit_test.hpp>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
using boost::unit_test::test_case;
#include <zypp/base/Logger.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/ReferenceCounted.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/ProvideNumericId>
#define BOOST_TEST_MODULE PtrTypes
}
},
TestSample {
- //kernel-1-2 is explicitely in the keep spec, it should not be removed
+ //kernel-1-2 is explicitly in the keep spec, it should not be removed
//kernel-1-5 provides a symbol for a kmp that has a non kernel package depending on it, it should not be removed
TESTS_SRC_DIR"/zypp/data/PurgeKernels/withdeps",
"1-1-default",
// All tests below should define 3 checks, abbrev. by defines
//
// CHECK_DONE_*: When does the tranaction succeed? (return if not)
-// CHECK_STATE( NEXT ): The state the transition leads to (if successfull)
-// CHECK_CAUSER_*: Changes to the remembered causer (if successfull)
+// CHECK_STATE( NEXT ): The state the transition leads to (if successful)
+// CHECK_CAUSER_*: Changes to the remembered causer (if successful)
//
#define DOCHECK( FROMSTATE, TOSTATE, C_DONE, C_STATE, C_CAUSER ) \
BOOST_CHECK_EQUAL( one, url.asString() );
BOOST_CHECK_EQUAL( two, url.asCompleteString() );
- // hidden proxypass in the query is available when explicitely asked for
+ // hidden proxypass in the query is available when explicitly asked for
BOOST_CHECK_EQUAL( url.getQueryParam( "proxypass" ), "@PROXYPASS@" );
// absolute path defaults to 'file://'
// Boost.Test
#include <boost/test/unit_test.hpp>
-#include <zypp/base/ZckStream.h>
+#include <zypp-core/base/ZckStream>
#include <zypp/Pathname.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/PathInfo.h>
BOOST_AUTO_TEST_CASE(zchunk_simple_read_write)
#include <zypp/PathInfo.h>
#include <zypp/ExternalProgram.h>
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/parser/Sysconfig>
using boost::unit_test::test_suite;
using boost::unit_test::test_case;
#include <zypp-core/zyppng/base/EventLoop>
#include <zypp-core/zyppng/base/EventDispatcher>
-#include <zypp/zyppng/media/network/downloader.h>
-#include <zypp/zyppng/media/network/downloadspec.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-curl/ng/network/Downloader>
+#include <zypp-curl/ng/network/DownloadSpec>
+#include <zypp-curl/ng/network/NetworkRequestError>
+#include <zypp-curl/ng/network/NetworkRequestDispatcher>
+#include <zypp-curl/ng/network/Request>
+#include <zypp-media/auth/CredentialManager>
#include <zypp/Digest.h>
#include <zypp/TmpPath.h>
#include <zypp/PathInfo.h>
auto ev = zyppng::EventLoop::create();
zyppng::Downloader::Ptr downloader = std::make_shared<zyppng::Downloader>();
+ downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
//make sure the data here is big enough to cross the threshold of 256 bytes so we get a progress signal emitted and not only the alive signal.
std::string dummyContent = "This is just some dummy content,\nto test downloading and signals.\n"
zypp::filesystem::TmpFile targetFile;
std::shared_ptr<zyppng::Downloader> downloader = std::make_shared<zyppng::Downloader>();
+ downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
downloader->requestDispatcher()->setMaximumConcurrentConnections( maxDLs );
//first metalink download, generate a fully valid one
auto ev = zyppng::EventLoop::create();
std::shared_ptr<zyppng::Downloader> downloader = std::make_shared<zyppng::Downloader>();
+ downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
WebServer web((zypp::Pathname(TESTS_SRC_DIR)/"/zyppng/data/downloader").c_str(), 10001, withSSL );
BOOST_REQUIRE( web.start() );
auto ev = zyppng::EventLoop::create();
std::shared_ptr<zyppng::Downloader> downloader = std::make_shared<zyppng::Downloader>();
+ downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
WebServer web((zypp::Pathname(TESTS_SRC_DIR)/"/zyppng/data/downloader").c_str(), 10001, withSSL );
BOOST_REQUIRE( web.start() );
web.addRequestHandler( "quit", [ &ev ]( WebServer::Request & ){ ev->quit();} );
{
- // simply check by request count if the test was successfull:
+ // simply check by request count if the test was successful:
// if the proactive code adding the credentials to the first request is not executed we will
// have more than 1 request.
int reqCount = 0;
#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <zypp-core/zyppng/base/EventLoop>
-#include <zypp/media/MetaLinkParser.h> // for hexstr2bytes
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/parser/MetaLinkParser> // for hexstr2bytes
+#include <zypp-curl/ng/network/Request>
+#include <zypp-curl/ng/network/NetworkRequestDispatcher>
+#include <zypp-curl/ng/network/NetworkRequestError>
#include <zypp/TmpPath.h>
#include <zypp/base/String.h>
#include <zypp/Digest.h>
--- /dev/null
+#!/usr/bin/env python3
+
+import urllib3
+import sys
+import re
+
+p = re.compile('.*debuginfo.*')
+
+http = urllib3.PoolManager()
+r = http.request('GET', 'http://download.opensuse.org/history/list')
+if ( r.status != 200 ):
+ print("Failed to download history list\n")
+ sys.exit(1)
+
+html = r.data.decode("utf-8")
+list = html.split("\n")
+
+for i in list:
+ if ( len(i) == 0 ):
+ continue
+ print ( "Searching for history in: "+i )
+ rEntries = http.request('GET', "http://download.opensuse.org/history/"+i.strip()+"/rpm.list", preload_content=False )
+ if ( rEntries.status != 200 ):
+ print("Failed to download history database for "+i+"\n")
+ continue
+
+ for line in rEntries:
+ if ( p.search( line.decode() ) ):
+ print("Found match: "+line.decode()+" in: "+"http://download.opensuse.org/history/"+i.strip() )
+
+
+print("Done")
\ No newline at end of file
#define fmtREPO "(%2d)%-*s"
#define argREPO slv.repository().info().priority(), _maxREPO, slv.repository().name().c_str()
- #define fmtTIME "%10ld"
- #define argTIME time_t( slv.isSystem() ? slv.installtime() : slv.buildtime() )
+ #define fmtTIME "%s%10ld"
+ #define argTIME ( slv.isSystem() && slv.installtime() ? "i" : "b" ), time_t( slv.isSystem() && slv.installtime() ? slv.installtime() : slv.buildtime() )
#define fmtVEND "%s"
#define argVEND slv.vendor().c_str()
///////////////////////////////////////////////////////////////////
+ auto _ { getZYpp() };
ZConfig::instance();
Pathname sysRoot("/");
sat::Pool satpool( sat::Pool::instance() );
#include <signal.h>
#include <unistd.h>
+// Messages to the zypp log sent on stdout/stderr
+#define ZDBG std::cout
+#define ZERR std::cerr
+
+namespace env
+{
+ /// Allows to increase rpm loglevel
+ inline bool ZYPP_RPM_DEBUG()
+ {
+ static bool val = [](){
+ const char * env = getenv("ZYPP_RPM_DEBUG");
+ return( env && zypp::str::strToBool( env, true ) );
+ }();
+ return val;
+ }
+} // namespace env
// this is the order we expect the FDs we need to communicate to be set up
// by the parent. This is not pretty but it works and is less effort than
}
bool sendBytes ( int fd, const void *buf, size_t n ) {
- const auto written = zyppng::eintrSafeCall( ::write, fd, buf, n );
+ const size_t written = zyppng::eintrSafeCall( ::write, fd, buf, n );
return written == n;
}
{
zypp::PathInfo file( path_r );
if ( ! file.isFile() ) {
- std::cerr << "Not a file: " << path_r << std::endl;
+ ZERR << "Not a file: " << path_r << std::endl;
return std::make_pair( RpmHeader(), -1 );
}
FD_t fd = ::Fopen( path_r.c_str(), "r.ufdio" );
if ( fd == 0 || ::Ferror(fd) )
{
- std::cerr << "Can't open file for reading: " << path_r << " (" << ::Fstrerror(fd) << ")" << std::endl;
+ ZERR << "Can't open file for reading: " << path_r << " (" << ::Fstrerror(fd) << ")" << std::endl;
if ( fd )
::Fclose( fd );
return std::make_pair( RpmHeader(), -1 );
if ( ! nh )
{
- std::cerr << "Error reading header from " << path_r << " error(" << res << ")" << std::endl;
+ ZERR << "Error reading header from " << path_r << " error(" << res << ")" << std::endl;
return std::make_pair( RpmHeader(), res );
}
// check if our env is set up correctly
if ( ::isatty(STDIN_FILENO) || ::isatty(STDOUT_FILENO) || ::isatty(STDERR_FILENO) ) {
- std::cerr << "Running zypp-rpm directly from the console is not supported. This is just a internal helper tool for libzypp." << std::endl;
+ ZERR << "Running zypp-rpm directly from the console is not supported. This is just a internal helper tool for libzypp." << std::endl;
return OtherError;
}
// make sure the expected FDs are around too
struct stat sb;
if ( fstat( static_cast<int>(ExpectedFds::MessageFd), &sb) == -1 ) {
- std::cerr << "Expected message fd is not valid, aborting" << std::endl;
+ ZERR << "Expected message fd is not valid, aborting" << std::endl;
return OtherError;
}
if ( (sb.st_mode & S_IFMT) != S_IFIFO ){
- std::cerr << "Expected message fd is not a pipe, aborting" << std::endl;
+ ZERR << "Expected message fd is not a pipe, aborting" << std::endl;
return OtherError;
}
if ( fstat( static_cast<int>(ExpectedFds::ScriptFd), &sb) == -1 ) {
- std::cerr << "Expected script fd is not valid, aborting" << std::endl;
+ ZERR << "Expected script fd is not valid, aborting" << std::endl;
return OtherError;
}
if ( (sb.st_mode & S_IFMT) != S_IFIFO ){
- std::cerr << "Expected script fd is not a pipe, aborting" << std::endl;
+ ZERR << "Expected script fd is not a pipe, aborting" << std::endl;
return OtherError;
}
// lets read our todo from stdin
zyppng::rpc::HeaderSizeType msgSize = 0;
if ( !recvBytes( STDIN_FILENO, reinterpret_cast<char *>(&msgSize), sizeof(zyppng::rpc::HeaderSizeType) ) ) {
- std::cerr << "Wrong Header size, aborting" << std::endl;
+ ZERR << "Wrong Header size, aborting" << std::endl;
return WrongHeaderSize;
}
{
zyppng::FileInputStream in( STDIN_FILENO );
if ( !msg.ParseFromBoundedZeroCopyStream( &in, msgSize ) ) {
- std::cerr << "Wrong commit message format, aborting" << std::endl;
+ ZERR << "Wrong commit message format, aborting" << std::endl;
return WrongMessageFormat;
}
// first we initialize the rpmdb
int rc = ::rpmReadConfigFiles( NULL, NULL );
if ( rc ) {
- std::cerr << "rpmReadConfigFiles returned " << rc << std::endl;
+ ZERR << "rpmReadConfigFiles returned " << rc << std::endl;
return RpmInitFailed;
}
if ( rpmtsGetRdb(ts) == NULL ) {
int res = ::rpmtsOpenDB( ts, O_RDWR );
if ( res ) {
- std::cerr << "rpmdbOpen error(" << res << "): " << std::endl;
+ ZERR << "rpmdbOpen error(" << res << "): " << std::endl;
return FailedToOpenDb;
}
}
case RPMRC_OK:
break;
case RPMRC_NOTTRUSTED:
- std::cerr << zypp::str::Format( "Failed to verify key for %s" ) % file << std::endl;
+ ZERR << zypp::str::Format( "Failed to verify key for %s" ) % file << std::endl;
if ( !allowUntrusted )
return FailedToReadPackage;
break;
case RPMRC_NOKEY:
- std::cerr << zypp::str::Format( "Public key unavailable for %s" ) % file << std::endl;
+ ZERR << zypp::str::Format( "Public key unavailable for %s" ) % file << std::endl;
if ( !allowUntrusted )
return FailedToReadPackage;
break;
case RPMRC_NOTFOUND:
- std::cerr << zypp::str::Format( "Signature not found for %s" ) % file << std::endl;
+ ZERR << zypp::str::Format( "Signature not found for %s" ) % file << std::endl;
if ( !allowUntrusted )
return FailedToReadPackage;
break;
case RPMRC_FAIL:
- std::cerr << zypp::str::Format( "Signature does not verify for %s" ) % file << std::endl;
+ ZERR << zypp::str::Format( "Signature does not verify for %s" ) % file << std::endl;
return FailedToReadPackage;
default:
- std::cerr << zypp::str::Format( "Failed to open(generic error): %1%" ) % file << std::endl;
+ ZERR << zypp::str::Format( "Failed to open(generic error): %1%" ) % file << std::endl;
return FailedToReadPackage;
}
if ( !rpmHeader.first ) {
- std::cerr << zypp::str::Format( "Failed to read rpm header from: %1%" )% file << std::endl;
+ ZERR << zypp::str::Format( "Failed to read rpm header from: %1%" )% file << std::endl;
return FailedToReadPackage;
}
const auto res = ::rpmtsAddInstallElement( ts, rpmHeader.first.get(), &step, !step.install().multiversion(), nullptr );
if ( res ) {
- std::cerr << zypp::str::Format( "Failed to add %1% to the transaction." )% file << std::endl;
+ ZERR << zypp::str::Format( "Failed to add %1% to the transaction." )% file << std::endl;
return FailedToAddStepToTransaction;
}
const auto res = ::rpmtsAddEraseElement( ts, hdr.get(), 0 );
if ( res ) {
- std::cerr << zypp::str::Format( "Failed to add removal of %1% to the transaction." ) % name << std::endl;
+ ZERR << zypp::str::Format( "Failed to add removal of %1% to the transaction." ) % name << std::endl;
return FailedToAddStepToTransaction;
}
}
if ( !found ) {
- std::cerr << "Unable to remove " << name << " it was not found!" << std::endl;
+ ZERR << "Unable to remove " << name << " it was not found!" << std::endl;
}
} else {
- std::cerr << "Ignoring step that is neither a remove, nor a install." << std::endl;
+ ZERR << "Ignoring step that is neither a remove, nor a install." << std::endl;
}
}
::rpmtsSetNotifyCallback( ts, rpmLibCallback, &data );
// make sure we get da log
- ::rpmlogSetMask( RPMLOG_UPTO( RPMLOG_PRI(RPMLOG_INFO) ) );
+ ::rpmlogSetMask( RPMLOG_UPTO( RPMLOG_PRI(env::ZYPP_RPM_DEBUG() ? RPMLOG_DEBUG : RPMLOG_INFO) ) );
::rpmlogSetCallback( rpmLogCallback, nullptr );
// redirect the script output to a fd ( log level MUST be at least INFO )
);
if ( data.rpmFd.value() ) {
- std::cerr << "Assigning script FD" << std::endl;
+ //ZDBG << "Assigning script FD" << std::endl;
::rpmtsSetScriptFd( ts, data.rpmFd );
} else {
- std::cerr << "Failed to assign script FD" << std::endl;
+ ZERR << "Failed to assign script FD" << std::endl;
}
const auto &rpmMsg = sstr.str();
// TranslatorExplanation the colon is followed by an error message
- std::cerr << std::string("RPM failed: ") + rpmMsg << std::endl;
+ ZERR << std::string("RPM failed: ") + rpmMsg << std::endl;
return RpmFinishedWithTransactionError;
}
}
const auto orderRes = rpmtsOrder( ts );
if ( orderRes ) {
- std::cerr << zypp::str::Format( "Failed with error %1% while ordering transaction." )% orderRes << std::endl;
+ ZERR << zypp::str::Format( "Failed with error %1% while ordering transaction." )% orderRes << std::endl;
return RpmOrderFailed;
}
sstr << "rpm output:" << std::endl << errMsg << std::endl;
//HistoryLog().comment(sstr.str());
- std::cerr << "RPM transaction failed: " + errMsg << std::endl;
+ ZERR << "RPM transaction failed: " + errMsg << std::endl;
return err;
}
- std::cerr << "Success !!!!" << std::endl;
+ //ZDBG << "Success !!!!" << std::endl;
return NoError;
}
}
const auto &sendEndOfScriptTag = [&](){
- std::cerr << "Send end of script" << std::endl;
+ //ZDBG << "Send end of script" << std::endl;
::sendBytes( static_cast<int>( ExpectedFds::ScriptFd ), endOfScriptTag.data(), endOfScriptTag.size() );
};
if ( !iStep || !iStep->has_install() || iStep->install().pathname().empty() )
return NULL;
if ( fd != NULL )
- std::cerr << "ERR opening a file before closing the old one? Really ? " << std::endl;
+ ZERR << "ERR opening a file before closing the old one? Really ? " << std::endl;
fd = Fopen( iStep->install().pathname().data(), "r.ufdio" );
if (fd == NULL || Ferror(fd)) {
- std::cerr << "Error when opening file " << iStep->install().pathname().data() << std::endl;
+ ZERR << "Error when opening file " << iStep->install().pathname().data() << std::endl;
if (fd != NULL) {
Fclose(fd);
fd = NULL;
if ( !iStep ) {
if ( header.empty() ) {
- std::cerr << "No header and no transaction step for a uninstall start, not sending anything" << std::endl;
+ ZERR << "No header and no transaction step for a uninstall start, not sending anything" << std::endl;
return rc;
}
} else {
if ( !iStep->has_remove() ) {
- std::cerr << "Could not find package in removables " << header << " in transaction elements" << std::endl;
+ ZERR << "Could not find package in removables " << header << " in transaction elements" << std::endl;
return rc;
}
case RPMCALLBACK_INST_STOP: {
if ( !iStep ) {
- std::cerr << "Could not find package " << header << " in transaction elements for " << what << std::endl;
+ ZERR << "Could not find package " << header << " in transaction elements for " << what << std::endl;
return rc;
}
if ( !iStep ) {
if ( header.empty() ) {
- std::cerr << "No header and no transaction step for a uninstall stop, not sending anything" << std::endl;
+ ZERR << "No header and no transaction step for a uninstall stop, not sending anything" << std::endl;
return rc;
}
case RPMCALLBACK_UNPACK_ERROR: {
if ( !iStep ) {
- std::cerr << "Could not find package " << header << " in transaction elements for " << what << std::endl;
+ ZERR << "Could not find package " << header << " in transaction elements for " << what << std::endl;
return rc;
}
: 100.0);
if ( !iStep ) {
if ( header.empty() ) {
- std::cerr << "No header and no transaction step for a uninstall progress, not sending anything" << std::endl;
+ ZERR << "No header and no transaction step for a uninstall progress, not sending anything" << std::endl;
return rc;
}
break;
}
case RPMCALLBACK_CPIO_ERROR:
- std::cerr << "CPIO Error when installing package" << std::endl;
+ ZERR << "CPIO Error when installing package" << std::endl;
break;
case RPMCALLBACK_SCRIPT_START: {
zypp::proto::target::ScriptBegin script;
zypp::proto::target::RpmLog log;
log.set_level( rpmlogRecPriority(rec) );
log.set_line( zypp::str::asString( ::rpmlogRecMessage(rec) ) );
- std::cerr << "Pushing log message: " << log.line() << std::endl;
pushMessage( log );
return logRc;
{}
/** Ctor taking value and no dispose function. */
- explicit AutoDispose( param_type value_r )
+ explicit AutoDispose( const value_type & value_r )
: _pimpl( new Impl( value_r ) )
{}
/** Ctor taking value and dispose function. */
- AutoDispose( param_type value_r, const Dispose & dispose_r )
+ AutoDispose( const value_type & value_r, const Dispose & dispose_r )
: _pimpl( new Impl( value_r, dispose_r ) )
{}
+ /** Ctor taking rvalue and no dispose function. */
+ explicit AutoDispose( value_type &&value_r )
+ : _pimpl( new Impl( std::move(value_r) ) )
+ {}
+
+ /** Ctor taking rvalue and dispose function. */
+ AutoDispose( value_type &&value_r, const Dispose & dispose_r )
+ : _pimpl( new Impl( std::move(value_r), dispose_r ) )
+ {}
+
public:
/** Provide implicit conversion to \c Tp\&. */
private:
struct Impl : private base::NonCopyable
{
- Impl( param_type value_r )
- : _value( value_r )
+ template <typename T>
+ Impl( T &&value_r )
+ : _value( std::forward<T>(value_r) )
{}
- Impl( param_type value_r, const Dispose & dispose_r )
- : _value( value_r )
- , _dispose( dispose_r )
+ template <typename T, typename D>
+ Impl( T &&value_r, D &&dispose_r )
+ : _value( std::forward<T>(value_r) )
+ , _dispose( std::forward<D>(dispose_r) )
{}
~Impl()
{
Digest.h
ExternalProgram.h
Globals.h
+ KVMap
+ kvmap.h
ManagedFile.h
+ onmedialocation.h
+ OnMediaLocation
Pathname.h
TriBool.h
Url.h
Date.cc
Digest.cc
ExternalProgram.cc
+ onmedialocation.cc
Pathname.cc
Url.cc
)
INSTALL( FILES ${zypp_toplevel_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core" )
SET( zypp_base_HEADERS
+ base/DefaultIntegral
+ base/defaultintegral.h
+ base/DtorReset
+ base/dtorreset.h
base/Easy.h
base/EnumClass.h
base/Errno.h
base/ExternalDataSource.h
base/Function.h
base/Flags.h
+ base/fXstream
+ base/fxstream.h
base/Gettext.h
+ base/GzStream
+ base/gzstream.h
base/Hash.h
+ base/InputStream
+ base/inputstream.h
base/IOStream.h
base/IOTools.h
base/Iterable.h
base/Logger.h
base/NonCopyable.h
base/ProfilingFormater.h
+ base/ProvideNumericId
+ base/providenumericid.h
base/PtrTypes.h
base/ReferenceCounted.h
base/Regex.h
+ base/SimpleStreambuf
+ base/simplestreambuf.h
base/String.h
base/StringV.h
base/Unit.h
+ base/UserRequestException
+ base/userrequestexception.h
base/Xml.h
)
base/Exception.cc
base/ExternalDataSource.cc
base/Gettext.cc
+ base/gzstream.cc
+ base/inputstream.cc
base/IOStream.cc
base/IOTools.cc
base/LogControl.cc
base/String.cc
base/StringV.cc
base/Unit.cc
+ base/userrequestexception.cc
base/Xml.cc
)
+IF (ENABLE_ZCHUNK_COMPRESSION)
+
+ list( APPEND zypp_base_SRCS
+ base/zckstream.cc
+ )
+
+ list( APPEND zypp_base_HEADERS
+ base/ZckStream
+ base/zckstream.h
+ )
+
+ENDIF(ENABLE_ZCHUNK_COMPRESSION)
+
INSTALL( FILES ${zypp_base_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/base" )
SET( zypp_fs_HEADERS
fs/PathInfo.h
fs/TmpPath.h
+ fs/WatchFile
+ fs/watchfile.h
)
INSTALL( FILES ${zypp_fs_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/fs" )
+SET( zypp_ui_SRCS
+ ui/progressdata.cc
+)
+
+SET( zypp_ui_HEADERS
+ ui/ProgressData
+ ui/progressdata.h
+)
+
+INSTALL( FILES ${zypp_ui_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/ui" )
+
SET( zypp_url_SRCS
url/UrlUtils.cc
INSTALL( FILES ${zypp_url_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/url" )
+SET( zypp_parser_SRCS
+ parser/iniparser.cc
+ parser/inidict.cc
+ parser/parseexception.cc
+ parser/sysconfig.cc
+)
+
+SET( zypp_parser_HEADERS
+ parser/IniParser
+ parser/iniparser.h
+ parser/IniDict
+ parser/inidict.h
+ parser/ParseException
+ parser/parseexception.h
+ parser/Sysconfig
+ parser/sysconfig.h
+)
+
+INSTALL( FILES ${zypp_parser_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/parser" )
+
SET( zypp_parser_xml_SRCS
parser/xml/XmlEscape.cc
)
INSTALL( FILES ${zypp_parser_xml_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/parser/xml" )
+SET( zyppng_async_HEADERS
+ zyppng/async/AsyncOp
+ zyppng/async/asyncop.h
+)
+
SET( zyppng_base_SRCS
zyppng/base/abstracteventsource.cc
zyppng/base/base.cc
zyppng/io/SockAddr
)
+SET( zyppng_meta_HEADERS
+ zyppng/meta/Functional
+ zyppng/meta/functional.h
+ zyppng/meta/FunctionTraits
+ zyppng/meta/function_traits.h
+ zyppng/meta/TypeTraits
+ zyppng/meta/type_traits.h
+)
+
+SET( zyppng_pipelines_HEADERS
+ zyppng/pipelines/AsyncResult
+ zyppng/pipelines/asyncresult.h
+ zyppng/pipelines/Await
+ zyppng/pipelines/await.h
+ zyppng/pipelines/Expected
+ zyppng/pipelines/expected.h
+ zyppng/pipelines/Lift
+ zyppng/pipelines/lift.h
+ zyppng/pipelines/MTry
+ zyppng/pipelines/mtry.h
+ zyppng/pipelines/Redo
+ zyppng/pipelines/redo.h
+ zyppng/pipelines/Transform
+ zyppng/pipelines/transform.h
+ zyppng/pipelines/Wait
+ zyppng/pipelines/wait.h
+)
+
SET( zyppng_rpc_HEADERS
zyppng/rpc/rpc.h
zyppng/rpc/zerocopystreams.h
SET ( zypp_HEADERS
${zypp_toplevel_headers}
+ ${zyppng_async_HEADERS}
${zypp_base_HEADERS}
${zypp_fs_HEADERS}
+ ${zypp_ui_HEADERS}
${zypp_url_HEADERS}
+ ${zypp_parser_HEADERS}
${zypp_parser_xml_HEADERS}
${zyppng_base_HEADERS}
${zyppng_base_private_HEADERS}
${zyppng_core_HEADERS}
${zyppng_io_HEADERS}
${zyppng_io_private_HEADERS}
+ ${zyppng_meta_HEADERS}
+ ${zyppng_pipelines_HEADERS}
${zyppng_rpc_HEADERS}
${zyppng_thread_HEADERS}
${zyppng_thread_private_HEADERS}
${zypp_toplevel_SRCS}
${zypp_base_SRCS}
${zypp_fs_SRCS}
+ ${zypp_ui_SRCS}
${zypp_url_SRCS}
+ ${zypp_parser_SRCS}
${zypp_parser_xml_SRCS}
${zyppng_base_SRCS}
${zyppng_io_SRCS}
--- /dev/null
+#include "kvmap.h"
--- /dev/null
+#include "onmedialocation.h"
--- /dev/null
+#include "defaultintegral.h"
--- /dev/null
+#include "dtorreset.h"
}
}
+ void Exception::remember( std::exception_ptr old_r )
+ {
+ try {
+ if (old_r) {
+ std::rethrow_exception(old_r);
+ }
+ } catch( const Exception& e ) {
+ remember( e );
+ } catch ( const std::exception& e ) {
+ addHistory( e.what() );
+ } catch ( ... ) {
+ addHistory( "Remembered unknown exception" );
+ }
+ }
+
void Exception::addHistory( const std::string & msg_r )
{ _history.push_front( msg_r ); }
/** \overload moving */
void remember( Exception && old_r );
+ /** \overload std::exception_ptr */
+ void remember( std::exception_ptr old_r );
+
/** Add some message text to the history. */
void addHistory( const std::string & msg_r );
/** \overload moving */
Exception::log( excpt_r, where_r, "RETHROW: " );
throw;
}
+
+ /** Helper for \ref ZYPP_EXCPT_PTR( Exception ). */
+ template<class TExcpt, EnableIfIsException<TExcpt> = 0>
+ std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r );
+ template<class TExcpt, EnableIfIsException<TExcpt>>
+ std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r )
+ {
+ excpt_r.relocate( where_r );
+ Exception::log( excpt_r, where_r, "THROW: " );
+ return std::make_exception_ptr( excpt_r );
+ }
+
+ /** Helper for \ref ZYPP_EXCPT_PTR( not Exception ). */
+ template<class TExcpt, EnableIfNotException<TExcpt> = 0>
+ std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r );
+ template<class TExcpt, EnableIfNotException<TExcpt>>
+ std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r )
+ {
+ Exception::log( typeid(excpt_r).name(), where_r, "THROW: " );
+ return std::make_exception_ptr( excpt_r );
+ }
+
+
} // namespace exception_detail
///////////////////////////////////////////////////////////////////
#define ZYPP_THROW(EXCPT)\
::zypp::exception_detail::do_ZYPP_THROW( EXCPT, ZYPP_EX_CODELOCATION )
+ /** Drops a logline and returns Exception as a std::exception_ptr. */
+#define ZYPP_EXCPT_PTR(EXCPT)\
+ ::zypp::exception_detail::do_ZYPP_EXCPT_PTR( EXCPT, ZYPP_EX_CODELOCATION )
+
/** Drops a logline telling the Exception was caught (in order to handle it). */
#define ZYPP_CAUGHT(EXCPT)\
::zypp::exception_detail::do_ZYPP_CAUGHT( EXCPT, ZYPP_EX_CODELOCATION )
--- /dev/null
+#include "gzstream.h"
--- /dev/null
+#include "inputstream.h"
--- /dev/null
+#include "providenumericid.h"
--- /dev/null
+#include "simplestreambuf.h"
--- /dev/null
+#include "userrequestexception.h"
--- /dev/null
+#include "zckstream.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/DefaultIntegral.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_DEFAULTINTEGRAL_H
+#define ZYPP_CORE_BASE_DEFAULTINTEGRAL_H
+
+#include <iosfwd>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_integral.hpp>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : DefaultIntegral<Tp,TInitial>
+ //
+ /** Integral type with defined initial value when default constructed.
+ *
+ * \code
+ * typedef DefaultIntegral<unsigned,0> Counter;
+ * std::map<KeyType,Counter> stats;
+ * for ( all keys )
+ * ++(stats[key]);
+ * \endcode
+ *
+ * \todo maybe specialize for bool, add logical and bit operators
+ * \todo let TInitial default to 0 then remove base/Counter.h
+ */
+ template<class Tp, Tp TInitial>
+ class DefaultIntegral
+ {
+ public:
+ typedef Tp value_type;
+
+ public:
+ DefaultIntegral( Tp val_r = TInitial )
+ : _val( val_r )
+ { BOOST_STATIC_ASSERT(boost::is_integral<Tp>::value); }
+
+ /** Conversion to Tp. */
+ //@{
+ Tp & get() { return _val; }
+ Tp get() const { return _val; }
+
+ operator Tp &() { return get(); }
+ operator Tp () const { return get(); }
+ //@}
+
+ /** The initial value. */
+ constexpr Tp initial() const { return TInitial; }
+
+ /** Reset to the defined initial value. */
+ DefaultIntegral & reset() { _val = TInitial; return *this; }
+
+ /** \name Arithmetic operations.
+ * \c + \c - \c * \c / are provided via conversion to Tp.
+ */
+ //@{
+ DefaultIntegral & operator=( Tp rhs ) { _val = rhs; return *this; }
+ DefaultIntegral & operator+=( Tp rhs ) { _val += rhs; return *this; }
+ DefaultIntegral & operator-=( Tp rhs ) { _val -= rhs; return *this; }
+ DefaultIntegral & operator*=( Tp rhs ) { _val *= rhs; return *this; }
+ DefaultIntegral & operator/=( Tp rhs ) { _val /= rhs; return *this; }
+
+ DefaultIntegral & operator++(/*prefix*/) { ++_val; return *this; }
+ DefaultIntegral & operator--(/*prefix*/) { --_val; return *this; }
+
+ DefaultIntegral operator++(int/*postfix*/) { return _val++; }
+ DefaultIntegral operator--(int/*postfix*/) { return _val--; }
+ //@}
+
+ private:
+ Tp _val;
+ };
+
+ /** \relates DefaultIntegral \c true initialized \c bool */
+ typedef DefaultIntegral<bool,true> TrueBool;
+
+ /** \relates DefaultIntegral \c false initialized \c bool */
+ typedef DefaultIntegral<bool,false> FalseBool;
+
+ /** \relates DefaultIntegral \c zero initialized \c integral */
+ template<typename TIntegral>
+ using ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>;
+
+ template<class Tp, Tp TInitial>
+ std::string asString( const DefaultIntegral<Tp,TInitial> & obj )
+ { return asString( obj.get() ); }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_DEFAULTINTEGRAL_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/DtorReset.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_DTORRESET_H
+#define ZYPP_CORE_BASE_DTORRESET_H
+
+#include <zypp-core/base/PtrTypes.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : DtorReset
+ //
+ /** Assign a vaiable a certain value when going out of scope.
+ * Use it e.g. to reset/cleanup in presence of exceptions.
+ * \code
+ * struct Foo
+ * {
+ * void consume()
+ * {
+ * DtorReset x(_inConsume,false);
+ * _inConsume = true;
+ * MIL << _inConsume << endl;
+ * };
+ *
+ * DefaultIntegral<bool,false> _inConsume;
+ * };
+ *
+ * Foo f;
+ * MIL << f._inConsume << endl; // 0
+ * f.consume(); // 1
+ * MIL << f._inConsume << endl; // 0
+ * \endcode
+ * \ingroup g_RAII
+ * \todo Check if using call_traits enables 'DtorReset(std::string,"value")',
+ * as this currently would require assignment of 'char[]'.
+ */
+ class DtorReset
+ {
+ public:
+ DtorReset() {}
+
+ template<class TVar>
+ DtorReset( TVar & var_r )
+ : _pimpl( new Impl<TVar,TVar>( var_r, var_r ) )
+ {}
+ template<class TVar, class TVal>
+ DtorReset( TVar & var_r, const TVal & val_r )
+ : _pimpl( new Impl<TVar,TVal>( var_r, val_r ) )
+ {}
+
+ private:
+ /** Requires TVal being copy constructible, and assignment
+ * <tt>TVar = TVal</tt> defined. */
+ template<class TVar, class TVal>
+ struct Impl
+ {
+ Impl( TVar & var_r, const TVal & val_r )
+ : _var( var_r )
+ , _val( val_r )
+ {}
+ ~Impl()
+ { _var = _val; }
+ TVar & _var;
+ TVal _val;
+ };
+ shared_ptr<void> _pimpl;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_DTORRESET_H
--- /dev/null
+#include "fxstream.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+#ifndef ZYPP_CORE_BASE_FXSTREAM_H
+#define ZYPP_CORE_BASE_FXSTREAM_H
+
+#include <iosfwd>
+#include <iostream>
+
+namespace zypp {
+ namespace detail {
+ /**
+ * @short Common template to define ifgzstream/ofgzstream
+ * reading/writing compressed files.
+ *
+ * Don't use fXstream directly, but @ref ifgzstream or
+ * @ref ofgzstream. fXstream is just to avoid almost
+ * duplicate code.
+ **/
+ template<class TBStream,class TStreamBuf>
+ class fXstream : public TBStream
+ {
+ public:
+
+ using ZlibError = typename TStreamBuf::error_type;
+ using stream_type = TBStream;
+ using streambuf_type = TStreamBuf;
+
+ fXstream()
+ : stream_type( nullptr )
+ { this->init( &_streambuf ); }
+
+ explicit
+ fXstream( const char * file_r )
+ : stream_type( nullptr )
+ { this->init( &_streambuf ); this->open( file_r ); }
+
+ virtual
+ ~fXstream()
+ {}
+
+ bool
+ is_open() const
+ { return _streambuf.isOpen(); }
+
+ void
+ open( const char * file_r )
+ {
+ if ( !_streambuf.open( file_r, defMode(*this) ) )
+ this->setstate(std::ios_base::failbit);
+ else
+ this->clear();
+ }
+
+ void
+ close()
+ {
+ if ( !_streambuf.close() )
+ this->setstate(std::ios_base::failbit);
+ }
+
+ /**
+ * The last error returned retuned from zlib.
+ **/
+ ZlibError
+ zError() const
+ { return _streambuf.error(); }
+
+ //! Similar to ios::rdbuf.
+ //! But it returns our specific type, not the generic streambuf *.
+ const streambuf_type&
+ getbuf() const
+ { return _streambuf; }
+
+ private:
+
+ streambuf_type _streambuf;
+
+ std::ios_base::openmode
+ defMode( const std::istream & )
+ { return std::ios_base::in; }
+
+ std::ios_base::openmode
+ defMode( const std::ostream & )
+ { return std::ios_base::out; }
+
+ };
+ }
+}
+
+#endif
#include <cerrno>
#include <iostream>
-#include <zypp/base/LogControl.h>
-#include <zypp/base/LogTools.h>
+#include <zypp-core/base/LogControl.h>
+#include <zypp-core/base/LogTools.h>
using std::endl;
-#include <zypp/base/GzStream.h>
+#include <zypp-core/base/GzStream>
#include <sys/types.h>
#include <sys/stat.h>
--- /dev/null
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE Linux Products GmbH |
+\----------------------------------------------------------------------/
+
+ File: GzStream.h
+
+ Author: Michael Andres <ma@suse.de>
+ Maintainer: Michael Andres <ma@suse.de>
+
+ Purpose: Streams reading and writing gzip files.
+
+/-*/
+#ifndef ZYPP_CORE_BASE_GZSTREAM_H
+#define ZYPP_CORE_BASE_GZSTREAM_H
+
+#include <iosfwd>
+#include <streambuf>
+#include <vector>
+#include <zlib.h>
+
+#include <zypp-core/base/SimpleStreambuf>
+#include <zypp-core/base/fXstream>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ namespace gzstream_detail
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ZlibError
+ /**
+ * @short Helper class to ship zlib errors.
+ **/
+ struct ZlibError
+ {
+ /**
+ * The zlib error code
+ **/
+ int _zError;
+
+ /**
+ * errno, valid if zError is Z_ERRNO
+ **/
+ int _errno;
+
+ ZlibError()
+ : _zError( 0 ), _errno( 0 )
+ {}
+
+ /**
+ * Return string describing the zlib error code
+ **/
+ std::string
+ strerror() const;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates ZlibError Stream output. */
+ inline std::ostream & operator<<( std::ostream & str, const ZlibError & obj )
+ { return str << obj.strerror(); }
+
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : gzstreambufimpl
+ /**
+ * @short Streambuffer reading or writing gzip files.
+ *
+ * Read and write mode are mutual exclusive. Seek is supported,
+ * but zlib restrictions appy (only forward seek in write mode;
+ * backward seek in read mode might be expensive).Putback is not
+ * supported.
+ *
+ * Reading plain (no gziped) files is possible as well.
+ *
+ * This streambuf is used in @ref ifgzstream and @ref ofgzstream.
+ **/
+ class gzstreambufimpl {
+ public:
+
+ using error_type = ZlibError;
+
+ ~gzstreambufimpl()
+ { closeImpl(); }
+
+ bool
+ isOpen () const
+ { return _file; }
+
+ bool
+ canRead () const
+ { return( _mode == std::ios_base::in ); }
+
+ bool
+ canWrite () const
+ { return( _mode == std::ios_base::out ); }
+
+ bool
+ canSeek ( std::ios_base::seekdir way_r ) const
+ { return ( way_r == std::ios_base::beg || way_r == std::ios_base::cur ); }
+
+ protected:
+ bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
+ bool closeImpl ();
+
+ //! Tell the file position in the compressed file.
+ //! Analogous to tell(2), complementary to gztell.
+ off_t compressed_tell() const;
+
+ public:
+ /**
+ * The last error returned fron zlib.
+ **/
+ error_type
+ error() const
+ { return _error; }
+
+ std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r );
+ bool writeData( const char * buffer_r, std::streamsize count_r );
+ off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
+ off_t tell() const;
+
+ private:
+
+ void
+ setZError() const
+ { gzerror( _file, &_error._zError ); }
+
+ //! file descriptor of the compressed file
+ int _fd = -1;
+
+ gzFile _file = nullptr;
+
+ std::ios_base::openmode _mode = std::ios_base::openmode(0);
+
+ mutable ZlibError _error;
+
+ };
+ using fgzstreambuf = detail::SimpleStreamBuf<gzstreambufimpl>;
+ } // namespace gzstream_detail
+
+ /**
+ * istream reading gzip files as well as plain files.
+ **/
+ typedef detail::fXstream<std::istream,gzstream_detail::fgzstreambuf> ifgzstream;
+
+ /**
+ * ostream writing gzip files.
+ **/
+ typedef detail::fXstream<std::ostream,gzstream_detail::fgzstreambuf> ofgzstream;
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+#endif // ZYPP_CORE_BASE_GZSTREAM_H
*
*/
#include <iostream>
-#include <zypp/base/LogTools.h>
+#include <zypp-core/base/LogTools.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/GzStream.h>
+#include "inputstream.h"
+#include <zypp-core/base/GzStream>
#ifdef ENABLE_ZCHUNK_COMPRESSION
- #include <zypp/base/ZckStream.h>
+ #include <zypp-core/base/ZckStream>
#endif
-#include <zypp/PathInfo.h>
+#include <zypp-core/fs/PathInfo.h>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/InputStream.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_INPUTSTREAM_H
+#define ZYPP_CORE_BASE_INPUTSTREAM_H
+
+#include <iosfwd>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/base/DefaultIntegral>
+#include <zypp-core/Pathname.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : InputStream
+ //
+ /** Helper to create and pass std::istream.
+ * The provided std::istream may either be std::cin,
+ * sone (gziped) file or an aleady existig \c std::istream.
+ *
+ * An optional \c name arument may be passed to the ctor,
+ * to identify the stream in log messages, even if it is
+ * not a file.
+ *
+ * Per default the name is "STDIN", the path to an input file
+ * or empty.
+ *
+ * \code
+ * void parse( const InputStream & input = InputStream() )
+ * {
+ * // process input.stream() and refer to input.name()
+ * // in log messages.
+ * }
+ *
+ * parse(); // std::cin
+ * parse( "/some/file" ); // file
+ * parse( "/some/file.gz" ); // gziped file
+ * std::istream & mystream;
+ * parse( mystream ); // some existing stream
+ * parse( InputStream( mystream,
+ * "my stream's name" ) );
+ * \endcode
+ */
+ class InputStream
+ {
+ public:
+ /** Default ctor providing \c std::cin. */
+ InputStream();
+
+ /** Ctor providing an aleady existig \c std::istream. */
+ InputStream( std::istream & stream_r,
+ const std::string & name_r = std::string() );
+
+ /** Ctor for reading a (gziped) file. */
+ InputStream( const Pathname & file_r );
+
+ /** Ctor for reading a (gziped) file. */
+ InputStream( const Pathname & file_r,
+ const std::string & name_r );
+
+ /** Ctor for reading a (gziped) file. */
+ InputStream( const std::string & file_r );
+
+ /** Ctor for reading a (gziped) file. */
+ InputStream( const std::string & file_r,
+ const std::string & name_r );
+
+ /** Ctor for reading a (gziped) file. */
+ InputStream( const char * file_r );
+
+ /** Ctor for reading a (gziped) file. */
+ InputStream( const char * file_r,
+ const std::string & name_r );
+
+ /** Dtor. */
+ ~InputStream();
+
+ /** The std::istream.
+ * \note The provided std::istream is never \c const.
+ */
+ std::istream & stream() const
+ { return *_stream; }
+
+ /** Allow implicit conversion to std::istream.*/
+ operator std::istream &() const
+ { return *_stream; }
+
+ /** Name of the std::istream.
+ * Per default this is "STDIN", the path to an input file or
+ * empty. A custom string may be provided to the ctor.
+ *
+ * This may be used in log messages to identify the stream even
+ * even if it is not a file.
+ */
+ const std::string & name() const
+ { return _name; }
+
+ /** Path to the input file or empty if no file. */
+ const Pathname & path() const
+ { return _path; }
+
+ /** Size of the input stream (informal).
+ * If constructed from an uncompressed file, the file size.
+ * Otherwise \c -1. See \ref setSize;
+ */
+ std::streamoff size() const
+ { return _size; }
+
+ /** Set the size of the input stream.
+ * You may set it to whatever vaule is appropriate. E.g.
+ * <tt>*=10</tt> to compensate gzip comression. or the
+ * number of items, lines, ... The value is not used here,
+ * just provided.
+ */
+ void setSize( std::streamoff val_r )
+ { _size = val_r; }
+
+ private:
+ Pathname _path;
+ shared_ptr<std::istream> _stream;
+ std::string _name;
+ DefaultIntegral<std::streamoff,-1> _size;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates InputStream Stream output */
+ std::ostream & operator<<( std::ostream & str, const InputStream & obj );
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_INPUTSTREAM_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/base/ProvideNumericId
+ *
+*/
+#ifndef ZYPP_CORE_BASE_PROVIDENUMERICID_H
+#define ZYPP_CORE_BASE_PROVIDENUMERICID_H
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace base
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ProvideNumericId
+ //
+ /** Base class for objects providing a numeric Id.
+ * The ctor creates a NumericId from some static counter.
+ *
+ * The only assertion is that \c 0 is not used as an Id,
+ * \b unless the derived class explicitly requests this by
+ * using \ref ProvideNumericId( const void *const ).
+ *
+ * Why should you want to use \c 0 as an Id? E.g if your class
+ * provides some (singleton) No-object. Might be desirable to
+ * make the No-object have No-Id.
+ *
+ * \code
+ * struct Foo : public base::ProvideNumericId<Foo,unsigned>
+ * {};
+ * Foo foo;
+ * foo.numericId(); // returns foo's NumericId.
+ * \endcode
+ */
+ template<class TDerived, class TNumericIdType>
+ struct ProvideNumericId
+ {
+ public:
+ /** \return The objects numeric Id. */
+ TNumericIdType numericId() const
+ { return _numericId; }
+
+ protected:
+ /** Default ctor */
+ ProvideNumericId()
+ : _numericId( nextId() )
+ {}
+ /** Copy ctor */
+ ProvideNumericId( const ProvideNumericId & /*rhs*/ )
+ : _numericId( nextId() )
+ {}
+ /** Assign */
+ ProvideNumericId & operator=( const ProvideNumericId & /*rhs*/ )
+ { return *this; }
+ /** Move ctor */
+ ProvideNumericId( ProvideNumericId && rhs )
+ : _numericId( rhs._numericId )
+ { /*rhs._numericId = 0;*/ }
+ /** Move Assign */
+ ProvideNumericId & operator=( ProvideNumericId && rhs )
+ { if ( &rhs != this ) { _numericId = rhs._numericId; /*rhs._numericId = 0;*/ } return *this; }
+ /** Dtor */
+ ~ProvideNumericId()
+ {}
+ protected:
+ /** No-Id ctor (0).
+ * Explicitly request Id \c 0. Use it with care!
+ */
+ ProvideNumericId( const void *const )
+ : _numericId( 0 )
+ {}
+ private:
+ /** Provide the next Id to use. */
+ static TNumericIdType nextId()
+ {
+ static TNumericIdType _staticCounter = 0;
+ // Assert not returning 0
+ return ++_staticCounter;
+ }
+ /** */
+ const TNumericIdType _numericId;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace base
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_PROVIDENUMERICID_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/SimpleStreambuf.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_SIMPLESTREAMBUF_H_DEFINED
+#define ZYPP_CORE_BASE_SIMPLESTREAMBUF_H_DEFINED
+
+#include <streambuf>
+#include <vector>
+
+namespace zypp {
+ namespace detail {
+
+ /*!
+ * Implementation of a std::streambuf that is using a std::vector<char> as buffer,
+ * relies on a Impl class that must implement the basic i/o functionality:
+ *
+ * \code
+ * class streambufimpl {
+ * public:
+ * using error_type = my_error_type;
+ *
+ * ~streambufimpl();
+ *
+ * bool isOpen () const; // returns true if the file is currently open
+ * bool canRead () const; // returns true if in read mode
+ * bool canWrite () const; // returns true if in write mode
+ * bool canSeek ( std::ios_base::seekdir way_r ) const; // returns true if the backend can seek in the given way
+ *
+ * std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r ); // reads data from the file and returns it in buffer_r
+ * bool writeData( const char * buffer_r, std::streamsize count_r ); // writes data ( if in write mode ) to file from buffer
+ * off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); // seeks in file if supported
+ * off_t tell() const; // returns the current FP
+ *
+ * error_type error() const; // returns the last error that happend in backend
+ *
+ * protected:
+ * bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); // backend implementation of opening the file
+ * bool closeImpl (); // closes the file
+ * };
+ * using FullStreamBuf = detail::SimpleStreamBuf<streambufimpl>;
+ * \endcode
+ *
+ * \note Currently only supports reading or writing at the same time, but can be extended to support both
+ */
+ template<typename Impl>
+ class SimpleStreamBuf : public std::streambuf, public Impl
+ {
+
+ public:
+
+ SimpleStreamBuf( size_t bufsize_r = 512) : _buffer( bufsize_r ) { }
+ virtual ~SimpleStreamBuf() { close(); }
+
+ SimpleStreamBuf * open( const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in ) {
+
+ if ( !this->openImpl( name_r, mode_r ) )
+ return nullptr;
+
+ if ( this->canRead() ) {
+ setp( NULL, NULL );
+ setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+ } else {
+ setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
+ setg( NULL, NULL, NULL );
+ }
+
+ return this;
+ }
+
+ SimpleStreamBuf * close() {
+
+ if ( !this->isOpen() )
+ return nullptr;
+
+ if ( this->canWrite() )
+ sync();
+
+ if ( !this->closeImpl() )
+ return nullptr;
+
+ return this;
+ }
+
+ protected:
+
+ virtual int sync() {
+ int ret = 0;
+ if ( pbase() < pptr() ) {
+ const int_type res = overflow();
+ if ( traits_type::eq_int_type( res, traits_type::eof() ) )
+ ret = -1;
+ }
+ return ret;
+ }
+
+ virtual int_type overflow( int_type c = traits_type::eof() ) {
+ int_type ret = traits_type::eof();
+ if ( this->canWrite() ) {
+ if ( ! traits_type::eq_int_type( c, traits_type::eof() ) )
+ {
+ *pptr() = traits_type::to_char_type( c );
+ pbump(1);
+ }
+ if ( pbase() <= pptr() )
+ {
+ if ( this->writeData( pbase(), pptr() - pbase() ) )
+ {
+ setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
+ ret = traits_type::not_eof( c );
+ }
+ // else: error writing the file
+ }
+ }
+ return ret;
+ }
+
+ virtual int_type underflow() {
+ int_type ret = traits_type::eof();
+ if ( this->canRead() )
+ {
+ if ( gptr() < egptr() )
+ return traits_type::to_int_type( *gptr() );
+
+ const std::streamsize got = this->readData( &(_buffer[0]), _buffer.size() );
+ if ( got > 0 )
+ {
+ setg( &(_buffer[0]), &(_buffer[0]), &(_buffer.data()[got]) );
+ ret = traits_type::to_int_type( *gptr() );
+ }
+ else if ( got == 0 )
+ {
+ // EOF
+ setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+ }
+ // else: error reading the file
+ }
+ return ret;
+ }
+
+ virtual pos_type seekpos( pos_type pos_r, std::ios_base::openmode openMode ) {
+ return seekoff( off_type(pos_r), std::ios_base::beg, openMode );
+ }
+
+
+ virtual pos_type seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode openMode ) {
+ pos_type ret = pos_type(off_type(-1));
+ if ( !this->canSeek( way_r) )
+ return ret;
+
+ if ( this->isOpen() ) {
+ if ( openMode == std::ios_base::out ) {
+ //write the buffer out and invalidate it , no need to keep it around
+ if ( !this->canWrite() || sync() != 0 )
+ return ret;
+
+ ret = this->seekTo( off_r, way_r, openMode );
+
+ } else if ( openMode == std::ios_base::in ) {
+ if ( !this->canRead() )
+ return ret;
+
+ //current physical FP, should point to end of buffer
+ const off_type buffEndOff = this->tell();
+
+ if ( buffEndOff != off_type(-1) ) {
+ if ( way_r == std::ios_base::end ) {
+ setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+ ret = this->seekTo( off_r, way_r, openMode );
+ }
+
+ const off_type bufLen = egptr() - eback();
+ const off_type bufStartFileOff = buffEndOff - bufLen;
+ const off_type currPtrFileOffset = buffEndOff - ( egptr() - gptr() );
+ off_type newFOff = off_r;
+
+ // Transform into ios_base::beg and seek.
+ if ( way_r == std::ios_base::cur ) {
+ newFOff += currPtrFileOffset;
+ way_r = std::ios_base::beg;
+ }
+
+ //check if a seek would go out of the buffers boundaries
+ if ( way_r == std::ios_base::beg ) {
+ if ( bufStartFileOff <= newFOff && newFOff <= buffEndOff ) {
+ // Still inside buffer, adjust gptr and
+ // calculate new position.
+ setg( eback(),
+ eback() + ( newFOff - bufStartFileOff ),
+ egptr() );
+ ret = pos_type( newFOff );
+ } else {
+ // Invalidate buffer and seek.
+ setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+ ret = this->seekTo( off_r, way_r, openMode );
+ }
+ }
+ }
+ }
+ }
+ return ret;
+ }
+
+ private:
+ typedef std::vector<char> buffer_type;
+ buffer_type _buffer;
+ };
+ }
+}
+#endif
#include <iostream>
//#include <zypp/base/Logger.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/base/UserRequestException
+ *
+*/
+#ifndef ZYPP_CORE_BASE_USERREQUESTEXCEPTION_H
+#define ZYPP_CORE_BASE_USERREQUESTEXCEPTION_H
+
+#include <iosfwd>
+
+#include <zypp/base/Exception.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : UserRequestException
+ //
+ /** Base for exceptions caused by explicit user request.
+ *
+ * Use the derived convenience classes to throw exceptions
+ * of a certain kind.
+ * \code
+ * ProgressData ticks( makeProgressData( input_r ) );
+ * ticks.sendTo( fnc_r );
+ * ticks.toMin(); // start sending min (0)
+ *
+ * iostr::EachLine line( input_r );
+ * for( ; line; line.next() )
+ * {
+ * // process the line
+ *
+ * if ( ! ticks.set( input_r.stream().tellg() ) )
+ * ZYPP_THROW( AbortRequestException( "" ) );
+ * }
+ * \endcode
+ * \code
+ * // either this way
+ * catch ( const AbortRequestException & excpt_r )
+ * {
+ * ...
+ * }
+ *
+ * // or that
+ * catch ( const UserRequestException & excpt_r )
+ * {
+ * switch ( excpt_r.kind() )
+ * {
+ * case UserRequestException::ABORT:
+ * ...
+ * break;
+ * }
+ * }
+ * \endcode
+ */
+ class UserRequestException : public Exception
+ {
+ public:
+ enum Kind { UNSPECIFIED, IGNORE, SKIP, RETRY, ABORT };
+ public:
+ explicit
+ UserRequestException( const std::string & msg_r = std::string() );
+ UserRequestException( const std::string & msg_r, const Exception & history_r );
+ explicit
+ UserRequestException( Kind kind_r, const std::string & msg_r = std::string() );
+ UserRequestException( Kind kind_r, const std::string & msg_r, const Exception & history_r );
+ public:
+ Kind kind() const
+ { return _kind; }
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ Kind _kind;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** Convenience macro to declare more specific PluginScriptExceptions. */
+#define declException( EXCP, KIND ) \
+ struct EXCP : public UserRequestException { \
+ explicit \
+ EXCP( const std::string & msg_r = std::string() ) \
+ : UserRequestException( KIND, msg_r ) \
+ {} \
+ EXCP( const std::string & msg_r, const Exception & history_r ) \
+ : UserRequestException( KIND, msg_r, history_r ) \
+ {} \
+ }
+
+ declException( IgnoreRequestException, IGNORE );
+ declException( SkipRequestException, SKIP );
+ declException( RetryRequestException, RETRY );
+ declException( AbortRequestException, ABORT );
+
+#undef declException
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_USERREQUESTEXCEPTION_H
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-#include <zypp/base/ZckStream.h>
-#include <zypp/base/String.h>
+#include "zckstream.h"
+#include <zypp-core/base/String.h>
#include <sys/types.h>
#include <sys/stat.h>
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+#ifndef ZYPP_CORE_BASE_ZCKSTREAM_H
+#define ZYPP_CORE_BASE_ZCKSTREAM_H
+
+#include <iosfwd>
+#include <streambuf>
+#include <vector>
+#include <zypp-core/base/SimpleStreambuf>
+#include <zypp-core/base/fXstream>
+
+typedef struct zckCtx zckCtx;
+
+namespace zypp {
+
+ namespace detail {
+
+ /**
+ * @short Streambuffer reading or writing zchunk files.
+ *
+ * Read and write mode are mutual exclusive. Seek is not supported.
+ *
+ * This streambuf is used in @ref ifzckstream and @ref ofzckstream.
+ **/
+ class zckstreambufimpl {
+ public:
+
+ using error_type = std::string;
+
+ ~zckstreambufimpl();
+
+ bool isOpen () const;
+ bool canRead () const;
+ bool canWrite () const;
+ bool canSeek ( std::ios_base::seekdir way_r ) const;
+
+ std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r );
+ bool writeData( const char * buffer_r, std::streamsize count_r );
+ off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
+ off_t tell() const;
+
+ error_type error() const { return _lastErr; }
+
+ protected:
+ bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
+ bool closeImpl ();
+
+ private:
+ void setError ();
+ int _fd = -1;
+ bool _isReading = false;
+ zckCtx *_zContext = nullptr;
+ off_t _currfp = 0;
+ error_type _lastErr;
+
+ };
+ using ZChunkStreamBuf = detail::SimpleStreamBuf<detail::zckstreambufimpl>;
+ }
+
+ /**
+ * istream reading zchunk files.
+ **/
+ using ifzckstream = detail::fXstream<std::istream,detail::ZChunkStreamBuf>;
+
+ /**
+ * ostream writing zchunk files.
+ **/
+ using ofzckstream = detail::fXstream<std::ostream,detail::ZChunkStreamBuf>;
+}
+
+#endif
--- /dev/null
+#include "watchfile.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/fs/WatchFile
+ *
+*/
+#ifndef ZYPP_CORE_FS_WATCHFILE_H
+#define ZYPP_CORE_FS_WATCHFILE_H
+
+#include <iosfwd>
+
+#include <zypp/PathInfo.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : WatchFile
+ //
+ /** Remember a files attributes to detect content changes.
+ *
+ * Repeatedly call \ref hasChanged to check whether the content has
+ * changed since the last call. Creation or deletion of the file will
+ * be reported as change as well.
+ *
+ * Per default the ctor stats the file, so \ref hasChanged will detect
+ * changes done after \ref WatchFile was created.
+ *
+ * You may omit the initial stat by passing \c NO_INIT as second argument
+ * to the ctor. \ref WatchFile will behave as if the file did not exist
+ * at the time \ref WatchFile was created.
+ *
+ * \code
+ * static WatchFile sysconfigFile( "/etc/sysconfig/SuSEfirewall2",
+ * WatchFile::NO_INIT );
+ * if ( sysconfigFile.hasChanged() )
+ * {
+ * // reload the file...
+ * }
+ * \endcode
+ */
+ class WatchFile
+ {
+ public:
+ enum Initial { NO_INIT, INIT };
+
+ public:
+ /** */
+ WatchFile( const Pathname & path_r = Pathname(),
+ Initial mode = INIT )
+ : _path( path_r )
+ {
+ PathInfo pi( mode == INIT ? path_r : Pathname() );
+ _size = pi.size();
+ _mtime = pi.mtime();
+ }
+
+ const Pathname & path() const
+ { return _path; }
+
+ off_t lastSize() const
+ { return _size;}
+
+ time_t lastMtime() const
+ { return _mtime; }
+
+ bool isDirty() const
+ {
+ PathInfo pi( _path );
+ return( _size != pi.size() || _mtime != pi.mtime() );
+ }
+
+ bool hasChanged()
+ {
+ PathInfo pi( _path );
+ if ( _size != pi.size() || _mtime != pi.mtime() )
+ {
+ _size = pi.size();
+ _mtime = pi.mtime();
+ return true;
+ }
+ return false;
+ }
+
+ private:
+ Pathname _path;
+ off_t _size;
+ time_t _mtime;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_FS_WATCHFILE_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\----------------------------------------------------------------------/
+
+ File: KVMap.h
+
+ Author: Michael Andres <ma@suse.de>
+ Maintainer: Michael Andres <ma@suse.de>
+
+ Purpose: Convenience stuff for handling (key,value) pairs
+
+*/
+#ifndef KVMap_h
+#define KVMap_h
+
+#include <iosfwd>
+#include <vector>
+#include <map>
+
+#include <zypp/base/String.h>
+
+namespace zypp {
+ namespace kvmap {
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : KVMapBase::KVMapPolicy
+ /**
+ * @short KVMapPolicy for conversion of KVMaps to/from string.
+ *
+ * <b>_kvsplit</b>: The string separating key from value
+ *
+ * <b>_fsplit</b>: (key,value) pairs are separated by any nonempty
+ * sequence of characers occurring in _fsplit
+ *
+ * <b>_kvjoin</b>: The string used to join key and value.
+ *
+ * <b>_fjoin</b>: The string used to separate (key,value) pairs.
+ *
+ * TODO: Maybe options for exact _fsplit handling and timming of values.
+ *
+ **/
+ struct KVMapPolicy {
+ std::string _kvsplit;
+ std::string _fsplit;
+ std::string _kvjoin;
+ std::string _fjoin;
+ KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r )
+ : _kvsplit( kvsplit_r )
+ , _fsplit ( fsplit_r )
+ , _kvjoin ( _kvsplit )
+ , _fjoin ( _fsplit )
+ {}
+ KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
+ const std::string & kvjoin_r )
+ : _kvsplit( kvsplit_r )
+ , _fsplit ( fsplit_r )
+ , _kvjoin ( kvjoin_r )
+ , _fjoin ( _fsplit )
+ {}
+ KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
+ const std::string & kvjoin_r, const std::string & fjoin_r )
+ : _kvsplit( kvsplit_r )
+ , _fsplit ( fsplit_r )
+ , _kvjoin ( kvjoin_r )
+ , _fjoin ( fjoin_r )
+ {}
+ };
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : KVMapBase
+ /**
+ * @short Base class for KVMaps, (key,value) pairs
+ **/
+ struct KVMapBase : public std::map<std::string,std::string> {
+
+ /**
+ * (key,value) map type
+ **/
+ typedef std::map<std::string,std::string> map_type;
+
+ KVMapBase()
+ {}
+ KVMapBase( const map_type & kvmap_r )
+ : std::map<std::string,std::string>( kvmap_r )
+ {}
+
+ /**
+ * Test whether key is set.
+ **/
+ bool has( const std::string & key_r ) const {
+ return( find( key_r ) != end() );
+ }
+
+ /**
+ * @short KVMapPolicy for KVMaps using a single char as separator (e.g. mount options).
+ **/
+ template<char kv, char f>
+ struct CharSep : public KVMapPolicy { CharSep() : KVMapPolicy( std::string(1,kv), std::string(1,f) ) {} };
+
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * Split str_r into (key,value) map, using the separators defined
+ * by opts_r.
+ **/
+ static map_type split( const std::string & str_r,
+ const KVMapPolicy & opts_r ) {
+ map_type ret;
+ std::vector<std::string> fields;
+ str::split( str_r, std::back_inserter(fields), opts_r._fsplit );
+
+ for ( unsigned i = 0; i < fields.size(); ++i ) {
+ std::string::size_type pos = fields[i].find( opts_r._kvsplit );
+ if ( pos == std::string::npos ) {
+ ret[fields[i]] = "";
+ } else {
+ ret[fields[i].substr( 0, pos )] = fields[i].substr( pos+1 );
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * Join (key,value) map into string, using the separators defined
+ * by opts_r.
+ **/
+ static std::string join( const map_type & kvmap_r,
+ const KVMapPolicy & opts_r ) {
+ std::string ret;
+
+ for ( map_type::const_iterator it = kvmap_r.begin(); it != kvmap_r.end(); ++it ) {
+ if ( ! ret.empty() ) {
+ ret += opts_r._fjoin;
+ }
+ ret += it->first;
+ if ( !it->second.empty() ) {
+ ret += opts_r._kvjoin + it->second;
+ }
+ }
+
+ return ret;
+ }
+
+ };
+
+
+
+ } // namespace kvmap
+
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : KVMap<KVMapOpts>
+ /**
+ * @short A map of (key,value) strings.
+ *
+ * The template argument defines the @ref kvmap::Options for
+ * split and join.
+ *
+ * E.g. mount options (a comma separated list of key[=value] pairs)
+ * could be handled by KVMap<kvmap::KVMapBase::Comma>.
+ **/
+ template<typename KVMapOpts>
+ struct KVMap : public kvmap::KVMapBase {
+
+ KVMap()
+ {}
+ KVMap( const char * str_r )
+ : kvmap::KVMapBase( split( (str_r?str_r:""), KVMapOpts() ) )
+ {}
+ KVMap( const std::string & str_r )
+ : kvmap::KVMapBase( split( str_r, KVMapOpts() ) )
+ {}
+ KVMap( const map_type & map_r )
+ : kvmap::KVMapBase( map_r )
+ {}
+
+ ~KVMap() {}
+
+ std::string asString() const {
+ return join( *this, KVMapOpts() );
+ }
+
+ };
+
+ ///////////////////////////////////////////////////////////////////
+
+ template<typename KVMapOpts>
+ std::ostream & operator<<( std::ostream & str, const KVMap<KVMapOpts> & obj )
+ { return str << obj.asString(); }
+
+///////////////////////////////////////////////////////////////////
+} // namespace zypp
+
+#endif // KVMap_h
#include <iostream>
//#include <zypp/base/Logger.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/OnMediaLocation.h
+ */
+#ifndef ZYPP_SOURCE_ONMEDIALOCATION_H
+#define ZYPP_SOURCE_ONMEDIALOCATION_H
+
+#include <iosfwd>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/ByteCount.h>
+#include <zypp-core/CheckSum.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{
+ ///////////////////////////////////////////////////////////////////
+ /// \class OnMediaLocation
+ /// \brief Describes a resource file located on a medium.
+ ///
+ /// Holds the path of a resource on a medium and contains additional
+ /// info required to retrieve and verify it (like media number,
+ /// checksum, size,...)
+ ///
+ /// It does not specify the \ref Url of the medium itself.
+ ///
+ /// Media number \c 0 usually indicates no media access.
+ ///////////////////////////////////////////////////////////////////
+ class OnMediaLocation
+ {
+ friend std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
+ friend std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj );
+
+ public:
+ /** Default Ctor indicating no media access. */
+ OnMediaLocation();
+
+ /** Ctor taking a \a filename_r and \a medianr_r (defaults to \c 1). */
+ OnMediaLocation( Pathname filename_r, unsigned medianr_r = 1 );
+
+ /** Dtor */
+ ~OnMediaLocation();
+
+ public:
+ /** The path to the resource on the medium. */
+ const Pathname & filename() const;
+
+ /** The media number the resource is located on. */
+ unsigned medianr() const;
+
+
+ /** Set \a filename_r and \a medianr_r (defaults to \c 1). */
+ OnMediaLocation & setLocation( Pathname filename_r, unsigned medianr_r = 1 );
+
+ /** Unset \c filename and set \c medianr to \c 0. */
+ OnMediaLocation & unsetLocation();
+
+
+ /** Individual manipulation of \c filename (prefer \ref setLocation). */
+ OnMediaLocation & changeFilename( Pathname filename_r );
+
+ /** Individual manipulation of \c medianr (prefer \ref setLocation). */
+ OnMediaLocation & changeMedianr( unsigned medianr_r );
+
+ /** Prepend the filename with \a prefix_r */
+ OnMediaLocation & prependPath( const Pathname & prefix_r );
+
+ public:
+ /** Whether this is an optional resource.
+ * This is a hint to the downloader not to report an error if
+ * the resource is not present on the server.
+ */
+ bool optional() const;
+ /** Set whether the resource is \ref optional. */
+ OnMediaLocation & setOptional( bool val );
+
+ public:
+ /** The size of the resource on the server. */
+ const ByteCount & downloadSize() const;
+ /** Set the \ref downloadSize. */
+ OnMediaLocation & setDownloadSize( ByteCount val_r );
+
+ /** The checksum of the resource on the server. */
+ const CheckSum & checksum() const;
+ /** Set the \ref checksum. */
+ OnMediaLocation & setChecksum( CheckSum val_r );
+
+ public:
+ /** The size of the resource once it has been uncompressed or unpacked. */
+ const ByteCount & openSize() const;
+ /** Set the \ref openSize. */
+ OnMediaLocation & setOpenSize( ByteCount val_r );
+
+ /** The checksum of the resource once it has been uncompressed or unpacked. */
+ const CheckSum & openChecksum() const;
+ /** Set the \ref openChecksum. */
+ OnMediaLocation & setOpenChecksum( CheckSum val_r );
+
+ public:
+ /** The size of the header prepending the resource (e.g. for zchunk). */
+ const ByteCount & headerSize() const;
+ /** Set the \ref headerSize. */
+ OnMediaLocation & setHeaderSize( ByteCount val_r );
+
+ /** The checksum of the header prepending the resource (e.g. for zchunk). */
+ const CheckSum & headerChecksum() const;
+ /** Set the \ref headerChecksum. */
+ OnMediaLocation & setHeaderChecksum( CheckSum val_r );
+
+ /** The existing deltafile that can be used to reduce download size ( zchunk or metalink ) */
+ const Pathname & deltafile() const;
+ /** Set the \ref deltafile. */
+ OnMediaLocation & setDeltafile( Pathname path );
+
+
+ public:
+ class Impl; ///< Implementation class.
+ private:
+ RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation.
+ };
+
+ /** \relates OnMediaLocation Stream output */
+ std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
+
+ /** \relates OnMediaLocation Verbose stream output */
+ std::ostream & dumOn( std::ostream & str, const OnMediaLocation & obj );
+
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_ONMEDIALOCATION_H
--- /dev/null
+#include "inidict.h"
--- /dev/null
+#include "iniparser.h"
--- /dev/null
+#include "parseexception.h"
--- /dev/null
+#include "sysconfig.h"
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/parser/IniDict.cc
+/** \file zypp-core/parser/inidict.cc
*
*/
+
+#include "inidict.h"
+
#include <iostream>
-#include <zypp/base/Logger.h>
#include <map>
#include <string>
-#include <zypp/parser/IniDict.h>
+
+#include <zypp-core/base/Logger.h>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/parser/IniDict
+ *
+*/
+#ifndef ZYPP_PARSER_INIDICT_H
+#define ZYPP_PARSER_INIDICT_H
+
+#include <iosfwd>
+#include <map>
+#include <string>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/Iterator.h>
+#include <zypp-core/base/Iterable.h>
+#include <zypp-core/parser/IniParser>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace parser
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : IniDict
+ //
+ /**
+ * Parses a INI file and offers its structure as a
+ * dictionary.
+ *
+ */
+ class IniDict : public IniParser
+ {
+ friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
+ public:
+ typedef std::map<std::string, std::string> EntrySet;
+ typedef std::map<std::string, EntrySet> SectionSet;
+ typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator section_const_iterator;
+ typedef EntrySet::const_iterator entry_const_iterator;
+
+ /**
+ * \name Section Iterators
+ * Iterate trough ini file sections
+ * \code
+ * for ( IniDict::section_const_iterator it = dict.sectionsBegin();
+ * it != dict.sectionsEnd();
+ * ++it )
+ * {
+ * MIL << (*it) << endl;
+ * }
+ * \endcode
+ */
+ //@{
+ section_const_iterator sectionsBegin() const;
+ section_const_iterator sectionsEnd() const;
+ Iterable<section_const_iterator> sections() const;
+ //@}
+
+ /**
+ * \name Entries Iterators
+ * Iterate trough ini file entries in a section
+ * \code
+ * for ( IniDict::entry_const_iterator it = dict.entriesBegin("updates");
+ * it != dict.entriesEnd("updates");
+ * ++it )
+ * {
+ * MIL << (*it).first << endl;
+ * }
+ * \endcode
+ */
+
+ //@{
+ entry_const_iterator entriesBegin(const std::string §ion) const;
+ entry_const_iterator entriesEnd(const std::string §ion) const;
+ Iterable<entry_const_iterator> entries(const std::string §ion) const;
+ //@{
+
+ /**
+ * Creates a dictionary from a InputStream
+ * containing a ini structured file
+ */
+ IniDict( const InputStream &is,
+ const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
+
+ /**
+ * Creates a mepty dictionary
+ */
+ IniDict();
+
+ /** Dtor */
+ ~IniDict();
+
+ /**
+ * Fill a dictionary from a InputStream
+ * containing a ini structured file
+ */
+ void read( const InputStream &is,
+ const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
+
+ /**
+ * \short add an entry
+ * \param section
+ * \param key
+ * \param value
+ */
+ void insertEntry( const std::string §ion,
+ const std::string &key,
+ const std::string &value );
+
+ /**
+ * \short add an entry
+ * \param section
+ * \param key
+ * \param value
+ */
+ void deleteSection( const std::string §ion );
+
+ /**
+ * \short True if there is a section with that name
+ * \param section Section Name
+ */
+ bool hasSection( const std::string §ion ) const;
+
+ /**
+ * \short True if an entry exists in the section
+ * \param section Section name
+ * \param entry entry name
+ *
+ * \note If the given section does not exist, this will
+ * of course return false.
+ */
+ bool hasEntry( const std::string §ion,
+ const std::string &entry ) const;
+ public:
+
+ /** Called when a section is found. */
+ virtual void consume( const std::string §ion );
+ /** Called when a key value is found. */
+ virtual void consume( const std::string §ion,
+ const std::string &key,
+ const std::string &value );
+
+ private:
+ SectionSet _dict;
+ /**
+ * empty map used to simulate
+ * iteration in non existant
+ * sections
+ */
+ EntrySet _empty_map;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates IniDict Stream output */
+ std::ostream & operator<<( std::ostream & str, const IniDict & obj );
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_INIDICT_H
/** \file zypp/parser/IniParser.cc
*
*/
+
+#include "iniparser.h"
+
#include <iostream>
#include <sstream>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/IOStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/IOStream.h>
+#include <zypp-core/base/UserRequestException>
-#include <zypp/parser/ParseException.h>
-#include <zypp/parser/IniParser.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/parser/ParseException>
+#include <zypp-core/ui/ProgressData>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/IniParser.h
+ *
+*/
+#ifndef ZYPP_CORE_PARSER_INIPARSER_H
+#define ZYPP_CORE_PARSER_INIPARSER_H
+
+#include <iosfwd>
+#include <string>
+#include <list>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/ui/ProgressData>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace parser
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+/// \class IniParser
+/// \brief Simple INI-file parser
+///
+/// Lines staring with \c ; or \c # are treated as comment. Section
+/// names are enclosed by <tt>[]</tt>. Key and value are separated by \c =.
+///
+/// Lines without \c = or with a key containing any of "<tt>,|\\/</tt>"
+/// or section lines without closing \c ] are considered garbage.
+///
+class IniParser : private base::NonCopyable
+{
+public:
+ /** Default ctor */
+ IniParser();
+ /** Dtor */
+ virtual ~IniParser();
+ /** Parse the stream.
+ * \throw ParseException on errors. Invoke \ref consume
+ * for each tag. \ref consume might throw other exceptions
+ * as well.
+ */
+ void parse( const InputStream & imput_r, const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
+
+public:
+ /** Called when start parsing. */
+ virtual void beginParse();
+ /** Called when a section is found. */
+ virtual void consume( const std::string §ion );
+ /** Called when a key value is found. */
+ virtual void consume( const std::string §ion, const std::string &key, const std::string &value );
+ /** Called when the parse is done. */
+ virtual void endParse();
+
+ /** Called whenever a garbage line is found.
+ *
+ * \throw ParseException if not overloaded.
+ *
+ * Derived parsers may overload this to examine the line
+ * and call this method to actually throw the exception.
+ *
+ * Used by some parsers to accept multi-line entires.
+ */
+ virtual void garbageLine( const std::string §ion, const std::string &line );
+
+public:
+ /** Name of the current InputStream. */
+ const std::string & inputname() const
+ {
+ return _inputname;
+ }
+
+private:
+ std::string _inputname;
+ std::string _current_section;
+ int _line_nr;
+ //ProgressData _ticks;
+};
+
+/////////////////////////////////////////////////////////////////
+} // namespace parser
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_PARSER_INIPARSER_H
*
*/
#include <iostream>
-//#include <zypp/base/Logger.h>
-
-#include <zypp/parser/ParseException.h>
+#include "parseexception.h"
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/tagfile/ParseException.h
+ *
+*/
+#ifndef ZYPP_CORE_PARSER_PARSEEXCEPTION_H
+#define ZYPP_CORE_PARSER_PARSEEXCEPTION_H
+
+#include <iosfwd>
+#include <string>
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/base/UserRequestException>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace parser
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ParseException
+ //
+ /** */
+ class ParseException : public Exception
+ {
+ public:
+ /** Default ctor */
+ ParseException();
+ /** Ctor */
+ ParseException( const std::string & msg_r );
+ /** Dtor */
+ virtual ~ParseException() throw();
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_PARSER_PARSEEXCEPTION_H
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/base/Sysconfig.cc
+/** \file zypp-core/parser/sysconfig.cc
*
*/
+#include "sysconfig.h"
+
#include <iostream>
#include <fstream>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/StrMatcher.h>
-#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/Pathname.h>
-#include <zypp/PathInfo.h>
-#include <zypp/TmpPath.h>
-
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/Regex.h>
+#include <zypp-core/base/IOStream.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/fs/PathInfo.h>
+#include <zypp-core/fs/TmpPath.h>
using std::endl;
using namespace zypp::base;
bool found = false;
filesystem::TmpFile tmpf( filesystem::TmpFile::makeSibling( path_r ) );
{
- StrMatcher matches( "^[ \t]*"+key_r+"[ \t]*=", Match::REGEX );
+ str::regex regex( "^[ \t]*"+key_r+"[ \t]*=" );
std::ofstream o( tmpf.path().c_str() );
iostr::forEachLine( InputStream( path_r ),
[&]( int num_r, std::string line_r )->bool
{
- if ( !found && matches( line_r ) )
+ if ( !found && regex.matches( line_r ) )
{
o << key_r << '=' << val_r << endl;
found = true;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/parser/Sysconfig
+ *
+*/
+#ifndef ZYPP_CORE_PARSER_SYSCONFIG_H
+#define ZYPP_CORE_PARSER_SYSCONFIG_H
+
+#include <string>
+#include <map>
+#include <zypp-core/Pathname.h>
+
+namespace zypp {
+ namespace base {
+ namespace sysconfig {
+
+ /** Read sysconfig file \a path_r and return <tt>(key,valye)</tt> pairs. */
+ std::map<std::string,std::string> read( const Pathname & _path );
+
+ /** Add or change a value in sysconfig file \a path_r.
+ *
+ * If \a key_r already exists, only the \a val_r is changed accordingly.
+ *
+ * In case \a key_r is not yet present in the file, a new entry may be created
+ * at the end of the file, using the lines in \a newcomment_r as comment
+ * block. If \a newcomment_r is not provided or empty, a new value is not
+ * created and \c false is returned.
+ *
+ * \returns \c TRUE if an entry was changed or created.
+ *
+ * \throws Exception if \a path_r can not be read or written.
+ *
+ * \note \a val_r is written as it is. The caller is responsible for escaping and
+ * enclosing in '"', in case this is needed (\see \ref writeStringVal and \ref str::escape).
+ *
+ * \note Lines in \a newcomment_r which do not already start with a '#',
+ * are prefixes with "# ".
+ *
+ * \code
+ * ## Type: string
+ * ## Default: ""
+ * #
+ * # A multiline description of
+ * # the options purpose.
+ * #
+ * KEY="value"
+ * \endcode
+ */
+ bool write( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
+ const std::string & newcomment_r = std::string() );
+
+ /** Convenience to add or change a string-value in sysconfig file \a path_r.
+ *
+ * \a val_r is expected to be a plain string value, so it is propery escaped and enclosed in
+ * double quotes before it is written to the sysconfig file \a path_r.
+ *
+ * \see \ref write
+ */
+ bool writeStringVal( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
+ const std::string & newcomment_r = std::string() );
+
+ } // namespace sysconfig
+ } // namespace base
+} // namespace zypp
+
+#endif // ZYPP_CORE_PARSER_SYSCONFIG_H
--- /dev/null
+#include "progressdata.h"
*/
#include <iostream>
#include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/String.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
using std::endl;
if ( _d->_state == INIT )
{
_d->_state = RUN;
+ DBG << str::form( "{#%u|%s} START", numericId(), name().c_str() ) << endl;
}
// XXX << str::form( "{#%u|%s}(%lld%s)", numericId(), name().c_str(), _d->_last_val, ( hasRange() ? "%" : "!" ) ) << endl;
}
else if ( _d->_state == END )
{
- DBG << str::form( "{#%u|%s}END", numericId(), name().c_str() ) << endl;
+ DBG << str::form( "{#%u|%s} END", numericId(), name().c_str() ) << endl;
}
return true; // continue per default
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/ui/ProgressData
+ *
+*/
+#ifndef ZYPP_CORE_UI_PROGRESSDATA_H
+#define ZYPP_CORE_UI_PROGRESSDATA_H
+
+#include <iosfwd>
+#include <string>
+
+#include <zypp/base/PtrTypes.h>
+#include <zypp/base/Function.h>
+#include <zypp-core/base/ProvideNumericId>
+
+#include <zypp/Date.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ProgressData
+ //
+ /** Maintain <tt>[min,max]</tt> and counter <tt>(value)</tt> for progress counting.
+ *
+ * This class should provide everything the producer of progress data
+ * needs. As a convention, a zero sizes range indicates that you are just
+ * able to send <em>'still alive'</em> triggers.
+ *
+ * The counter should be updated in reasonable intervals. Don't mind whether
+ * the counter value actually increased or not. ProgressData will recognize
+ * your triggers and knows when to actually send notification to a consumer.
+ *
+ * Each ProgressData object provides a unique numeric id and you may assign
+ * it a name.
+ *
+ * \code
+ * bool exampleReceiver( const ProgressData & ticks_r )
+ * {
+ * DBG << "got ->" << ticks_r.reportValue() << " (" << ticks_r.val() << ")" << endl;
+ * return( ticks_r.val() <= 100 ); // Abort if ( val > 100 )
+ * }
+ *
+ * class Example
+ * {
+ * public:
+ *
+ * Example( const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() )
+ * : _fnc( fnc_r )
+ * {}
+ *
+ * void SendTo( const ProgressData::ReceiverFnc & fnc_r )
+ * { _fnc = fnc_r; }
+ *
+ * public:
+ *
+ * void action()
+ * {
+ * ProgressData tics( 10 ); // Expect range 0 -> 10
+ * tics.name( "test ticks" ); // Some arbitrary name
+ * tics.sendTo( _fnc ); // Send reports to _fnc
+ * tics.toMin(); // start sending min (0)
+ *
+ * for ( int i = 0; i < 10; ++i )
+ * {
+ * if ( ! tics.set( i ) )
+ * return; // user requested abort
+ * }
+ *
+ * tics.toMax(); // take care 100% are reported on success
+ * }
+ *
+ * void action2()
+ * {
+ * ProgressData tics; // Just send 'still alive' messages
+ * tics.name( "test ticks" ); // Some arbitrary name
+ * tics.sendTo( _fnc ); // Send reports to _fnc
+ * tics.toMin(); // start sending min (0)
+ *
+ * for ( int i = 0; i < 10; ++i )
+ * {
+ * if ( ! tics.set( i ) )
+ * return; // user requested abort
+ * }
+ *
+ * tics.toMax(); //
+ * }
+ *
+ * private:
+ * ProgressData::ReceiverFnc _fnc;
+ * };
+ * \endcode
+ * \code
+ * Example t( exampleReceiver );
+ * DBG << "Reporting %:" << endl;
+ * t.action();
+ * DBG << "Reporting 'still alive':" << endl;
+ * t.action2();
+ * \endcode
+ * \code
+ * Reporting %:
+ * got ->0 (0)
+ * got ->10 (1)
+ * got ->20 (2)
+ * got ->30 (3)
+ * got ->40 (4)
+ * got ->50 (5)
+ * got ->60 (6)
+ * got ->70 (7)
+ * got ->80 (8)
+ * got ->90 (9)
+ * got ->100 (10)
+ * got ->100 (10)
+ * Reporting 'still alive':
+ * got ->-1 (0)
+ * got ->-1 (9)
+ * \endcode
+ *
+ * The different ammount of triggers is due to different rules for sending
+ * percent or 'still alive' messages.
+ */
+ class ProgressData : public base::ProvideNumericId<ProgressData,unsigned>
+ {
+ public:
+ typedef long long value_type;
+ /** Most simple version of progress reporting
+ * The percentage in most cases. Sometimes just keepalive.
+ * \p sender ProgressData object who sends the progress info
+ * \p
+ */
+ typedef function<bool( const ProgressData & )> ReceiverFnc;
+
+ private:
+ enum State { INIT, RUN, END };
+
+ class Data
+ {
+ public:
+ Data( value_type min_r, value_type max_r, value_type val_r )
+ : _state( INIT ), _min( min_r ), _max( max_r ), _val( val_r )
+ , _last_val( 0 ), _last_send( 0 )
+ {}
+
+ public:
+ State _state;
+ std::string _name;
+ value_type _min;
+ value_type _max;
+ value_type _val;
+
+ ReceiverFnc _receiver;
+ value_type _last_val;
+ Date _last_send;
+
+ private:
+ /** clone for RWCOW_pointer */
+ friend Data * rwcowClone<Data>( const Data * rhs );
+ Data * clone() const { return new Data( *this ); }
+ };
+
+ public:
+ /** Ctor no range <tt>[0,0](0)</tt>. */
+ ProgressData()
+ : _d( new Data( 0, 0, 0 ) )
+ {}
+
+ /** Ctor <tt>[0,max](0)</tt>. */
+ ProgressData( value_type max_r )
+ : _d( new Data( 0, max_r, 0 ) )
+ {}
+
+ /** Ctor <tt>[min,max](min)</tt>. */
+ ProgressData( value_type min_r, value_type max_r )
+ : _d( new Data( min_r, max_r, min_r ) )
+ {}
+
+ /** Ctor <tt>[min,max](val)</tt>. */
+ ProgressData( value_type min_r, value_type max_r, value_type val_r )
+ : _d( new Data( min_r, max_r, val_r ) )
+ {}
+
+ ~ProgressData()
+ {
+ if ( _d->_state == RUN )
+ {
+ _d->_state = END;
+ report();
+ }
+ }
+
+ public:
+ /** Set new \c min value. */
+ void min( value_type min_r )
+ { _d->_min = min_r; }
+
+ /** Set new \c max value. */
+ void max( value_type max_r )
+ { _d->_max = max_r; }
+
+ /** Set no range <tt>[0,0]</tt>. */
+ void noRange()
+ { range( 0, 0 ); }
+
+ /** Set new <tt>[0,max]</tt>. */
+ void range( value_type max_r )
+ { range( 0, max_r ); }
+
+ /** Set new <tt>[min,max]</tt>. */
+ void range( value_type min_r, value_type max_r )
+ { min( min_r ); max( max_r ); }
+
+ public:
+ /** Set counter name. */
+ void name( const std::string & name_r )
+ { _d->_name = name_r; }
+
+ /** Set ReceiverFnc. */
+ void sendTo( const ReceiverFnc & fnc_r )
+ { _d->_receiver = fnc_r; }
+
+ /** Set no ReceiverFnc. */
+ void noSend()
+ { _d->_receiver = ReceiverFnc(); }
+
+ public:
+ /** \name Progress reporting.
+ *
+ * These methods may actually cause a progress report to be sent.
+ *
+ * All methods return \c bool, because a progress receiver may
+ * return \c false to indicate the desire to abort the pending
+ * action. The incident is logged, but it's finaly up to the caller
+ * to honor this.
+ */
+ //@{
+
+ /** Set new counter \c value. */
+ bool set( value_type val_r )
+ {
+ _d->_val = val_r;
+ return report();
+ }
+
+ /** Set range and counter from an other \ref ProgressData. */
+ bool set( const ProgressData & rhs )
+ {
+ min( rhs.min() );
+ max( rhs.max() );
+ return set( rhs.val() );
+ }
+
+ /** Increment counter \c value (default by 1). */
+ bool incr( value_type val_r = 1 )
+ { return set( val() + val_r ); }
+
+ /** Decrement counter \c value (default by 1). */
+ bool decr( value_type val_r = 1 )
+ { return set( val() - val_r ); }
+
+ /** Set counter value to current \c min value. */
+ bool toMin()
+ { return set( min() ); }
+
+ /** Set counter value to current \c max value (unless no range). */
+ bool toMax()
+ { return hasRange() ? set( max() ) : tick(); }
+
+ /** Leave counter value unchanged (still alive). */
+ bool tick()
+ { return report(); }
+
+ //@}
+
+ public:
+ /** \name Progress receiving.
+ */
+ //@{
+ /** @return Current \c min value. */
+ value_type min() const
+ { return _d->_min; }
+
+ /** @return Current \c max value. */
+ value_type max() const
+ { return _d->_max; }
+
+ /** @return Current counter \c value. */
+ value_type val() const
+ { return _d->_val; }
+
+ /** @return Whether <tt>[min,max]</tt> defines a nonempty range. */
+ bool hasRange() const
+ { return min() != max(); }
+
+ /** @return Whether \ref reportValue will return a percent value.
+ * Same as \ref hasRange.
+ * \see \ref reportAlive
+ */
+ bool reportPercent() const
+ { return hasRange(); }
+
+ /** @return Whether \ref reportValue always returns -1, because we
+ * trigger 'still alive' messages. I.e. \ref hasrange is \c false.
+ * \see \ref reportPercent
+ */
+ bool reportAlive() const
+ { return ! hasRange(); }
+
+ /** @return Either a a percent value or -1.
+ * \see \ref reportPercent and \ref reportAlive.
+ */
+ value_type reportValue() const
+ { return hasRange() ? val() * 100 / ( max() - min() ) : -1; }
+
+ /** @return The counters name. */
+ const std::string & name() const
+ { return _d->_name; }
+
+ /** @return The ReceiverFnc. */
+ const ReceiverFnc & receiver() const
+ { return _d->_receiver; }
+
+ /** @return Return \c true if this is the final report sent by the
+ * ProgressData dtor.
+ */
+ bool finalReport() const
+ { return( _d->_state == END ); }
+
+ //@}
+
+ private:
+ /** Send report if necessary. */
+ bool report();
+
+ /** Pointer to data. */
+ RWCOW_pointer<Data> _d;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates ProgressData Stream output */
+ std::ostream & operator<<( std::ostream & str, const ProgressData & obj );
+
+ ///////////////////////////////////////////////////////////////////
+
+ class InputStream;
+ /** \relates ProgressData Setup from \ref InputStream. */
+ ProgressData makeProgressData( const InputStream & input_r );
+
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * \short Progress callback from another progress
+ *
+ * This class allows you to pass a progress callback to a
+ * subtask based on a current progress data, plus a weight
+ * value. Every progress reported by the subtask via
+ * this callback will be forwarded to the main progress
+ * data, with the corresponding weight.
+ *
+ * Example:
+ *
+ * \code
+ *
+ * // receiver for main task
+ * void task_receiver( ProgressData &progress );
+ *
+ * // subtask prototypes
+ * void do_subtask_one( ProgressData::ReceiverFnc &fnc );
+ * void do_subtask_two( ProgressData::ReceiverFnc &fnc );
+ *
+ * // main task
+ * ProgressData progress;
+ * //progress for subtask 1
+ * // which is 80%
+ * CombinedProgressData sub1(pd, 80);
+ * // the second is only 20%
+ * CombinedProgressData sub2(pd, 20);
+ * do_subtask_one( sub1 );
+ * do_subtask_two( sub2 );
+ *
+ * \endcode
+ */
+ class CombinedProgressData
+ {
+ public:
+ /**
+ * \short Ctor
+ *
+ * Creates a \ref ProgressData::ReceiverFnc
+ * from a \ref ProgressData object
+ *
+ * \param pd \ref ProgressData object
+ * \param weight Weight of the subtask
+ * relative to the main task range.
+ *
+ * If weight is 0, or \param pd only reports
+ * keepalives. then only ticks are sent.
+ *
+ */
+ CombinedProgressData( ProgressData &pd,
+ ProgressData::value_type weight = 0 );
+
+ /**
+ * Implements the \ref ProgressData::ReceiverFnc
+ * callback interface
+ */
+ bool operator()( const ProgressData &progress );
+
+ private:
+ ProgressData::value_type _weight;
+ ProgressData::value_type _last_value;
+ ProgressData &_pd;
+ };
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_UI_PROGRESSDATA_H
--- /dev/null
+#include "asyncop.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_ASYNC_ASYNCOP_H_INCLUDED
+#define ZYPPNG_ASYNC_ASYNCOP_H_INCLUDED
+
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/zyppng/base/Signals>
+#include <boost/optional.hpp>
+#include <memory>
+
+namespace zyppng {
+
+ /*!
+ * Thrown if code tries to access the result of a async operation
+ * that is not ready.
+ */
+ class AsyncOpNotReadyException : public zypp::Exception
+ {
+ public:
+ AsyncOpNotReadyException()
+ : Exception( "AsyncOp instance not ready" )
+ {}
+ virtual ~AsyncOpNotReadyException();
+ };
+
+ AsyncOpNotReadyException::~AsyncOpNotReadyException()
+ { }
+
+ /*!
+ *\class AsyncOp
+ * The \a AsyncOp template class is the basic building block for the asynchronous pipelines.
+ * Its the base for all async callbacks as well as the async result type. That basically means
+ * every pipeline is just a AsyncOp that contains all previous operations that were defined in the pipeline.
+ *
+ * When implementing a async operation it is required to add a operator() to the class taking the
+ * input parameter. After the operation is finished the implementation must call setReady(). Calling
+ * setReady() must be treated like calling return in a normal function and not execute anymore code on the
+ * AsyncOp instance afterwards, since the next operation in the pipeline is allowed to free the previous operation
+ * as soon as it gets ready.
+ *
+ * In case no next operation is defined on the AsyncOp ( when the instance is used as result object ) the return value
+ * is cached internally and can be retrieved with \sa get().
+ *
+ * A async operation can be cancelled by releasing the result object ( the resulting combinatory object ), this will
+ * destroy all previous operations that are either running or pending as well.
+ */
+ template <typename Result>
+ struct AsyncOp {
+
+ using value_type = Result;
+
+ AsyncOp () = default;
+
+ AsyncOp ( const AsyncOp &other ) = delete;
+ AsyncOp& operator= ( const AsyncOp &other ) = delete;
+
+ AsyncOp& operator= ( AsyncOp &&other ) = default;
+ AsyncOp ( AsyncOp &&other ) = default;
+
+ virtual ~AsyncOp(){}
+
+ /*!
+ * Sets the async operation ready, in case a callback
+ * is registered the \a val is directly forwarded without
+ * storing it.
+ */
+ void setReady ( value_type && val ) {
+ if ( _readyCb )
+ _readyCb( std::move( val ) );
+ else { //we need to cache the value because no callback is available
+ _maybeValue = std::move(val);
+ _sigReady.emit();
+ }
+ }
+
+ /*!
+ * Checks if the async operation already has finished.
+ *
+ * \note This can only be used when no callback is registered.
+ */
+ bool isReady () const {
+ return _maybeValue.is_initialized();
+ }
+
+ /*!
+ * Registeres a callback that is immediately called
+ * when the object gets into ready state. In case the
+ * object is in ready state when registering the callback
+ * it is called right away.
+ */
+ template< typename Fun >
+ void onReady ( Fun cb ) {
+ this->_readyCb = std::forward<Fun>(cb);
+
+ if ( isReady() ) {
+ _readyCb( std::move( _maybeValue.get()) );
+ _maybeValue = boost::optional<value_type>();
+ }
+ }
+
+ /*!
+ * Returns the internally cached value if there is one.
+ * \throws AsyncOpNotReadyException if called before the operation is ready
+ */
+ value_type &get (){
+ if ( !isReady() )
+ ZYPP_THROW(AsyncOpNotReadyException());
+ return _maybeValue.get();
+ }
+
+ /*!
+ * Signal that is emitted once the AsyncOp is ready and no
+ * callback was registered with \ref onReady
+ */
+ SignalProxy<void()> sigReady () {
+ return _sigReady;
+ }
+
+ private:
+ Signal<void()> _sigReady;
+ std::function<void(value_type &&)> _readyCb;
+ boost::optional<value_type> _maybeValue;
+ };
+
+ template <typename T>
+ using AsyncOpPtr = std::unique_ptr<AsyncOp<T>>;
+
+ namespace detail {
+
+#if 0
+ template <typename T>
+ using has_value_type_t = typename T::value_type;
+
+ template <typename T, typename AsyncRet>
+ using is_asyncop_type = std::is_convertible<T*, AsyncOp<AsyncRet>*>;
+
+
+ template <typename T>
+ using is_async_op = typename std::conjunction<
+ std::is_detected< has_value_type_t, T >,
+ std::is_detected< is_asyncop_type, T, typename T::value_type >
+ >;
+
+#else
+
+ /*!
+ * Checks if a type T is a asynchronous operation type
+ */
+ template < typename T, typename = std::void_t<> >
+ struct is_async_op : public std::false_type{};
+
+ template < typename T >
+ struct is_async_op<T,
+ std::void_t< typename T::value_type, //needs to have a value_type
+ std::enable_if_t<std::is_convertible< T*, AsyncOp<typename T::value_type>* >::value>>> //needs to be convertible to AsyncOp<T::value_type>
+ : public std::true_type{};
+
+#endif
+
+ }
+
+}
+
+
+
+#endif
off_t writeData(const char *data, off_t count) override;
off_t readData(char *buffer, off_t bufsize) override;
size_t rawBytesAvailable() const override;
+
+ private:
+ using IODevice::open;
};
}
--- /dev/null
+#include "function_traits.h"
--- /dev/null
+#include "functional.h"
--- /dev/null
+#include "type_traits.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+* //Code based on a blogpost on https://functionalcpp.wordpress.com/2013/08/05/function-traits/
+*
+*/
+#ifndef ZYPPNG_META_FUNCTION_TRAITS_H_INCLUDED
+#define ZYPPNG_META_FUNCTION_TRAITS_H_INCLUDED
+
+#include <cstddef>
+#include <tuple>
+#include <zypp-core/zyppng/meta/TypeTraits>
+
+namespace zyppng {
+
+template<class F, class = void >
+struct function_traits;
+
+template<class R, class... Args>
+struct function_traits<R(Args...)>
+{
+ using return_type = R;
+
+ static constexpr std::size_t arity = sizeof...(Args);
+
+ template <std::size_t N>
+ struct argument
+ {
+ static_assert(N >= 0 && N < arity, "error: invalid parameter index.");
+ using type = typename std::tuple_element<N,std::tuple<Args...>>::type;
+ };
+};
+
+// function pointer
+template<class R, class... Args>
+struct function_traits<R(*)(Args...)> : public function_traits<R(Args...)>
+{ };
+
+// function ref
+template<class R, class... Args>
+struct function_traits<R(&)(Args...)> : public function_traits<R(Args...)>
+{ };
+
+// member function pointer
+template<class C, class R, class... Args>
+struct function_traits<R(C::*)(Args...)> : public function_traits<R(C&,Args...)>
+{};
+
+// const member function pointer, this will match lambdas too
+template<class C, class R, class... Args>
+struct function_traits<R(C::*)(Args...) const> : public function_traits<R(C&,Args...)>
+{};
+
+// member object pointer
+template<class C, class R>
+struct function_traits<R(C::*)> : public function_traits<R(C&)>
+{};
+
+template <typename T>
+using has_call_operator = decltype (&T::operator());
+
+//functor with one overload
+template<class F>
+struct function_traits<F, std::void_t<decltype (&F::operator())>> : public function_traits<decltype (&F::operator())>
+{};
+
+}
+#endif
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_META_FUNCTIONAL_H_INCLUDED
+#define ZYPPNG_META_FUNCTIONAL_H_INCLUDED
+
+#include <functional>
+
+#if __cplusplus <= 201402L || !defined ( __cpp_lib_invoke )
+
+#include <type_traits>
+
+// this is a workaround for std::invoke not being available in C++14
+// and the proposed minimal implementation in
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4169.html
+
+namespace std {
+ template<typename Functor, typename... Args>
+ typename std::enable_if<
+ std::is_member_pointer<typename std::decay<Functor>::type>::value,
+ typename std::result_of<Functor&&(Args&&...)>::type
+ >::type invoke(Functor&& f, Args&&... args)
+ {
+ return std::mem_fn(f)(std::forward<Args>(args)...);
+ }
+
+ template<typename Functor, typename... Args>
+ typename std::enable_if<
+ !std::is_member_pointer<typename std::decay<Functor>::type>::value,
+ typename std::result_of<Functor&&(Args&&...)>::type
+ >::type invoke(Functor&& f, Args&&... args)
+ {
+ return std::forward<Functor>(f)(std::forward<Args>(args)...);
+ }
+}
+
+#endif
+
+#endif
--- /dev/null
+#ifndef ZYPPNG_META_TYPE_TRAITS_INCLUDED
+#define ZYPPNG_META_TYPE_TRAITS_INCLUDED
+
+#include <type_traits>
+#include <memory>
+
+#if !defined ( __cpp_lib_void_t )
+
+namespace std {
+ //define void_t since its only available starting with C++17 in some compilers
+ template<typename... Ts> struct make_void { typedef void type;};
+ template<typename... Ts> using void_t = typename make_void<Ts...>::type;
+}
+
+#endif
+
+
+#if __cplusplus < 201703L
+
+namespace std {
+
+//implementation of the detector idiom, used to help with SFINAE
+//from https://en.cppreference.com/w/cpp/experimental/is_detected
+
+namespace detail {
+template <class Default, class AlwaysVoid,
+ template<class...> class Op, class... Args>
+struct detector {
+ using value_t = std::false_type;
+ using type = Default;
+};
+
+template <class Default, template<class...> class Op, class... Args>
+struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
+ using value_t = std::true_type;
+ using type = Op<Args...>;
+};
+
+struct nonesuch{
+ ~nonesuch( ) = delete;
+ nonesuch( nonesuch const& ) = delete;
+ void operator = ( nonesuch const& ) = delete;
+};
+
+} // namespace detail
+
+template <bool B> using bool_constant = integral_constant<bool, B>;
+
+template <template<class...> class Op, class... Args>
+using is_detected = typename detail::detector<detail::nonesuch, void, Op, Args...>::value_t;
+
+template <template<class...> class Op, class... Args>
+using detected_t = typename detail::detector<detail::nonesuch, void, Op, Args...>::type;
+
+template <class Default, template<class...> class Op, class... Args>
+using detected_or = detail::detector<Default, void, Op, Args...>;
+
+template< template<class...> class Op, class... Args >
+constexpr bool is_detected_v = is_detected<Op, Args...>::value;
+
+template< class Default, template<class...> class Op, class... Args >
+using detected_or_t = typename detected_or<Default, Op, Args...>::type;
+
+template <class Expected, template<class...> class Op, class... Args>
+using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
+
+template <class Expected, template<class...> class Op, class... Args>
+constexpr bool is_detected_exact_v = is_detected_exact<Expected, Op, Args...>::value;
+
+template <class To, template<class...> class Op, class... Args>
+using is_detected_convertible = std::is_convertible<detected_t<Op, Args...>, To>;
+
+template <class To, template<class...> class Op, class... Args>
+constexpr bool is_detected_convertible_v = is_detected_convertible<To, Op, Args...>::value_t::value;
+
+//https://en.cppreference.com/w/cpp/types/conjunction)
+template<class...> struct conjunction : std::true_type { };
+template<class B1> struct conjunction<B1> : B1 { };
+template<class B1, class... Bn>
+struct conjunction<B1, Bn...>
+ : std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};
+
+//https://en.cppreference.com/w/cpp/types/disjunction
+template<class...> struct disjunction : std::false_type { };
+template<class B1> struct disjunction<B1> : B1 { };
+template<class B1, class... Bn>
+struct disjunction<B1, Bn...>
+ : std::conditional_t<bool(B1::value), B1, disjunction<Bn...>> { };
+
+//https://en.cppreference.com/w/cpp/types/negation
+template<class B>
+struct negation : std::bool_constant< !bool(B::value)> { };
+
+}
+#endif
+
+
+namespace zyppng {
+ //check wether something is a instance of a template type
+ template < template< class ... > class Templ, class Type >
+ struct is_instance_of : std::false_type{};
+
+ template < template< typename ... > class Templ, typename... Args >
+ struct is_instance_of<Templ, Templ<Args...>> : std::true_type{};
+
+ //Provides the member typedef type which is the type pointed to by T, or, if T is not a pointer, then type is the same as T.
+ template< typename T>
+ struct remove_smart_ptr{ using type = typename std::remove_cv<T>::type; };
+
+ template< typename T>
+ struct remove_smart_ptr<std::shared_ptr<T>>{ using type = typename std::remove_cv<T>::type; };
+
+ template< typename T>
+ struct remove_smart_ptr<std::unique_ptr<T>>{ using type = typename std::remove_cv<T>::type; };
+
+ template< typename T>
+ using remove_smart_ptr_t = typename remove_smart_ptr<T>::type;
+
+ //helper template to print type parameters
+ template <typename T>
+ class myerror_t;
+}
+
+#endif
--- /dev/null
+#include "asyncresult.h"
--- /dev/null
+#include "await.h"
--- /dev/null
+#include "expected.h"
--- /dev/null
+#include "lift.h"
--- /dev/null
+#include "mtry.h"
--- /dev/null
+#include "redo.h"
--- /dev/null
+#include "transform.h"
--- /dev/null
+#include "wait.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_ASYNCRESULT_H_INCLUDED
+#define ZYPPNG_MONADIC_ASYNCRESULT_H_INCLUDED
+
+#include <zypp-core/zyppng/meta/TypeTraits>
+#include <zypp-core/zyppng/meta/FunctionTraits>
+#include <zypp-core/zyppng/meta/Functional>
+#include <zypp-core/zyppng/async/AsyncOp>
+
+
+namespace zyppng {
+
+
+ namespace detail {
+
+ /*!
+ * Checks if a Callable object is of type async_op and if
+ * it accepts the given MsgType and returns the expected type
+ */
+ template< typename Callback, typename Ret, typename MsgType, typename = std::void_t<> >
+ struct is_future_monad_cb : public std::false_type{};
+
+ template< typename Callback, typename Ret, typename MsgType >
+ struct is_future_monad_cb<Callback, Ret, MsgType,
+ std::void_t<
+ typename Callback::value_type,
+ std::enable_if_t< std::is_same< typename Callback::value_type, Ret >::value >,
+ std::enable_if_t< is_async_op<Callback>::value >,
+ decltype ( std::declval<Callback>()( std::declval<MsgType>()) )//check if the callback has a operator() member with the correct signature
+ >
+ > : public std::true_type{};
+
+ /*!
+ * Checks if a Callable object is a syncronous callback type with the expected signature
+ */
+ template< typename Callback, typename MsgType, typename = std::void_t<> >
+ struct is_sync_monad_cb : public std::false_type{};
+
+ template< typename Callback, typename MsgType >
+ struct is_sync_monad_cb<Callback, MsgType
+ , std::void_t<
+ std::enable_if_t< !is_async_op<Callback>::value >,
+ std::enable_if_t< !std::is_same< void, decltype ( std::declval<Callback>()(std::declval<MsgType>())) >::value > > //check if the callback has the correct signature: cb( MsgType )
+ > : public std::true_type{};
+
+
+ /*!
+ * The AsyncResult class is used to bind previous operations to a new operation and to carry
+ * the result of the full pipeline. It has a pointer to the _prevTask, which is usually
+ * a AsyncResult too, and to the task it should execute once the previous task enters ready state.
+ *
+ * In theory this is a single linked list, but each node owns all the previous nodes, means that once
+ * a node is destroyed all previous ones are destroyed as well. Basically the async results are nested objects, where
+ * the outermost object is the last to be executed. While executing the nodes they are cleaned up right away
+ * after they enter finished or ready state.
+ *
+ * When returned to the code the AsyncResult is casted into the AsyncOp base class, otherwise the type
+ * information gets too complex and matching the pipe operator functions is a nightmare. This could be revisited
+ * with newer C++ versions.
+ *
+ */
+ template <typename Prev, typename AOp, typename = void>
+ struct AsyncResult;
+
+ template <typename Prev, typename AOp >
+ struct AsyncResult<Prev,AOp> : public zyppng::AsyncOp< typename AOp::value_type > {
+
+ AsyncResult ( std::unique_ptr<Prev> && prevTask, std::unique_ptr<AOp> &&cb )
+ : _prevTask( std::move(prevTask) )
+ , _myTask( std::move(cb) ) {
+ connect();
+ }
+
+ AsyncResult ( const AsyncResult &other ) = delete;
+ AsyncResult& operator= ( const AsyncResult &other ) = delete;
+
+ AsyncResult ( AsyncResult &&other ) = delete;
+ AsyncResult& operator= ( AsyncResult &&other ) = delete;
+
+ virtual ~AsyncResult() {}
+
+ void connect () {
+ //not using a lambda here on purpose, binding this into a lambda that is stored in the _prev
+ //object causes segfaults on gcc when the lambda is cleaned up with the _prev objects signal instance
+ _prevTask->onReady( std::bind( &AsyncResult::readyWasCalled, this, std::placeholders::_1) );
+ _myTask->onReady( [this] ( typename AOp::value_type && res ){
+ this->setReady( std::move( res ) );
+ });
+ }
+
+ private:
+ void readyWasCalled ( typename Prev::value_type && res ) {
+ //we need to force the passed argument into our stack, otherwise we
+ //run into memory issues if the argument is moved out of the _prevTask object
+ typename Prev::value_type resStore = std::move(res);
+
+ if ( _prevTask ) {
+ //dumpInfo();
+ _prevTask.reset(nullptr);
+ }
+
+ _myTask->operator()(std::move(resStore));
+ }
+
+ std::unique_ptr<Prev> _prevTask;
+ std::unique_ptr<AOp> _myTask;
+ };
+
+ template<typename AOp, typename In>
+ struct AsyncResult<void, AOp, In> : public zyppng::AsyncOp< typename AOp::value_type > {
+
+ AsyncResult ( std::unique_ptr<AOp> &&cb )
+ : _myTask( std::move(cb) ) {
+ connect();
+ }
+
+ virtual ~AsyncResult() { }
+
+ void run ( In &&val ) {
+ _myTask->operator()( std::move(val) );
+ }
+
+ AsyncResult ( const AsyncResult &other ) = delete;
+ AsyncResult& operator= ( const AsyncResult &other ) = delete;
+
+ AsyncResult ( AsyncResult &&other ) = delete;
+ AsyncResult& operator= ( AsyncResult &&other ) = delete;
+
+ private:
+ void connect () {
+ _myTask->onReady( [this] ( typename AOp::value_type && in ){
+ this->setReady( std::move( in ) );
+ });
+ }
+ std::unique_ptr<AOp> _myTask;
+ };
+
+ //A async result that is ready right away
+ template <typename T>
+ struct ReadyResult : public zyppng::AsyncOp< T >
+ {
+ ReadyResult( T &&val ) {
+ this->setReady( std::move(val) );
+ }
+ };
+
+ //need a wrapper to connect a sync callback to a async one
+ template < typename Callback, typename In, typename Out >
+ struct SyncCallbackWrapper : public AsyncOp<Out>
+ {
+ using value_type = Out;
+
+ template< typename C = Callback >
+ SyncCallbackWrapper( C &&c ) : _c( std::forward<C>(c) ){}
+
+ virtual ~SyncCallbackWrapper(){ }
+
+ void operator() ( In &&value ) {
+ this->setReady( std::invoke( _c, std::move(value)) );
+ }
+
+ private:
+ Callback _c;
+ };
+
+ /*!
+ * Simple AsyncOperator wrapper that accepts a Async result
+ * forwarding the actual value when it gets ready. This is used to
+ * simplify nested asyncronous results.
+ */
+ template< typename AOp, typename Ret = typename AOp::value_type >
+ struct SimplifyHelper : public AsyncOp<Ret>
+ {
+
+ virtual ~SimplifyHelper(){}
+
+ void operator() ( std::unique_ptr<AOp> &&op ) {
+ assert( !_task );
+ _task = std::move(op);
+ _task->onReady( [this]( Ret &&val ){
+ this->setReady( std::move(val) );
+ });
+ }
+ private:
+ std::unique_ptr<AOp> _task;
+ };
+
+ /*!
+ * Takes a possibly nested future and simplifies it,
+ * so instead of AsyncResult<AsyncResult<int>> we get AsyncResult<int>.
+ * Usually we do not want to wait on the future of a future but get the nested result immediately
+ */
+ template < typename Res >
+ inline std::unique_ptr<AsyncOp<Res>> simplify ( std::unique_ptr< AsyncOp<Res> > &&res ) {
+ return std::move(res);
+ }
+
+ template < typename Res,
+ typename AOp = AsyncOp< std::unique_ptr< AsyncOp<Res>> > >
+ inline std::unique_ptr<AsyncOp<Res>> simplify ( std::unique_ptr< AsyncOp< std::unique_ptr< AsyncOp<Res>> > > &&res ) {
+ std::unique_ptr<AsyncOp<Res>> op = std::make_unique< detail::AsyncResult< AOp, SimplifyHelper< AsyncOp<Res>>> >( std::move(res), std::make_unique<SimplifyHelper< AsyncOp<Res>>>() );
+ return detail::simplify( std::move(op) );
+ }
+ }
+
+ template <typename T>
+ AsyncOpPtr<T> makeReadyResult ( T && result ) {
+ return std::make_unique<detail::ReadyResult<T>>( std::move(result) );
+ }
+
+ namespace operators {
+
+ //case 1 : binding a async message to a async callback
+ template< typename PrevOp
+ , typename Callback
+ , typename Ret = typename Callback::value_type
+ , std::enable_if_t< detail::is_async_op<PrevOp>::value, int> = 0
+ //is the callback signature what we want?
+ , std::enable_if_t< detail::is_future_monad_cb< Callback, Ret, typename PrevOp::value_type >::value, int> = 0
+ >
+ auto operator| ( std::unique_ptr<PrevOp> &&future, std::unique_ptr<Callback> &&c )
+ {
+ std::unique_ptr<AsyncOp<Ret>> op = std::make_unique<detail::AsyncResult< PrevOp, Callback>>( std::move(future), std::move(c) );
+ return detail::simplify( std::move(op) );
+ }
+
+ //case 2: binding a async message to a sync callback
+ template< typename PrevOp
+ , typename Callback
+ , typename Ret = std::result_of_t< Callback( typename PrevOp::value_type&& ) >
+ , std::enable_if_t< detail::is_async_op<PrevOp>::value, int> = 0
+ , std::enable_if_t< detail::is_sync_monad_cb< Callback, typename PrevOp::value_type >::value, int> = 0
+ >
+ auto operator| ( std::unique_ptr<PrevOp> &&future, Callback &&c )
+ {
+ std::unique_ptr<AsyncOp<Ret>> op(std::make_unique<detail::AsyncResult< PrevOp, detail::SyncCallbackWrapper<Callback, typename PrevOp::value_type, Ret> >>(
+ std::move(future)
+ , std::make_unique<detail::SyncCallbackWrapper<Callback, typename PrevOp::value_type, Ret>>( std::forward<Callback>(c) ) ));
+
+ return detail::simplify( std::move(op) );
+ }
+
+ //case 3: binding a sync message to a async callback
+ template< typename SyncRes
+ , typename Callback
+ , typename Ret = typename Callback::value_type
+ , std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<SyncRes> >::value, int> = 0
+ , std::enable_if_t< detail::is_future_monad_cb< Callback, Ret, SyncRes >::value, int> = 0
+ >
+ auto operator| ( SyncRes &&in, std::unique_ptr<Callback> &&c )
+ {
+ AsyncOpPtr<Ret> op( std::make_unique<detail::AsyncResult<void, Callback, SyncRes>>( std::move(c) ) );
+ static_cast< detail::AsyncResult<void, Callback, SyncRes>* >(op.get())->run( std::move(in) );
+ return detail::simplify( std::move(op) );
+ }
+
+ //case 4: binding a sync message to a sync callback
+ template< typename SyncRes
+ , typename Callback
+ , std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<SyncRes> >::value, int > = 0
+ , std::enable_if_t< detail::is_sync_monad_cb< Callback, SyncRes >::value, int > = 0
+ >
+ auto operator| ( SyncRes &&in, Callback &&c )
+ {
+ return std::forward<Callback>(c)(std::forward<SyncRes>(in));
+ }
+
+ }
+}
+
+#endif
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_AWAIT_H_INCLUDED
+#define ZYPPNG_MONADIC_AWAIT_H_INCLUDED
+
+
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+#include <zypp-core/zyppng/base/Signals>
+
+namespace zyppng {
+
+ namespace detail
+ {
+ template <typename T, typename SigGetter> struct AwaitImpl;
+
+ template <typename ArgType, typename SigR, typename ...SigT >
+ struct AwaitImpl<std::shared_ptr<ArgType>, SignalProxy<SigR(SigT...)> (ArgType::*)()> : public zyppng::AsyncOp< std::shared_ptr<ArgType> > {
+
+ using SigGetter = SignalProxy<SigR(SigT...)> (ArgType::*)();
+
+ template<typename S>
+ AwaitImpl ( S&& sigGet ) : _sigGet( std::forward<S>(sigGet ) ) {}
+
+ virtual ~AwaitImpl(){ }
+
+ void operator() ( std::shared_ptr<ArgType> &&req ) {
+ _req = std::move(req);
+ std::invoke( _sigGet, _req ).connect( sigc::mem_fun(this, &AwaitImpl::sigHandler<SigR>) );
+ }
+
+ private:
+ template < typename RetType = SigR >
+ std::enable_if_t< std::is_same<void,RetType>::value, RetType >
+ sigHandler ( SigT... ) {
+ this->setReady( std::move(_req) );
+ }
+
+ template < typename RetType = SigR >
+ std::enable_if_t< !std::is_same<void,RetType>::value, RetType >
+ sigHandler ( SigT... ) {
+ this->setReady( std::move(_req) );
+ return {};
+ }
+
+ std::shared_ptr<ArgType> _req;
+ SigGetter _sigGet;
+ };
+ }
+
+ //return a async op that waits for a signal to emitted by a object
+ template <typename T,
+ typename SignalGetter >
+ auto await ( SignalGetter &&sigGet )
+ {
+ return std::make_unique<detail::AwaitImpl<T, SignalGetter>>( std::forward<SignalGetter>(sigGet) );
+ }
+
+}
+
+#endif
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+* Based on code by Ivan Čukić (BSD/MIT licensed) from the functional cpp book
+*/
+
+#ifndef ZYPP_ZYPPNG_MONADIC_EXPECTED_H
+#define ZYPP_ZYPPNG_MONADIC_EXPECTED_H
+
+#include <zypp-core/zyppng/meta/Functional>
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+
+namespace zyppng {
+
+ template<typename T, typename E = std::exception_ptr>
+ class expected {
+ protected:
+ union {
+ T m_value;
+ E m_error;
+ };
+
+ bool m_isValid;
+
+ expected() // used internally
+ {
+ }
+
+ public:
+
+ using value_type = T;
+ using error_type = E;
+
+ ~expected()
+ {
+ if (m_isValid) {
+ m_value.~T();
+ } else {
+ m_error.~E();
+ }
+ }
+
+ expected(const expected &other)
+ : m_isValid(other.m_isValid)
+ {
+ if (m_isValid) {
+ new (&m_value) T(other.m_value);
+ } else {
+ new (&m_error) E(other.m_error);
+ }
+ }
+
+ expected(expected &&other)
+ : m_isValid(other.m_isValid)
+ {
+ if (m_isValid) {
+ new (&m_value) T( std::move(other.m_value) );
+ } else {
+ new (&m_error) E( std::move(other.m_error) );
+ }
+ }
+
+ expected &operator= (expected other)
+ {
+ swap(other);
+ return *this;
+ }
+
+ void swap(expected &other)
+ {
+ using std::swap;
+ if (m_isValid) {
+ if (other.m_isValid) {
+ // Both are valid, just swap the values
+ swap(m_value, other.m_value);
+
+ } else {
+ // We are valid, but the other one is not
+ // we need to do the whole dance
+ auto temp = std::move(other.m_error); // moving the error into the temp
+ other.m_error.~E(); // destroying the original error object
+ new (&other.m_value) T(std::move(m_value)); // moving our value into the other
+ m_value.~T(); // destroying our value object
+ new (&m_error) E(std::move(temp)); // moving the error saved to the temp into us
+ std::swap(m_isValid, other.m_isValid); // swap the isValid flags
+ }
+
+ } else {
+ if (other.m_isValid) {
+ // We are not valid, but the other one is,
+ // just call swap on other and rely on the
+ // implementation in the previous case
+ other.swap(*this);
+
+ } else {
+ // Everything is rotten, just swap the errors
+ swap(m_error, other.m_error);
+ std::swap(m_isValid, other.m_isValid);
+ }
+ }
+ }
+
+ template <typename... ConsParams>
+ static expected success(ConsParams && ...params)
+ {
+ expected result;
+ result.m_isValid = true;
+ new(&result.m_value) T(std::forward<ConsParams>(params)...);
+ return result;
+ }
+
+ template <typename... ConsParams>
+ static expected error(ConsParams && ...params)
+ {
+ expected result;
+ result.m_isValid = false;
+ new(&result.m_error) E(std::forward<ConsParams>(params)...);
+ return result;
+ }
+
+ operator bool() const
+ {
+ return m_isValid;
+ }
+
+ bool is_valid() const
+ {
+ return m_isValid;
+ }
+
+ #ifdef NO_EXCEPTIONS
+ # define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) std::terminate()
+ #else
+ # define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) throw std::logic_error(WHAT)
+ #endif
+
+ T &get()
+ {
+ if (!m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("expected<T, E> contains no value");
+ return m_value;
+ }
+
+ const T &get() const
+ {
+ if (!m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("expected<T, E> contains no value");
+ return m_value;
+ }
+
+
+
+ T *operator-> ()
+ {
+ return &get();
+ }
+
+ const T *operator-> () const
+ {
+ return &get();
+ }
+
+ E &error()
+ {
+ if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+ return m_error;
+ }
+
+ const E &error() const
+ {
+ if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+ return m_error;
+ }
+
+ #undef THROW_IF_EXCEPTIONS_ARE_ENABLED
+
+ template <typename F>
+ void visit(F f) {
+ if (m_isValid) {
+ f(m_value);
+ } else {
+ f(m_error);
+ }
+ }
+ };
+
+
+ template<typename E>
+ class expected<void, E> {
+ private:
+ union {
+ void* m_value;
+ E m_error;
+ };
+
+ bool m_isValid;
+
+ expected() {} //used internally
+
+ public:
+ ~expected()
+ {
+ if (m_isValid) {
+ // m_value.~T();
+ } else {
+ m_error.~E();
+ }
+ }
+
+ expected(const expected &other)
+ : m_isValid(other.m_isValid)
+ {
+ if (m_isValid) {
+ // new (&m_value) T(other.m_value);
+ } else {
+ new (&m_error) E(other.m_error);
+ }
+ }
+
+ expected(expected &&other)
+ : m_isValid(other.m_isValid)
+ {
+ if (m_isValid) {
+ // new (&m_value) T(std::move(other.m_value));
+ } else {
+ new (&m_error) E(std::move(other.m_error));
+ }
+ }
+
+ expected &operator= (expected other)
+ {
+ swap(other);
+ return *this;
+ }
+
+ void swap(expected &other)
+ {
+ using std::swap;
+ if (m_isValid) {
+ if (other.m_isValid) {
+ // Both are valid, we do not have any values
+ // to swap
+
+ } else {
+ // We are valid, but the other one is not.
+ // We need to move the error into us
+ auto temp = std::move(other.m_error); // moving the error into the temp
+ other.m_error.~E(); // destroying the original error object
+ new (&m_error) E(std::move(temp)); // moving the error into us
+ std::swap(m_isValid, other.m_isValid); // swapping the isValid flags
+ }
+
+ } else {
+ if (other.m_isValid) {
+ // We are not valid, but the other one is,
+ // just call swap on other and rely on the
+ // implementation in the previous case
+ other.swap(*this);
+
+ } else {
+ // Everything is rotten, just swap the errors
+ swap(m_error, other.m_error);
+ std::swap(m_isValid, other.m_isValid);
+ }
+ }
+ }
+
+ static expected success()
+ {
+ expected result;
+ result.m_isValid = true;
+ result.m_value = nullptr;
+ return result;
+ }
+
+ template <typename... ConsParams>
+ static expected error(ConsParams && ...params)
+ {
+ expected result;
+ result.m_isValid = false;
+ new(&result.m_error) E(std::forward<ConsParams>(params)...);
+ return result;
+ }
+
+ operator bool() const
+ {
+ return m_isValid;
+ }
+
+ bool is_valid() const
+ {
+ return m_isValid;
+ };
+
+ #ifdef NO_EXCEPTIONS
+ # define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) std::terminate()
+ #else
+ # define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) throw std::logic_error(WHAT)
+ #endif
+
+ E &error()
+ {
+ if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+ return m_error;
+ }
+
+ const E &error() const
+ {
+ if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+ return m_error;
+ }
+
+ };
+
+
+ template < typename T
+ , typename E
+ , typename Function
+ , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+ >
+ std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( const expected<T, E>& exp, Function f)
+ {
+ if (exp) {
+ return std::invoke( f, exp.get() );
+ } else {
+ return ResultType::error(exp.error());
+ }
+ }
+
+ template < typename T
+ , typename E
+ , typename Function
+ , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+ >
+ std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( expected<T, E>&& exp, Function f)
+ {
+ if (exp) {
+ return std::invoke( f, std::move(exp.get()) );
+ } else {
+ return ResultType::error( std::move(exp.error()) );
+ }
+ }
+
+ template < typename T
+ , typename E
+ , typename Function
+ , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+ >
+ std::enable_if_t< detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( const expected<T, E>& exp, Function f)
+ {
+ if (exp) {
+ return std::invoke( f, exp.get() );
+ } else {
+ return makeReadyResult( remove_smart_ptr_t<ResultType>::value_type::error(exp.error()) );
+ }
+ }
+
+ template < typename T
+ , typename E
+ , typename Function
+ , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+ >
+ std::enable_if_t< detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( expected<T, E>&& exp, Function f)
+ {
+ if (exp) {
+ return std::invoke( f, std::move(exp.get()) );
+ } else {
+ return makeReadyResult( remove_smart_ptr_t<ResultType>::value_type::error( std::move(exp.error()) ) );
+ }
+ }
+
+ namespace detail {
+ template <typename Callback>
+ struct mbind_helper {
+ Callback function;
+
+ template< typename T
+ , typename E >
+ auto operator()( const expected<T, E>& exp ) {
+ return mbind( exp, function );
+ }
+
+ template< typename T
+ , typename E >
+ auto operator()( expected<T, E>&& exp ) {
+ return mbind( std::move(exp), function );
+ }
+ };
+ }
+
+ namespace operators {
+ template <typename Fun>
+ auto mbind ( Fun && function ) {
+ return detail::mbind_helper<Fun> {
+ std::forward<Fun>(function)
+ };
+ }
+ }
+}
+
+#endif
+
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_LIFT_H_INCLUDED
+#define ZYPPNG_MONADIC_LIFT_H_INCLUDED
+
+#include <utility>
+#include <memory>
+#include <iostream>
+
+#include <zypp-core/zyppng/meta/Functional>
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+
+namespace zyppng {
+
+ namespace detail {
+ template <typename LiftedFun, typename extra = void >
+ struct lifter {
+
+ lifter( LiftedFun &&fun ) : _fun(std::move(fun)) {}
+ lifter( lifter && ) = default;
+ ~lifter(){}
+
+ template< typename T1
+ , typename T2
+ , typename Ret = std::pair<std::result_of_t<LiftedFun(T1)>, T2>
+ >
+ Ret operator()( std::pair<T1, T2> &&data ) {
+ return std::make_pair( std::invoke( _fun, std::move(data.first) ), std::move(data.second) );
+ }
+ private:
+ LiftedFun _fun;
+ };
+
+ template < typename AsyncOp >
+ struct lifter< std::unique_ptr<AsyncOp>, std::void_t< std::enable_if_t< zyppng::detail::is_async_op<AsyncOp>::value > > > {
+
+ using LiftedFun = std::unique_ptr<AsyncOp>;
+
+ lifter( LiftedFun &&fun ) : _fun(std::move(fun)) {}
+ lifter( lifter && ) = default;
+ ~lifter(){}
+
+ template< typename T1
+ , typename T2
+ >
+ auto operator()( std::pair<T1, T2> &&data ) {
+
+ using namespace zyppng;
+ using namespace zyppng::operators;
+
+ return std::move(data.first)
+ | ( std::move(_fun) )
+ | [ other = std::move(data.second)]( auto && res ) mutable {
+ return std::make_pair( std::forward<decltype (res)>(res), std::move(other) );
+ };
+ }
+ private:
+ LiftedFun _fun;
+ };
+ }
+
+ template< typename Fun >
+ auto lift ( Fun && func ) {
+ return detail::lifter<Fun>( std::forward<Fun>(func) );
+ }
+
+}
+
+#endif
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+* Based on code by Ivan Čukić (BSD/MIT licensed) from the functional cpp book
+*/
+
+#ifndef ZYPP_ZYPPNG_MONADIC_MTRY_H
+#define ZYPP_ZYPPNG_MONADIC_MTRY_H
+
+#include "expected.h"
+
+namespace zyppng {
+
+ template < typename F
+ , typename Ret = typename std::result_of<F()>::type
+ , typename Exp = expected<Ret, std::exception_ptr>
+ >
+ Exp mtry(F f)
+ {
+ try {
+ return Exp::success(f());
+ } catch (...) {
+ return Exp::error(std::current_exception());
+ }
+ }
+
+}
+
+#endif /* !MTRY_H */
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_REDO_H_INCLUDED
+#define ZYPPNG_MONADIC_REDO_H_INCLUDED
+
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+#include <zypp-core/zyppng/meta/FunctionTraits>
+#include <zypp-core/zyppng/meta/TypeTraits>
+#include <zypp-core/zyppng/meta/Functional>
+
+namespace zyppng {
+
+ namespace detail {
+
+
+ template< typename Task, typename Pred, typename = void >
+ struct RedoWhileImpl
+ {
+
+ static_assert ( !is_async_op< zyppng::remove_smart_ptr<Pred> >::value, "" );
+
+ template <typename T, typename P>
+ RedoWhileImpl( T &&t, P &&p ) :
+ _task( std::forward<T>(t) )
+ , _pred( std::forward<P>(p) ) {}
+
+ template <typename Arg>
+ std::enable_if_t< is_async_op< remove_smart_ptr_t<std::result_of_t<Task(Arg)>> >::value == false, Arg > operator()( Arg &&arg ) {
+ Arg store = std::forward<Arg>(arg);
+ do {
+ auto res = _task ( Arg(store) );
+ if ( !_pred( res ) )
+ return std::move(res);
+ } while( true );
+ }
+
+ template <typename T, typename P>
+ static auto create ( T &&t, P &&p ) {
+ return RedoWhileImpl( std::forward<T>(t), std::forward<P>(p));
+ }
+
+ private:
+ Task _task;
+ Pred _pred;
+ };
+
+ template< typename MyAsyncOp, typename Pred >
+ struct RedoWhileImpl< std::unique_ptr<MyAsyncOp>,Pred, std::enable_if_t< is_async_op< MyAsyncOp >::value > > : public AsyncOp<typename MyAsyncOp::value_type> {
+
+ using Task = std::unique_ptr<MyAsyncOp>;
+ using OutType = typename MyAsyncOp::value_type;
+
+ template <typename T, typename P>
+ RedoWhileImpl( T &&t, P &&p ) :
+ _task( std::forward<T>(t) )
+ , _pred( std::forward<P>(p) ) {}
+
+ static_assert ( !is_async_op< remove_smart_ptr<Pred> >::value, "" );
+
+ template<typename InType>
+ void operator()( InType &&arg ) {
+ _task->onReady(
+ [this, inArg = arg]( OutType &&a) mutable {
+ if ( _pred(a) )
+ this->operator()(std::move(inArg));
+ else
+ this->setReady( std::move(a) );
+ }
+ );
+ _task->operator()( InType(arg) );
+ }
+
+ template <typename T, typename P>
+ static auto create ( T &&t, P &&p ) {
+ return std::make_unique<RedoWhileImpl>( std::forward<T>(t), std::forward<P>(p));
+ }
+
+ private:
+
+ Task _task;
+ Pred _pred;
+ std::unique_ptr<AsyncOp<OutType>> _pipeline;
+ };
+
+ //implementation for a function returning a asynchronous result
+ template< typename Task, typename Pred >
+ struct RedoWhileImpl< Task,Pred, std::enable_if_t< is_async_op< remove_smart_ptr_t<typename function_traits<Task>::return_type> >::value > > : public AsyncOp< typename remove_smart_ptr_t<typename function_traits<Task>::return_type>::value_type> {
+
+ using FunRet = remove_smart_ptr_t<typename function_traits<Task>::return_type>;
+
+ //the task function needs to return the same type it takes
+ using OutType = typename FunRet::value_type;
+
+ template <typename T, typename P>
+ RedoWhileImpl( T &&t, P &&p ) :
+ _task( std::forward<T>(t) )
+ , _pred( std::forward<P>(p) ) {}
+
+ template<typename InType>
+ void operator() ( InType &&arg ) {
+ _asyncRes.reset(nullptr);
+ _asyncRes = _task( InType( arg ) );
+ _asyncRes->onReady(
+ [this, inArg = arg ]( OutType &&arg ) mutable {
+ if ( _pred(arg) )
+ this->operator()( std::move(inArg) );
+ else
+ this->setReady( std::move(arg) );
+ });
+ }
+
+ template <typename T, typename P>
+ static auto create ( T &&t, P &&p ) {
+ return std::make_unique<RedoWhileImpl>( std::forward<T>(t), std::forward<P>(p));
+ }
+
+ private:
+ std::unique_ptr<AsyncOp<OutType>> _asyncRes;
+
+ Task _task;
+ Pred _pred;
+ };
+
+ //check if its possible to query the given type for function_traits
+ template <typename T>
+ using has_func_trait = typename function_traits<T>::return_type;
+
+ }
+
+ template <typename Task, typename Pred>
+ auto redo_while ( Task &&todo, Pred &&until )
+ {
+ static_assert ( std::is_detected_v< detail::has_func_trait, Task >, "Not possible to deduce the function_traits for Task, maybe a generic lambda?" );
+ return detail::RedoWhileImpl<Task,Pred>::create( std::forward<Task>(todo), std::forward<Pred>(until) );
+ }
+
+}
+
+#endif
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*/
+
+
+#ifndef ZYPP_ZYPPNG_MONADIC_TRANSFORM_H
+#define ZYPP_ZYPPNG_MONADIC_TRANSFORM_H
+
+#include <zypp-core/zyppng/meta/TypeTraits>
+#include <zypp-core/zyppng/meta/Functional>
+#include <algorithm>
+#include <vector>
+
+namespace zyppng {
+
+template < template< class, class... > class Container,
+ typename Msg,
+ typename Transformation,
+ typename Ret = std::result_of_t<Transformation(Msg)>,
+ typename ...CArgs >
+Container<Ret> transform( Container<Msg, CArgs...>&& val, Transformation transformation )
+{
+ Container<Ret> res;
+ std::transform( std::make_move_iterator(val.begin()), std::make_move_iterator(val.end()), std::back_inserter(res), transformation );
+ return std::move(res);
+}
+
+namespace detail {
+ template <typename Transformation>
+ struct transform_helper {
+ Transformation function;
+
+ template<template< class, class... > class Container, typename Msg, typename ...CArgs>
+ auto operator()( Container<Msg, CArgs...>&& arg ) {
+ return zyppng::transform( std::forward< Container<Msg,CArgs...> >(arg), function );
+ }
+ };
+}
+
+namespace operators {
+
+ template <typename Transformation>
+ auto transform(Transformation&& transformation)
+ {
+ return detail::transform_helper<Transformation>{
+ std::forward<Transformation>(transformation)};
+ }
+}
+
+}
+
+#endif
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*/
+
+#ifndef ZYPP_ZYPPNG_MONADIC_WAIT_H
+#define ZYPP_ZYPPNG_MONADIC_WAIT_H
+
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+
+namespace detail {
+
+ template < class AsyncOp,
+ class InnerResult = typename AsyncOp::value_type
+ >
+ struct WaitForImpl : public zyppng::AsyncOp< std::vector<InnerResult> > {
+
+ WaitForImpl () = default;
+
+ WaitForImpl ( const WaitForImpl &other ) = delete;
+ WaitForImpl& operator= ( const WaitForImpl &other ) = delete;
+
+ WaitForImpl& operator= ( WaitForImpl &&other ) = default;
+ WaitForImpl ( WaitForImpl &&other ) = default;
+
+ void operator()( std::vector< std::unique_ptr< AsyncOp > > &&ops ) {
+ assert( _allOps.empty() );
+
+ _allOps = std::move( ops );
+ for ( auto &op : _allOps ) {
+ op->onReady( [ this ]( typename AsyncOp::value_type &&res ) {
+ this->resultReady( std::move(res));
+ });
+ }
+
+ }
+
+ private:
+
+ void resultReady ( InnerResult &&res ) {
+ _allResults.push_back( std::move( res ) );
+ if ( _allOps.size() == _allResults.size() ) {
+ //release all ops we waited on
+ _allOps.clear();
+
+ this->setReady( std::move(_allResults) );
+ }
+ }
+
+ std::vector< std::unique_ptr<zyppng::AsyncOp<InnerResult>> > _allOps;
+ std::vector< InnerResult > _allResults;
+ };
+
+}
+
+/*!
+ * Returns a async operation that waits for all async operations that are passed to it and collects their results,
+ * forwarding them as one
+ */
+template < class Res >
+auto waitFor () {
+ return std::make_unique<detail::WaitForImpl<zyppng::AsyncOp<Res>>>();
+}
+
+
+#endif
--- /dev/null
+# Collect all files that may contain translatable texts
+FILE( GLOB_RECURSE POT_FILE_DEPENDS RELATIVE ${LIBZYPP_SOURCE_DIR} "*.h" "*.cc" )
+SET( POT_FILE_DEPENDS_ZYPP_CURL ${POT_FILE_DEPENDS} PARENT_SCOPE )
+
+INCLUDE_DIRECTORIES ( ${LIBZYPP_SOURCE_DIR} )
+
+ADD_DEFINITIONS( -DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL )
+
+SET( zypp_curl_HEADERS
+ CurlConfig
+ curlconfig.h
+ ProxyInfo
+ proxyinfo.h
+ TransferSettings
+ transfersettings.h
+)
+
+SET( zypp_curl_private_HEADERS
+ private/curlhelper_p.h
+)
+
+SET( zypp_curl_SRCS
+ curlconfig.cc
+ proxyinfo.cc
+ curlhelper.cc
+ transfersettings.cc
+)
+
+INSTALL( FILES ${zypp_curl_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-curl" )
+
+SET( zypp_curl_auth_HEADERS
+ auth/CurlAuthData
+ auth/curlauthdata.h
+)
+
+SET( zypp_curl_auth_private_HEADERS
+)
+
+SET( zypp_curl_auth_SRCS
+ auth/curlauthdata.cc
+)
+
+INSTALL( FILES ${zypp_curl_auth_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-curl/auth" )
+
+IF ( LIBPROXY_FOUND )
+ SET(zypp_curl_proxyinfo_libproxy_SRCS proxyinfo/proxyinfolibproxy.cc)
+ SET(zypp_curl_proxyinfo_libproxy_HEADERS proxyinfo/ProxyInfoLibproxy proxyinfo/proxyinfolibproxy.h)
+ENDIF( LIBPROXY_FOUND )
+
+SET( zypp_curl_proxyinfo_SRCS
+ proxyinfo/proxyinfosysconfig.cc
+ ${zypp_curl_proxyinfo_libproxy_SRCS}
+)
+
+SET( zypp_curl_proxyinfo_HEADERS
+ proxyinfo/proxyinfoimpl.h
+ proxyinfo/ProxyInfoSysconfig
+ proxyinfo/proxyinfosysconfig.h
+ ${zypp_curl_proxyinfo_libproxy_HEADERS}
+ proxyinfo/proxyinfos.h
+)
+
+INSTALL( FILES ${zypp_curl_proxyinfo_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/zypp-curl/proxyinfo )
+
+SET( zypp_curl_ng_network_SRCS
+ ng/network/downloader.cc
+ ng/network/downloadspec.cc
+ ng/network/mirrorcontrol.cc
+ ng/network/networkrequestdispatcher.cc
+ ng/network/networkrequesterror.cc
+ ng/network/request.cc
+)
+
+SET( zypp_curl_ng_network_HEADERS
+ ng/network/AuthData
+ ng/network/authdata.h
+ ng/network/Downloader
+ ng/network/downloader.h
+ ng/network/DownloadSpec
+ ng/network/downloadspec.h
+ ng/network/NetworkRequestDispatcher
+ ng/network/networkrequestdispatcher.h
+ ng/network/NetworkRequestError
+ ng/network/networkrequesterror.h
+ ng/network/Request
+ ng/network/request.h
+ ng/network/TransferSettings
+ ng/network/transfersettings.h
+)
+
+SET( zypp_curl_ng_network_private_HEADERS
+ ng/network/private/downloader_p.h
+ ng/network/private/mediadebug_p.h
+ ng/network/private/mirrorcontrol_p.h
+ ng/network/private/networkrequestdispatcher_p.h
+ ng/network/private/networkrequesterror_p.h
+ ng/network/private/request_p.h
+ ng/network/private/downloaderstates/base_p.h
+ ng/network/private/downloaderstates/basicdownloader_p.h
+ ng/network/private/downloaderstates/detectmeta_p.h
+ ng/network/private/downloaderstates/final_p.h
+ ng/network/private/downloaderstates/initial_p.h
+ ng/network/private/downloaderstates/metalinkinfo_p.h
+ ng/network/private/downloaderstates/metalink_p.h
+ ng/network/private/downloaderstates/mirrorhandling_p.h
+ ng/network/private/downloaderstates/normal_p.h
+ ng/network/private/downloaderstates/preparemulti_p.h
+ ng/network/private/downloaderstates/rangedownloader_p.h
+ ng/network/private/downloaderstates/zck_p.h
+)
+
+SET( zypp_curl_ng_network_private_SOURCES
+ ng/network/private/downloaderstates/basicdownloader_p.cc
+ ng/network/private/downloaderstates/detectmeta_p.cc
+ ng/network/private/downloaderstates/final_p.cc
+ ng/network/private/downloaderstates/initial_p.cc
+ ng/network/private/downloaderstates/metalinkinfo_p.cc
+ ng/network/private/downloaderstates/metalink_p.cc
+ ng/network/private/downloaderstates/mirrorhandling_p.cc
+ ng/network/private/downloaderstates/normal_p.cc
+ ng/network/private/downloaderstates/preparemulti_p.cc
+ ng/network/private/downloaderstates/rangedownloader_p.cc
+ ng/network/private/downloaderstates/zck_p.cc
+)
+
+# ng files are not installed yet
+# INSTALL( FILES ${zypp_curl_ng_network_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/zypp-curl/ng/network )
+
+SET( zypp_curl_parser_HEADERS
+ parser/MediaBlockList
+ parser/mediablocklist.h
+ parser/MetaLinkParser
+ parser/metalinkparser.h
+)
+
+SET( zypp_curl_parser_private_HEADERS
+)
+
+SET( zypp_curl_parser_SRCS
+ parser/mediablocklist.cc
+ parser/metalinkparser.cc
+)
+
+INSTALL( FILES ${zypp_curl_parser_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-curl/parser" )
+
+
+ADD_LIBRARY( zypp-curl STATIC
+ ${zypp_curl_SRCS} ${zypp_curl_private_HEADERS} ${zypp_curl_HEADERS}
+ ${zypp_curl_auth_SRCS} ${zypp_curl_auth_private_HEADERS} ${zypp_curl_auth_HEADERS}
+ ${zypp_curl_ng_network_SRCS} ${zypp_curl_ng_network_HEADERS} ${zypp_curl_ng_network_private_HEADERS} ${zypp_curl_ng_network_private_SOURCES}
+ ${zypp_curl_parser_SRCS} ${zypp_curl_parser_private_HEADERS} ${zypp_curl_parser_HEADERS}
+ ${zypp_curl_proxyinfo_HEADERS} ${zypp_curl_proxyinfo_SRCS}
+ )
+#we include generated headers, so we need to wait for zypp-protobuf to be ready
+add_dependencies( zypp-curl zypp-protobuf )
--- /dev/null
+#include "curlconfig.h"
--- /dev/null
+#include "proxyinfo.h"
--- /dev/null
+#include "curlauthdata.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/auth/curlauthdata.cc
+ *
+*/
+
+#include "curlauthdata.h"
+
+#include <zypp-core/base/Gettext.h>
+#include <zypp-core/base/String.h>
+#include <zypp-media/MediaException>
+
+#include <curl/curl.h>
+
+
+using std::endl;
+
+namespace zypp::media {
+
+ CurlAuthData::CurlAuthData()
+ : AuthData()
+ , _auth_type_str()
+ , _auth_type(CURLAUTH_NONE)
+ {}
+
+ CurlAuthData::CurlAuthData(const AuthData & authData)
+ : AuthData(authData)
+ , _auth_type_str()
+ , _auth_type(CURLAUTH_NONE)
+ {}
+
+ bool CurlAuthData::valid() const
+ {
+ return username().size() && password().size();
+ }
+
+ std::ostream & CurlAuthData::dumpOn( std::ostream & str ) const
+ {
+ AuthData::dumpOn(str) << endl
+ << " auth_type: " << _auth_type_str << " (" << _auth_type << ")";
+ return str;
+ }
+
+ long CurlAuthData::auth_type_str2long( std::string & auth_type_str )
+ {
+ return auth_type_str2long( const_cast< const std::string &>(auth_type_str) );
+ }
+
+ long CurlAuthData::auth_type_str2long( const std::string & auth_type_str )
+ {
+ curl_version_info_data *curl_info = curl_version_info(CURLVERSION_NOW);
+
+ std::vector<std::string> list;
+ std::vector<std::string>::const_iterator it;
+ long auth_type = CURLAUTH_NONE;
+
+ zypp::str::split(auth_type_str, std::back_inserter(list), ",");
+
+ for(it = list.begin(); it != list.end(); ++it)
+ {
+ if(*it == "basic")
+ {
+ auth_type |= CURLAUTH_BASIC;
+ }
+ else
+ if(*it == "digest")
+ {
+ auth_type |= CURLAUTH_DIGEST;
+ }
+ else
+ if((curl_info && (curl_info->features & CURL_VERSION_NTLM)) &&
+ (*it == "ntlm"))
+ {
+ auth_type |= CURLAUTH_NTLM;
+ }
+ else
+ if((curl_info && (curl_info->features & CURL_VERSION_SPNEGO)) &&
+ (*it == "spnego" || *it == "negotiate"))
+ {
+ // there is no separate spnego flag for this auth type
+ auth_type |= CURLAUTH_GSSNEGOTIATE;
+ }
+ else
+ if((curl_info && (curl_info->features & CURL_VERSION_GSSNEGOTIATE)) &&
+ (*it == "gssnego" || *it == "negotiate"))
+ {
+ auth_type |= CURLAUTH_GSSNEGOTIATE;
+ }
+ else
+ {
+ ZYPP_THROW(MediaException(str::Format(_("Unsupported HTTP authentication method '%s'")) % *it));
+ }
+ }
+
+ return auth_type;
+ }
+
+ std::string CurlAuthData::auth_type_long2str(long auth_type)
+ {
+ std::list<std::string> auth_list;
+
+ if(auth_type & CURLAUTH_GSSNEGOTIATE)
+ auth_list.push_back("negotiate");
+
+ if(auth_type & CURLAUTH_NTLM)
+ auth_list.push_back("ntlm");
+
+ if(auth_type & CURLAUTH_DIGEST)
+ auth_list.push_back("digest");
+
+ if(auth_type & CURLAUTH_BASIC)
+ auth_list.push_back("basic");
+
+ return str::join(auth_list, ",");
+ }
+
+ std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data)
+ {
+ auth_data.dumpOn(str);
+ return str;
+ }
+
+}
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/auth/CurlAuthData
+ *
+*/
+#ifndef ZYPP_CURL_AUTH_CURLAUTHDATA_H_INCLUDED
+#define ZYPP_CURL_AUTH_CURLAUTHDATA_H_INCLUDED
+
+#include <zypp-media/auth/AuthData>
+
+namespace zypp {
+ namespace media {
+ /**
+ * Curl HTTP authentication data.
+ */
+ class CurlAuthData : public AuthData {
+ public:
+ /**
+ * Default constructor. Initializes username and password to empty strings
+ * and authetication type to CURLAUTH_NONE.
+ */
+ CurlAuthData();
+
+ CurlAuthData(const AuthData & authData);
+
+ CurlAuthData(std::string & username, std::string & password, std::string & auth_type)
+ : AuthData(username,password), _auth_type_str(auth_type)
+ {
+ _auth_type = auth_type_str2long(auth_type);
+ }
+
+ CurlAuthData(std::string & username, std::string & password, long auth_type)
+ : AuthData(username,password), _auth_type(auth_type)
+ {
+ _auth_type_str = auth_type_long2str(auth_type);
+ }
+
+ /**
+ * Checks validity of authentication data.
+ * \return true if the object contains non-empty username,
+ * non-empty password, and specifies authentication type; false otherwise.
+ */
+ virtual bool valid() const;
+
+ /**
+ * Set HTTP authentication type(s) to use.
+ * \param comma separated list of HTTP authentication type names
+ */
+ void setAuthType(std::string auth_type)
+ {
+ _auth_type_str = auth_type; _auth_type = auth_type_str2long(auth_type);
+ }
+
+ /**
+ * Set HTTP authentication type(s) to use.
+ * \param HTTP authentication type as in long ORed form.
+ * \see curl.h for available auth types
+ */
+ void setAuthType(long auth_type)
+ {
+ _auth_type = auth_type;
+ _auth_type_str = auth_type_long2str(auth_type);
+ }
+
+ long authType() const { return _auth_type; }
+ std::string authTypeAsString() const { return _auth_type_str; }
+
+ std::string getUserPwd() const { return username() + ":" + password(); }
+
+
+ /**
+ * Converts a string of comma separated list of authetication type names
+ * into a long of ORed CURLAUTH_* identifiers.
+ * The method also automatically leaves out any auth types declared
+ * not supported by curl_version_info().
+ *
+ * \throws MediaException if an invalid authentication type name is
+ * encountered.
+ */
+ static long auth_type_str2long( std::string & auth_type_str );
+ static long auth_type_str2long( const std::string &auth_type_str );
+
+ /**
+ * Converts a long of ORed CURLAUTH_* identifiers into a string of comma
+ * separated list of authentication type names.
+ */
+ static std::string auth_type_long2str(long auth_type);
+
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+ private:
+ std::string _auth_type_str;
+ long _auth_type;
+ };
+
+ typedef shared_ptr<CurlAuthData> CurlAuthData_Ptr;
+ std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data);
+ }
+}
+
+#endif
#include <iostream>
#include <fstream>
-#include <zypp/base/Logger.h>
-#include <zypp/base/IOStream.h>
-#include <zypp/Pathname.h>
-#include <zypp/PathInfo.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/IOStream.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/fs/PathInfo.h>
-#include <zypp/media/CurlConfig.h>
+#include <zypp-curl/CurlConfig>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/CurlConfig
+*/
+#ifndef ZYPP_CURL_CURLCONFIG_H_INCLUDED
+#define ZYPP_CURL_CURLCONFIG_H_INCLUDED
+
+//#include <zypp/base/NonCopyable.h>
+#include <zypp-core/base/String.h>
+
+namespace zypp
+{
+ namespace media
+ {
+
+
+ /**
+ * Structure holding values of curlrc options.
+ */
+ struct CurlConfig
+ {
+ public:
+ /**
+ * Parse a curlrc file and store the result in the \a config structure.
+ *
+ * \param config a CurlConfig structure
+ * \param filename path to the curlrc file. If empty, ~/.curlrc is used.
+ * \return 0 on success, 1 if problem occurs.
+ */
+ static int parseConfig(CurlConfig & config, const std::string & filename = "");
+
+ /**
+ * Stores the \a value of the \a option in the \a config structure or
+ * logs an unknown option.
+ *
+ * \return 0 on success, 1 if problem occurs.
+ */
+ static int setParameter(CurlConfig & config,
+ const std::string & option,
+ const std::string & value);
+
+ public:
+ std::string proxyuserpwd;
+ // add more curl config data here as they become needed
+ };
+
+
+ } // namespace media
+} // namespace zypp
+
+#endif /*ZYPP_CURL_CURLCONFIG_H_INCLUDED*/
-#include "CurlHelper.h"
-
-#include <zypp/PathInfo.h>
-#include <zypp/Pathname.h>
-#include <zypp/Target.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/MediaException.h>
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/curlhelper.cc
+ *
+*/
+#include "private/curlhelper_p.h"
+
+#include <zypp/APIConfig.h>
+
+#include <zypp-core/fs/PathInfo.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/auth/CurlAuthData>
+#include <zypp-media/MediaException>
#include <list>
using std::endl;
} (), true );
}
-int log_curl(CURL *curl, curl_infotype info,
+int log_curl(CURL *, curl_infotype info,
char *ptr, size_t len, void *max_lvl)
{
if ( max_lvl == nullptr )
}
}
-
-const char * anonymousIdHeader()
-{
- // we need to add the release and identifier to the
- // agent string.
- // The target could be not initialized, and then this information
- // is guessed.
- static const std::string _value(
- str::trim( str::form(
- "X-ZYpp-AnonymousId: %s",
- Target::anonymousUniqueId( Pathname()/*guess root*/ ).c_str() ) )
- );
- return _value.c_str();
-}
-
-const char * distributionFlavorHeader()
-{
- // we need to add the release and identifier to the
- // agent string.
- // The target could be not initialized, and then this information
- // is guessed.
- static const std::string _value(
- str::trim( str::form(
- "X-ZYpp-DistributionFlavor: %s",
- Target::distributionFlavor( Pathname()/*guess root*/ ).c_str() ) )
- );
- return _value.c_str();
-}
-
-const char * agentString()
-{
- // we need to add the release and identifier to the
- // agent string.
- // The target could be not initialized, and then this information
- // is guessed.
- static const std::string _value(
- str::form(
- "ZYpp " LIBZYPP_VERSION_STRING " (curl %s) %s"
- , curl_version_info(CURLVERSION_NOW)->version
- , Target::targetDistribution( Pathname()/*guess root*/ ).c_str()
- )
- );
- return _value.c_str();
-}
-
void curlEscape( std::string & str_r,
const char char_r, const std::string & escaped_r ) {
for ( std::string::size_type pos = str_r.find( char_r );
// bsc#933839: propagate proxy settings passed in the repo URL
zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r )
{
- for ( std::string param : { "proxy", "proxyport", "proxyuser", "proxypass"} )
+ for ( const std::string ¶m : { "proxy", "proxyport", "proxyuser", "proxypass"} )
{
const std::string & value( template_r.getQueryParam( param ) );
if ( ! value.empty() )
return url_r;
}
-ProgressData::ProgressData(CURL *_curl, time_t _timeout, const Url &_url, ByteCount expectedFileSize_r, zypp::callback::SendReport< zypp::media::DownloadProgressReport> *_report)
-: curl( _curl )
-, url( _url )
-, timeout( _timeout )
-, reached( false )
-, fileSizeExceeded ( false )
-, report( _report )
-, _expectedFileSize( expectedFileSize_r )
-{}
-
-void ProgressData::updateStats(double dltotal, double dlnow)
-{
- time_t now = _timeNow = time(0);
-
- // If called without args (0.0), recompute based on the last values seen
- if ( dltotal && dltotal != _dnlTotal )
- _dnlTotal = dltotal;
-
- if ( dlnow && dlnow != _dnlNow )
- {
- _timeRcv = now;
- _dnlNow = dlnow;
- }
- else if ( !_dnlNow && !_dnlTotal )
- {
- // Start time counting as soon as first data arrives.
- // Skip the connection / redirection time at begin.
- return;
- }
-
- // init or reset if time jumps back
- if ( !_timeStart || _timeStart > now )
- _timeStart = _timeLast = _timeRcv = now;
-
- // timeout condition
- if ( timeout )
- reached = ( (now - _timeRcv) > timeout );
-
- // check if the downloaded data is already bigger than what we expected
- fileSizeExceeded = _expectedFileSize > 0 && _expectedFileSize < static_cast<ByteCount::SizeType>(_dnlNow);
-
- // percentage:
- if ( _dnlTotal )
- _dnlPercent = int(_dnlNow * 100 / _dnlTotal);
-
- // download rates:
- _drateTotal = _dnlNow / std::max( int(now - _timeStart), 1 );
-
- if ( _timeLast < now )
- {
- _drateLast = (_dnlNow - _dnlLast) / int(now - _timeLast);
- // start new period
- _timeLast = now;
- _dnlLast = _dnlNow;
- }
- else if ( _timeStart == _timeLast )
- _drateLast = _drateTotal;
-}
-
-int ProgressData::reportProgress() const
-{
- if ( fileSizeExceeded )
- return 1;
- if ( reached )
- return 1; // no-data timeout
- if ( report && !(*report)->progress( _dnlPercent, url, _drateTotal, _drateLast ) )
- return 1; // user requested abort
- return 0;
-}
-
}
--- /dev/null
+#include "downloadspec.h"
--- /dev/null
+#include "downloader.h"
--- /dev/null
+#include "mirrorcontrol.h"
--- /dev/null
+#include "networkrequestdispatcher.h"
--- /dev/null
+#include "networkrequesterror.h"
--- /dev/null
+#include "request.h"
--- /dev/null
+#include "transfersettings.h"
#ifndef ZYPPNG_MEDIA_NETWORK_AUTHDATA_H_INCLUDED
#define ZYPPNG_MEDIA_NETWORK_AUTHDATA_H_INCLUDED
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-curl/auth/CurlAuthData>
namespace zyppng {
| /_____||_| |_| |_| |
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/media/TransferSettings.h>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/MediaException.h>
-#include <zypp/base/String.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/ZConfig.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
+#include <zypp-curl/TransferSettings>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-media/MediaException>
+#include <zypp-core/base/String.h>
namespace zyppng {
bool DownloadPrivateBase::handleRequestAuthError( std::shared_ptr<Request> req, const zyppng::NetworkRequestError &err )
{
- //Handle the auth errors explicitely, we need to give the user a way to put in new credentials
+ //Handle the auth errors explicitly, we need to give the user a way to put in new credentials
//if we get valid new credentials we can retry the request
bool retry = false;
if ( err.type() == NetworkRequestError::Unauthorized || err.type() == NetworkRequestError::AuthFailed ) {
MIL << "Authentication failed for " << req->url() << " trying to recover." << std::endl;
- zypp::media::CredentialManager cm( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
+ zypp::media::CredentialManager cm( _parent ? _parent->credManagerOptions() : zypp::media::CredManagerOptions() );
auto authDataPtr = cm.getCred( req->url() );
// get stored credentials
if ( set.authType() == "basic"
&& set.username().size()
&& !set.password().size() ) {
- zypp::media::CredentialManager cm( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
+ zypp::media::CredentialManager cm( _parent ? _parent->credManagerOptions() : zypp::media::CredManagerOptions() );
const auto cred = cm.getCred( url );
if ( cred && cred->valid() ) {
if ( !set.username().size() )
void Download::cancel()
{
Z_D();
- d->forceState ( std::make_unique<FinishedState>( NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, "Download was cancelled explicitely" ), *d_func() ) );
+ d->forceState ( std::make_unique<FinishedState>( NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, "Download was cancelled explicitly" ), *d_func() ) );
}
DownloadSpec &Download::spec()
}
}
+ const zypp::media::CredManagerOptions &Downloader::credManagerOptions() const
+ {
+ return d_func()->_credManagerOptions;
+ }
+
+ void Downloader::setCredManagerOptions(const zypp::media::CredManagerOptions &options)
+ {
+ d_func()->_credManagerOptions = options;
+ }
+
std::shared_ptr<Download> Downloader::downloadFile(const zyppng::DownloadSpec &spec )
{
Z_D();
#include <zypp-core/zyppng/base/Base>
#include <zypp-core/zyppng/base/signals.h>
#include <zypp-core/zyppng/core/Url>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/AuthData>
+#include <zypp-media/auth/CredentialManager>
+#include <zypp-curl/ng/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/AuthData>
-#include <zypp/ByteCount.h>
+#include <zypp-core/ByteCount.h>
namespace zypp::media {
class TransferSettings;
virtual ~Downloader();
/*!
+ * Returns the currently used CredentialManager options
+ */
+ const zypp::media::CredManagerOptions &credManagerOptions () const;
+
+ /*!
+ * Sets the options for the CredentialManager to retrieve auth data
+ */
+ void setCredManagerOptions ( const zypp::media::CredManagerOptions & options );
+
+ /*!
* Generates a new Download object in waiting state
*/
std::shared_ptr<Download> downloadFile ( const DownloadSpec &spec );
#include <zypp-core/zyppng/base/zyppglobal.h>
#include <zypp-core/zyppng/core/Url>
-#include <zypp/Pathname.h>
-#include <zypp/base/PtrTypes.h>
-#include <zypp/ByteCount.h>
-#include <zypp/CheckSum.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/ByteCount.h>
+#include <zypp-core/CheckSum.h>
+#include <zypp-curl/TransferSettings>
#include <optional>
| /_____||_| |_| |_| |
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/networkrequestdispatcher_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/private/request_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp/APIConfig.h>
+#include <zypp-curl/ng/network/private/networkrequestdispatcher_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/private/request_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include <zypp-core/zyppng/base/Timer>
#include <zypp-core/zyppng/base/SocketNotifier>
#include <zypp-core/zyppng/base/EventDispatcher>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-curl/private/curlhelper_p.h>
#include <assert.h>
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
-#include <zypp/base/DtorReset.h>
+#include <zypp-core/base/DtorReset>
using namespace boost;
namespace zyppng {
+static const std::string & defaultAgentString()
+{
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is guessed.
+ static const std::string _value(
+ zypp::str::form(
+ "ZYpp " LIBZYPP_VERSION_STRING " (curl %s)"
+ , curl_version_info(CURLVERSION_NOW)->version
+ )
+ );
+ return _value;
+}
+
+
NetworkRequestDispatcherPrivate::NetworkRequestDispatcherPrivate( NetworkRequestDispatcher &p )
: BasePrivate( p )
, _timer( Timer::create() )
, _multi ( curl_multi_init() )
+ , _userAgent( defaultAgentString() )
{
::internal::globalInitCurlOnce();
d->dequeuePending();
}
+void NetworkRequestDispatcher::setAgentString( const std::string &agent )
+{
+ Z_D();
+ if ( agent.empty() )
+ d->_userAgent = defaultAgentString();
+ else
+ d->_userAgent = agent;
+}
+
+const std::string &NetworkRequestDispatcher::agentString() const
+{
+ return d_func()->_userAgent;
+}
+
+void NetworkRequestDispatcher::setHostSpecificHeader( const std::string &host, const std::string &headerName, const std::string &value )
+{
+ Z_D();
+ if ( value.empty() ) {
+ if ( auto i = d->_customHeaders.find( host ); i != d->_customHeaders.end() ) {
+ if ( auto v = i->second.find( headerName ); v != i->second.end() ) {
+ i->second.erase (v);
+ }
+ if ( i->second.empty() )
+ d->_customHeaders.erase(i);
+ }
+ return;
+ }
+ d->_customHeaders[host][headerName] = value;
+}
+
+const NetworkRequestDispatcher::SpecificHeaderMap &NetworkRequestDispatcher::hostSpecificHeaders() const
+{
+ return d_func()->_customHeaders;
+}
+
void NetworkRequestDispatcher::cancel( NetworkRequest &req, std::string reason )
{
- cancel( req, NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, reason.size() ? std::move(reason) : "Request explicitely cancelled" ) );
+ cancel( req, NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, reason.size() ? std::move(reason) : "Request explicitly cancelled" ) );
}
void NetworkRequestDispatcher::cancel(NetworkRequest &req, const NetworkRequestError &err)
#include <zypp-core/zyppng/base/signals.h>
#include <zypp-core/zyppng/core/Url>
#include <vector>
+#include <unordered_map>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/networkrequesterror.h>
namespace zyppng {
void enqueue ( const std::shared_ptr<NetworkRequest> &req );
/*!
+ * Changes the agent header valur to \a agent.
+ */
+ void setAgentString ( const std::string &agent );
+
+ /*!
+ * Returns the currenty set agent string
+ */
+ const std::string &agentString () const;
+
+ /*!
+ * Adds a header to each request to a specific host, this is used to send
+ * anonymous statistics to download.opensuse.org.
+ * Setting a host/headerName combination to a empty string removes the header from being send again.
+ *
+ * \note This will add the header to ALL requests that match the given host, for more fine grained control use \ref TransferSettings
+ * \note is empty by default
+ */
+ void setHostSpecificHeader ( const std::string &host, const std::string &headerName, const std::string &value );
+
+
+ using SpecificHeaderMap = std::unordered_map< std::string, std::unordered_map<std::string, std::string >>;
+
+ /*!
+ * Returns the currenty set host specific headers
+ */
+ const SpecificHeaderMap &hostSpecificHeaders() const;
+
+
+ /*!
* Cancels the request \a req setting the error description to \a reason.
*/
void cancel ( NetworkRequest &req , std::string reason = std::string() );
void cancel ( NetworkRequest &req , const NetworkRequestError &err );
/*!
- * Start dispatching requests, this needs to be done explicitely before any request can be executed.
+ * Start dispatching requests, this needs to be done explicitly before any request can be executed.
*/
void run ( );
| /_____||_| |_| |_| |
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-curl/private/curlhelper_p.h>
#include <zypp/base/Gettext.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-curl/auth/CurlAuthData>
#include <curl/curl.h>
namespace zyppng {
#define ZYPP_NG_MEDIA_CURL_NETWORK_REQUEST_ERROR_H_INCLUDED
#include <zypp-core/zyppng/base/zyppglobal.h>
-#include <zypp/base/PtrTypes.h>
+#include <zypp-core/base/PtrTypes.h>
#include <boost/any.hpp>
#include <string>
#include <map>
NotFound, //< The requested path in the URL does not exist on the server
Unauthorized, //<< No auth data given but authorization required
AuthFailed, //<< Auth data was given, but authorization failed
- ServerReturnedError, //<< A error was returned by the server that is not explicitely handled
+ ServerReturnedError, //<< A error was returned by the server that is not explicitly handled
MissingData //<< The download was a multirange download and we did not get all data that was requested, if that is returned some ranges might have been downloaded successful
};
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADER_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADER_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADER_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADER_P_H_INCLUDED
#include <zypp-core/zyppng/base/statemachine.h>
Signal< void ( Downloader &parent, Download& download )> _sigFinished;
Signal< void ( Downloader &parent )> _queueEmpty;
std::shared_ptr<MirrorControl> _mirrors;
+ zypp::media::CredManagerOptions _credManagerOptions; //< The credential manager options used to initialize the CredentialManager
};
}
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
#include <zypp-core/zyppng/base/private/base_p.h>
#include <zypp-core/zyppng/base/signals.h>
#include <zypp-core/TriBool.h>
-#include <zypp/zyppng/media/network/downloader.h>
-#include <zypp/zyppng/media/network/downloadspec.h>
+#include <zypp-curl/ng/network/Downloader>
+#include <zypp-curl/ng/network/DownloadSpec>
#include <zypp-core/zyppng/core/ByteArray>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/zyppng/media/network/TransferSettings>
-#include <zypp/zyppng/media/network/private/mirrorcontrol_p.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-curl/ng/network/TransferSettings>
+#include <zypp-curl/ng/network/private/mirrorcontrol_p.h>
+#include <zypp-curl/ng/network/networkrequesterror.h>
namespace zyppng {
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-core/fs/PathInfo.h>
#include "basicdownloader_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
#include "base_p.h"
#include "mirrorhandling_p.h"
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
#include "detectmeta_p.h"
#include "metalinkinfo_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
#include "base_p.h"
#include <zypp-core/zyppng/base/statemachine.h>
/*!
* State implementation for the metalink detection phase,
* this state issues a HEAD request while setting the magic
- * "Accept: *\/*, application/metalink+xml, application/metalink4+xml"
+ * "Accept: *\/\*, application/metalink+xml, application/metalink4+xml"
* header in the request to figure out if a metalink file is available or not.
*
* In order to use metalink support the server
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include "final_p.h"
namespace zyppng {
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
#include "base_p.h"
#include <zypp-core/zyppng/base/statemachine.h>
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include "initial_p.h"
#if ENABLE_ZCHUNK_COMPRESSION
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
#include "base_p.h"
#include <zypp-core/zyppng/base/statemachine.h>
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/PathInfo.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-core/fs/PathInfo.h>
#include "metalink_p.h"
#include "final_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
#include "base_p.h"
#include "rangedownloader_p.h"
#include <zypp-core/zyppng/base/statemachine.h>
-#include <zypp/media/MediaBlockList.h>
+#include <zypp-curl/parser/MediaBlockList>
namespace zyppng {
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/request_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/request_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
#include "metalinkinfo_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
#include "base_p.h"
#include "basicdownloader_p.h"
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include "mirrorhandling_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
#include <zypp-core/zyppng/base/statemachine.h>
#include "base_p.h"
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include "normal_p.h"
#include "final_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
#include "base_p.h"
#include "basicdownloader_p.h"
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-core/fs/PathInfo.h>
#include "preparemulti_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
#include "base_p.h"
#include <zypp-core/zyppng/base/statemachine.h>
-#include <zypp/media/MediaBlockList.h>
+#include <zypp-curl/parser/MediaBlockList>
namespace zyppng {
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
#include <zypp-core/AutoDispose.h>
+#include <zypp-core/fs/PathInfo.h>
#include "rangedownloader_p.h"
auto &parent = stateMachine();
- //Handle the auth errors explicitely, we need to give the user a way to put in new credentials
+ //Handle the auth errors explicitly, we need to give the user a way to put in new credentials
//if we get valid new credentials we can retry the request
if ( err.type() == NetworkRequestError::Unauthorized || err.type() == NetworkRequestError::AuthFailed ) {
retry = parent.handleRequestAuthError( req, err );
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
#include "base_p.h"
#include "mirrorhandling_p.h"
#if ENABLE_ZCHUNK_COMPRESSION
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
#include <zypp-core/AutoDispose.h>
#include "zck_p.h"
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
#include "base_p.h"
#include "basicdownloader_p.h"
#ifndef ZYPP_NG_MEDIADEBUG_H_INCLUDED
#define ZYPP_NG_MEDIADEBUG_H_INCLUDED
-#include <zypp/base/LogControl.h>
+#include <zypp-core/base/LogControl.h>
namespace zypp {
L_ENV_CONSTR_FWD_DECLARE_FUNC(ZYPP_MEDIA_CURL_DEBUG);
}
* You have been warned!
*
*/
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_MIRRORCONTROL_P_H
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_MIRRORCONTROL_P_H
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_MIRRORCONTROL_P_H
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_MIRRORCONTROL_P_H
#include <zypp-core/zyppng/core/Url>
#include <zypp-core/zyppng/base/Signals>
#include <zypp-core/zyppng/base/Base>
#include <zypp-core/zyppng/base/Timer>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-curl/parser/MetaLinkParser>
#include <vector>
#include <unordered_map>
}
-#endif // ZYPP_NG_MEDIA_HTTP_PRIVATE_MIRRORCONTROL_P_H
+#endif // ZYPP_CURL_NG_NETWORK_PRIVATE_MIRRORCONTROL_P_H
#ifndef ZYPP_NG_MEDIA_CURL_PRIVATE_CURL_P_H_INCLUDED
#define ZYPP_NG_MEDIA_CURL_PRIVATE_CURL_P_H_INCLUDED
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
#include <zypp-core/zyppng/base/private/base_p.h>
#include <curl/curl.h>
#include <deque>
#include <set>
+#include <unordered_map>
namespace zyppng {
NetworkRequestError _lastError;
+ std::string _userAgent;
+ std::unordered_map< std::string, std::unordered_map<std::string, std::string> > _customHeaders;
+
//signals
Signal< void ( NetworkRequestDispatcher &, NetworkRequest & )> _sigDownloadStarted;
Signal< void ( NetworkRequestDispatcher &, NetworkRequest & )> _sigDownloadFinished;
#ifndef ZYPP_NG_MEDIA_CURL_PRIVATE_NETWORKREQUESTERROR_P_H_INCLUDED
#define ZYPP_NG_MEDIA_CURL_PRIVATE_NETWORKREQUESTERROR_P_H_INCLUDED
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/networkrequesterror.h>
#include <map>
namespace zyppng {
#define ZYPP_NG_MEDIA_CURL_PRIVATE_REQUEST_P_H_INCLUDED
#include <zypp-core/zyppng/base/private/base_p.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-media/MediaException>
#include <zypp-core/zyppng/base/Timer>
-#include <zypp/base/Regex.h>
+#include <zypp-core/base/Regex.h>
#include <curl/curl.h>
#include <array>
#include <memory>
-#include <zypp/Digest.h>
-#include <zypp/AutoDispose.h>
+#include <zypp-core/Digest.h>
+#include <zypp-core/AutoDispose.h>
#include <boost/optional.hpp>
#include <variant>
| /_____||_| |_| |_| |
| |
----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/request_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/request_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include <zypp-core/zyppng/base/EventDispatcher>
#include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
#include <zypp-core/zyppng/core/String>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/CurlConfig.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/ZConfig.h>
-#include <zypp/base/String.h>
-#include <zypp/Pathname.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-curl/CurlConfig>
+#include <zypp-curl/auth/CurlAuthData>
+#include <zypp-media/MediaConfig>
+#include <zypp-core/base/String.h>
+#include <zypp-core/Pathname.h>
#include <curl/curl.h>
#include <stdio.h>
#include <fcntl.h>
//make a local copy of the settings, so headers are not added multiple times
TransferSettings locSet = _settings;
- // add custom headers for download.opensuse.org (bsc#955801)
- if ( _url.getHost() == "download.opensuse.org" )
- {
- locSet.addHeader( ::internal::anonymousIdHeader() );
- locSet.addHeader( ::internal::distributionFlavorHeader() );
+ if ( _dispatcher ) {
+ locSet.setUserAgentString( _dispatcher->agentString().c_str() );
+
+ // add custom headers as configured (bsc#955801)
+ const auto &cHeaders = _dispatcher->hostSpecificHeaders();
+ if ( auto i = cHeaders.find(_url.getHost()); i != cHeaders.end() ) {
+ for ( const auto &[key, value] : i->second ) {
+ locSet.addHeader( zypp::str::trim( zypp::str::form(
+ "%s: %s", key.c_str(), value.c_str() )
+ ));
+ }
+ }
}
locSet.addHeader("Pragma:");
- locSet.setTimeout( zypp::ZConfig::instance().download_transfer_timeout() );
+ locSet.setTimeout( zypp::MediaConfig::instance().download_transfer_timeout() );
locSet.setConnectTimeout( CONNECT_TIMEOUT );
- locSet.setUserAgentString( ::internal::agentString() );
-
{
char *ptr = getenv("ZYPP_MEDIA_CURL_DEBUG");
_curlDebug = (ptr && *ptr) ? zypp::str::strtonum<long>( ptr) : 0L;
return 0;
}
- //we always download a range even if its not explicitely requested
+ //we always download a range even if its not explicitly requested
if ( _requestedRanges.empty() ) {
_requestedRanges.push_back( NetworkRequest::Range() );
}
#ifndef ZYPP_NG_MEDIA_CURL_REQUEST_H_INCLUDED
#define ZYPP_NG_MEDIA_CURL_REQUEST_H_INCLUDED
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/TransferSettings>
+#include <zypp-curl/ng/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/TransferSettings>
#include <zypp-core/zyppng/base/Base>
#include <zypp-core/zyppng/core/Url>
#include <zypp-core/zyppng/core/ByteArray>
#include <zypp-core/zyppng/base/zyppglobal.h>
#include <zypp-core/zyppng/base/signals.h>
-#include <zypp/base/Flags.h>
-#include <zypp/ByteCount.h>
+#include <zypp-core/base/Flags.h>
+#include <zypp-core/ByteCount.h>
#include <optional>
#include <vector>
#include <chrono>
#ifndef ZYPPNG_MEDIA_HTTP_TRANSFERSETTINGS_H_INCLUDED
#define ZYPPNG_MEDIA_HTTP_TRANSFERSETTINGS_H_INCLUDED
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
namespace zyppng {
using TransferSettings = zypp::media::TransferSettings;
--- /dev/null
+#include "mediablocklist.h"
--- /dev/null
+#include "metalinkparser.h"
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaBlockList.cc
+/** \file zypp-curl/parser/mediablocklist.cc
*
*/
+#include "mediablocklist.h"
+
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
-#include <zypp/media/MediaBlockList.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
using namespace zypp::base;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/parser/MediaBlockList
+ *
+*/
+#ifndef ZYPP_CURL_PARSER_MEDIABLOCKLIST_H
+#define ZYPP_CURL_PARSER_MEDIABLOCKLIST_H
+
+#include <sys/types.h>
+#include <vector>
+#include <optional>
+
+#include <zypp-core/Digest.h>
+
+namespace zypp {
+ namespace media {
+
+/**
+ * a single block from the blocklist, consisting of an offset and a size
+ **/
+struct MediaBlock {
+ MediaBlock( off_t off_r, size_t size_r )
+ : off( off_r )
+ , size( size_r )
+ {}
+ off_t off;
+ size_t size;
+};
+
+class MediaBlockList {
+public:
+ MediaBlockList(off_t filesize=off_t(-1));
+
+ /**
+ * do we have a blocklist describing the file?
+ * set to true when addBlock() is called
+ **/
+ inline bool haveBlocks() const {
+ return haveblocks;
+ }
+ /**
+ * add a block with offset off and size size to the block list. Note
+ * that blocks must be ordered and must not overlap. returns the
+ * block number.
+ **/
+ size_t addBlock(off_t off, size_t size);
+
+ /**
+ * return the offset/size of a block with number blkno
+ **/
+ inline MediaBlock getBlock(size_t blkno) const {
+ return blocks[blkno];
+ }
+ /**
+ * return the number of blocks in the blocklist
+ **/
+ inline size_t numBlocks() const {
+ return blocks.size();
+ }
+
+ /**
+ * set / return the size of the whole file
+ **/
+ inline void setFilesize(off_t newfilesize=off_t(-1)) {
+ filesize = newfilesize;
+ }
+ inline off_t getFilesize() const {
+ return filesize;
+ }
+ inline bool haveFilesize() const {
+ return filesize != off_t(-1);
+ }
+
+ /**
+ * set / verify the checksum over the whole file
+ **/
+ void setFileChecksum(std::string ctype, int cl, unsigned char *c);
+ std::string fileChecksumType () const;
+
+ const UByteArray &getFileChecksum( );
+ bool createFileDigest(Digest &digest) const;
+ bool verifyFileDigest(Digest &digest) const;
+ inline bool haveFileChecksum() const {
+ return !fsumtype.empty() && fsum.size();
+ }
+
+ /**
+ * set / verify the (strong) checksum over a single block
+ **/
+ void setChecksum(size_t blkno, std::string cstype, int csl, unsigned char *cs, size_t cspad=0);
+ bool checkChecksum(size_t blkno, const unsigned char *buf, size_t bufl) const;
+ UByteArray getChecksum( size_t blkno ) const;
+ std::string getChecksumType( ) const;
+ bool createDigest(Digest &digest) const;
+ bool verifyDigest(size_t blkno, Digest &digest) const;
+ inline bool haveChecksum(size_t blkno) const {
+ return chksumlen && chksums.size() >= chksumlen * (blkno + 1);
+ }
+
+ /**
+ * set / verify the (weak) rolling checksum over a single block
+ **/
+ void setRsum(size_t blkno, int rsl, unsigned int rs, size_t rspad=0);
+ bool checkRsum(size_t blkno, const unsigned char *buf, size_t bufl) const;
+ unsigned int updateRsum(unsigned int rs, const char *bytes, size_t len) const;
+ bool verifyRsum(size_t blkno, unsigned int rs) const;
+ inline bool haveRsum(size_t blkno) const {
+ return rsumlen && rsums.size() >= blkno + 1;
+ }
+
+ /**
+ * scan a file for blocks from our blocklist. if we find a suitable block,
+ * it is removed from the list
+ **/
+ void reuseBlocks(FILE *wfp, std::string filename);
+
+ /**
+ * return block list as string
+ **/
+ std::string asString() const;
+
+private:
+ void writeBlock(size_t blkno, FILE *fp, const unsigned char *buf, size_t bufl, size_t start, std::vector<bool> &found) const;
+ bool checkChecksumRotated(size_t blkno, const unsigned char *buf, size_t bufl, size_t start) const;
+
+ off_t filesize;
+ std::string fsumtype;
+ UByteArray fsum;
+
+ bool haveblocks;
+ std::vector<MediaBlock> blocks;
+
+ std::string chksumtype;
+ int chksumlen;
+ size_t chksumpad;
+ std::vector<unsigned char> chksums;
+
+ std::string rsumtype;
+ int rsumlen;
+ size_t rsumpad;
+ std::vector<unsigned int> rsums;
+};
+
+inline std::ostream & operator<<(std::ostream &str, const MediaBlockList &bl)
+{ return str << bl.asString(); }
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_CURL_PARSER_MEDIABLOCKLIST_H
+
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/MetaLinkParser.cc
+/** \file zypp-curl/parser/metalinkparser.cc
*
*/
-#include <zypp/media/MetaLinkParser.h>
-#include <zypp/base/Logger.h>
-#include <zypp/ByteArray.h>
-#include <zypp/AutoDispose.h>
+#include "metalinkparser.h"
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/ByteArray.h>
+#include <zypp-core/AutoDispose.h>
#include <stack>
#include <vector>
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/parser/MetaLinkParser
+ *
+*/
+#ifndef ZYPP_CURL_PARSER_METALINKPARSER_H_INCLUDED
+#define ZYPP_CURL_PARSER_METALINKPARSER_H_INCLUDED
+
+#include <string>
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-curl/parser/MediaBlockList>
+#include <zypp-core/Url.h>
+#include <zypp-core/ByteArray.h>
+
+namespace zypp::media {
+
+struct ml_parsedata;
+
+struct MetalinkMirror {
+ int priority = 0;
+ int maxConnections = -1; //< How many connections can be opened to that mirror, -1 means no limit was defined.
+ Url url;
+};
+
+class MetaLinkParser : private zypp::base::NonCopyable {
+public:
+ MetaLinkParser();
+ ~MetaLinkParser();
+
+ /**
+ * parse a file consisting of metalink xml data
+ * \throws Exception
+ **/
+ void parse(const Pathname &filename);
+
+ /**
+ * parse an InputStream consisting of metalink xml data
+ * \throws Exception
+ **/
+ void parse(const InputStream &is);
+
+ /**
+ * parse a chunk of a file consisting of metalink xml data.
+ * \throws Exception
+ **/
+ void parseBytes(const char* bytes, size_t len);
+ /**
+ * tells the parser that all chunks are now processed
+ * \throws Exception
+ **/
+ void parseEnd();
+
+ /**
+ * return the download urls from the parsed metalink data
+ **/
+ std::vector<Url> getUrls() const;
+
+ /**
+ * return the mirrors from the parsed metalink data
+ */
+ const std::vector<MetalinkMirror> &getMirrors() const;
+
+ /**
+ * return the block list from the parsed metalink data
+ **/
+ MediaBlockList getBlockList() const;
+
+ const std::vector<UByteArray> &getZsyncBlockHashes() const;
+ const std::vector<UByteArray> &getSHA1BlockHashes() const;
+
+private:
+ struct ml_parsedata *pd;
+};
+
+UByteArray hexstr2bytes( std::string str );
+
+} // namespace zypp::media
+
+#endif // ZYPP_CURL_PARSER_METALINKPARSER_H_INCLUDED
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
+#define ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
+
+#include <curl/curl.h>
+#include <zypp-core/Url.h>
+#include <zypp-curl/TransferSettings>
+
+#define CONNECT_TIMEOUT 60
+#define TRANSFER_TIMEOUT_MAX 60 * 60
+#define DETECT_DIR_INDEX 0
+
+#define EXPLICITLY_NO_PROXY "_none_"
+
+#undef CURLVERSION_AT_LEAST
+#define CURLVERSION_AT_LEAST(M,N,O) LIBCURL_VERSION_NUM >= ((((M)<<8)+(N))<<8)+(O)
+
+namespace zypp
+{
+ namespace env
+ {
+ /** Long number for setting CURLOPT_DEBUGDATA */
+ inline long ZYPP_MEDIA_CURL_DEBUG()
+ {
+ long ret = 0L;
+ if ( char *ptr = ::getenv("ZYPP_MEDIA_CURL_DEBUG"); ptr && *ptr )
+ str::strtonum( ptr, ret );
+ return ret;
+ }
+
+ /** 4/6 to force IPv4/v6 */
+ int ZYPP_MEDIA_CURL_IPRESOLVE();
+ } // namespace env
+} //namespace zypp
+
+//do not export
+namespace internal {
+
+void globalInitCurlOnce();
+int log_curl(CURL *curl, curl_infotype info, char *ptr, size_t len, void *max_lvl);
+size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata);
+
+
+void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
+void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
+
+void curlEscape( std::string & str_r, const char char_r, const std::string & escaped_r );
+std::string curlEscapedPath( std::string path_r );
+std::string curlUnEscape( std::string text_r );
+
+zypp::Url clearQueryString(const zypp::Url &url);
+zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
+
+}
+
+#endif //ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/ProxyInfo.cc
+/** \file zypp-curl/ProxyInfo.cc
*
*/
+#include "proxyinfo.h"
#include <iostream>
#include <zypp/base/Logger.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/proxyinfo/ProxyInfoImpl.h>
-#include <zypp/media/proxyinfo/ProxyInfos.h>
+#include "proxyinfo/proxyinfoimpl.h"
+#include "proxyinfo/proxyinfos.h"
using namespace zypp::base;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/ProxyInfo
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_H_INCLUDED
+
+#include <string>
+#include <list>
+
+#include <zypp-core/base/PtrTypes.h>
+
+namespace zypp {
+
+ class Url;
+
+ namespace media {
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ProxyInfo
+ class ProxyInfo
+ {
+ public:
+ typedef intrusive_ptr<ProxyInfo> Ptr;
+ typedef intrusive_ptr<ProxyInfo> constPtr;
+ typedef std::list<std::string> NoProxyList;
+ typedef std::list<std::string>::const_iterator NoProxyIterator;
+
+ /** Implementation */
+ struct Impl;
+ typedef shared_ptr<Impl> ImplPtr;
+
+ /** Default Ctor: guess the best available implementation. */
+ ProxyInfo();
+ /** Ctor taking a specific implementation. */
+ ProxyInfo( ProxyInfo::ImplPtr pimpl_r );
+
+ bool enabled() const;
+ std::string proxy(const Url & url) const;
+ NoProxyList noProxy() const;
+ NoProxyIterator noProxyBegin() const;
+ NoProxyIterator noProxyEnd() const;
+
+ /** Return \c true if \ref enabled and \a url_r does not match \ref noProxy. */
+ bool useProxyFor( const Url & url_r ) const;
+
+ private:
+ /** Pointer to implementation */
+ RW_pointer<Impl> _pimpl;
+ };
+
+
+///////////////////////////////////////////////////////////////////
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_CURL_PROXYINFO_H_INCLUDED
--- /dev/null
+#include "proxyinfolibproxy.h"
--- /dev/null
+#include "proxyinfosysconfig.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/proxyinfo/proxyinfoimpl.h
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_PROXYINFOIMPL_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_PROXYINFOIMPL_H_INCLUDED
+
+#include <string>
+#include <list>
+
+#include <zypp-core/Url.h>
+#include <zypp-core/base/String.h>
+#include <zypp-curl/ProxyInfo>
+
+namespace zypp {
+ namespace media {
+
+ struct ProxyInfo::Impl
+ {
+ /** Ctor */
+ Impl()
+ {}
+
+ /** Dtor */
+ virtual ~Impl()
+ {}
+
+ public:
+ /** */
+ virtual bool enabled() const = 0;
+ /** */
+ virtual std::string proxy(const Url & url_r) const = 0;
+ /** */
+ virtual ProxyInfo::NoProxyList noProxy() const = 0;
+ /** */
+ virtual ProxyInfo::NoProxyIterator noProxyBegin() const = 0;
+ /** */
+ virtual ProxyInfo::NoProxyIterator noProxyEnd() const = 0;
+
+ /** Return \c true if \ref enabled and \a url_r does not match \ref noProxy. */
+ bool useProxyFor( const Url & url_r ) const
+ {
+ if ( ! enabled() || proxy( url_r ).empty() )
+ return false;
+
+ ProxyInfo::NoProxyList noproxy( noProxy() );
+ if ( noproxy.size() == 1 && noproxy.front() == "*" )
+ return false; // just an asterisk disables all.
+
+ // No proxy: Either an exact match, or the previous character
+ // is a '.', so host is within the same domain.
+ // A leading '.' in the pattern is ignored. Some implementations
+ // need '.foo.ba' to prevent 'foo.ba' from matching 'xfoo.ba'.
+ std::string host( str::toLower( url_r.getHost() ) );
+ for_( it, noproxy.begin(), noproxy.end() )
+ {
+ std::string pattern( str::toLower( (*it)[0] == '.' ? it->c_str() + 1 : it->c_str() ) );
+ if ( str::hasSuffix( host, pattern )
+ && ( host.size() == pattern.size()
+ || host[host.size()-pattern.size()-1] == '.' ) )
+ return false;
+ }
+ return true;
+ }
+
+ public:
+ /** Default Impl: empty sets. */
+ static shared_ptr<Impl> _nullimpl;
+ };
+
+
+///////////////////////////////////////////////////////////////////
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoLibproxy.cc
+/** \file zypp-curl/proxyinfo/proxyinfolibproxy.cc
*
*/
#include <iostream>
#include <fstream>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/WatchFile.h>
-#include <zypp/Pathname.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/fs/WatchFile>
+#include <zypp-core/Pathname.h>
-#include <zypp/media/proxyinfo/ProxyInfoLibproxy.h>
+#include <zypp-curl/proxyinfo/ProxyInfoLibproxy>
using std::endl;
using namespace zypp::base;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/media/proxyinfo/ProxyInfoLibproxy.h
+ *
+*/
+#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
+#define ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
+
+#include <string>
+#include <map>
+
+#include <proxy.h>
+
+#include <zypp-core/base/DefaultIntegral>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/proxyinfo/proxyinfoimpl.h>
+
+namespace zypp {
+ namespace media {
+
+
+ class ProxyInfoLibproxy : public ProxyInfo::Impl
+ {
+ public:
+ ProxyInfoLibproxy();
+ /** */
+ ~ProxyInfoLibproxy();
+ /** */
+ bool enabled() const
+ { return _enabled; }
+ /** */
+ std::string proxy(const Url & url_r) const;
+ /** */
+ ProxyInfo::NoProxyList noProxy() const
+ { return _no_proxy; }
+ /** */
+ virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
+ /** */
+ virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
+ private:
+ DefaultIntegral<bool,false> _enabled;
+ ProxyInfo::NoProxyList _no_proxy;
+ pxProxyFactory *_factory;
+ };
+
+///////////////////////////////////////////////////////////////////
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/proxyinfo/proxyinfos.h
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_PROXYINFOS_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_PROXYINFOS_H_INCLUDED
+
+#include <string>
+#include <list>
+
+#include <zypp-curl/proxyinfo/ProxyInfoSysconfig>
+#ifdef WITH_LIBPROXY_SUPPORT
+#include <zypp-curl/proxyinfo/ProxyInfoLibproxy>
+#endif
+
+#endif // ZYPP_CURL_PROXYINFO_PROXYINFOS_H_INCLUDED
*
*/
+#include "proxyinfosysconfig.h"
+
#include <iostream>
#include <fstream>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/Pathname.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/Pathname.h>
-#include <zypp/media/proxyinfo/ProxyInfoSysconfig.h>
using namespace zypp::base;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/proxyinfo/ProxyInfoSysconfig
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_PROXYINFOSYSCONFIG_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_PROXYINFOSYSCONFIG_H_INCLUDED
+
+#include <string>
+#include <map>
+
+#include <zypp-core/parser/Sysconfig>
+#include <zypp-core/base/DefaultIntegral>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/proxyinfo/proxyinfoimpl.h>
+
+namespace zypp {
+ namespace media {
+
+
+ class ProxyInfoSysconfig : public ProxyInfo::Impl
+ {
+ public:
+ ProxyInfoSysconfig(const Pathname & path);
+ /** */
+ bool enabled() const
+ { return _enabled; }
+ /** */
+ std::string proxy(const Url & url_r) const;
+ /** */
+ ProxyInfo::NoProxyList noProxy() const
+ { return _no_proxy; }
+ /** */
+ virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
+ /** */
+ virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
+ private:
+ DefaultIntegral<bool,false> _enabled;
+ ProxyInfo::NoProxyList _no_proxy;
+ std::map<std::string,std::string> _proxies;
+ };
+
+///////////////////////////////////////////////////////////////////
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_CURL_PROXYINFO_PROXYINFOSYSCONFIG_H_INCLUDED
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/transfersettings.cc
+ *
+*/
+
+#include "transfersettings.h"
#include <iostream>
#include <sstream>
-#include <zypp/base/String.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/WatchFile.h>
-#include <zypp/base/ReferenceCounted.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/ExternalProgram.h>
-#include <zypp/media/TransferSettings.h>
-#include <zypp/ZConfig.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/fs/WatchFile>
+#include <zypp-core/base/ReferenceCounted.h>
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/ExternalProgram.h>
+#include <zypp-media/MediaConfig>
#include <zypp-proto/transfersettings.pb.h>
+#include <zypp/APIConfig.h>
+
using std::endl;
#define CURL_BINARY "/usr/bin/curl"
public:
Impl() {
_settingsObj.set_useproxy( false );
- _settingsObj.set_timeout( ZConfig::instance().download_transfer_timeout() );
+ _settingsObj.set_timeout( MediaConfig::instance().download_transfer_timeout() );
_settingsObj.set_connect_timeout( 60 );
- _settingsObj.set_maxconcurrentconnections( ZConfig::instance().download_max_concurrent_connections() );
- _settingsObj.set_mindownloadspeed(ZConfig::instance().download_min_download_speed());
- _settingsObj.set_maxdownloadspeed(ZConfig::instance().download_max_download_speed());
- _settingsObj.set_maxsilenttries(ZConfig::instance().download_max_silent_tries() );
+ _settingsObj.set_maxconcurrentconnections( MediaConfig::instance().download_max_concurrent_connections() );
+ _settingsObj.set_mindownloadspeed(MediaConfig::instance().download_min_download_speed());
+ _settingsObj.set_maxdownloadspeed(MediaConfig::instance().download_max_download_speed());
+ _settingsObj.set_maxsilenttries(MediaConfig::instance().download_max_silent_tries() );
_settingsObj.set_verify_host(false);
_settingsObj.set_verify_peer(false);
_settingsObj.set_ca_path("/etc/ssl/certs");
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/TransferSettings
+ *
+ */
+#ifndef ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
+#define ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
+
+#include <string>
+#include <vector>
+#include <zypp-core/base/Flags.h>
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/Url.h>
+
+namespace zypp::proto {
+ class TransferSettings;
+}
+
+namespace zypp
+{
+ namespace media
+ {
+
+ /**
+ * Holds transfer setting
+ */
+ class TransferSettings
+ {
+ public:
+ /** Constructs a transfer program cmd line access. */
+ TransferSettings();
+
+ TransferSettings( const zypp::proto::TransferSettings &settings );
+
+ typedef std::vector<std::string> Headers;
+
+ /** reset the settings to the defaults */
+ void reset();
+
+
+ /** add a header, on the form "Foo: Bar" */
+ void addHeader( std::string && val_r );
+
+ /** returns a list of all added headers */
+ Headers headers() const;
+
+ /** sets the user agent ie: "Mozilla v3" */
+ void setUserAgentString( std::string && val_r );
+
+ /** user agent string */
+ std::string userAgentString() const;
+
+
+ /** sets the auth username */
+ void setUsername( std::string && val_r );
+
+ /** auth username */
+ std::string username() const;
+
+ /** sets the auth password */
+ void setPassword( std::string && val_r );
+
+ /** auth password */
+ std::string password() const;
+
+ /** returns the user and password as a user:pass string */
+ std::string userPassword() const;
+
+ /** sets anonymous authentication (ie: for ftp) */
+ void setAnonymousAuth();
+
+
+ /** whether the proxy is used or not */
+ void setProxyEnabled( bool enabled );
+
+ /** proxy is enabled */
+ bool proxyEnabled() const;
+
+
+ /** proxy to use if it is enabled */
+ void setProxy( std::string && val_r );
+
+ /** proxy host */
+ std::string proxy() const;
+
+
+ /** sets the proxy user */
+ void setProxyUsername( std::string && val_r );
+
+ /** proxy auth username */
+ std::string proxyUsername() const;
+
+ /** sets the proxy password */
+ void setProxyPassword( std::string && val_r );
+
+ /** proxy auth password */
+ std::string proxyPassword() const;
+
+ /** returns the proxy user and password as a user:pass string */
+ std::string proxyUserPassword() const;
+
+
+ /** set the connect timeout */
+ void setConnectTimeout( long t );
+
+ /** connection timeout */
+ long connectTimeout() const;
+
+
+ /** set the transfer timeout */
+ void setTimeout( long t );
+
+ /** transfer timeout */
+ long timeout() const;
+
+
+ /** Set maximum number of concurrent connections for a single transfer */
+ void setMaxConcurrentConnections(long v);
+
+ /** Maximum number of concurrent connections for a single transfer */
+ long maxConcurrentConnections() const;
+
+
+ /** Set minimum download speed (bytes per second) until the connection is dropped */
+ void setMinDownloadSpeed(long v);
+
+ /** Minimum download speed (bytes per second) until the connection is dropped */
+ long minDownloadSpeed() const;
+
+
+ /** Set max download speed (bytes per second) */
+ void setMaxDownloadSpeed(long v);
+
+ /** Maximum download speed (bytes per second) */
+ long maxDownloadSpeed() const;
+
+
+ /** Set maximum silent retries */
+ void setMaxSilentTries(long v);
+
+ /** Maximum silent retries */
+ long maxSilentTries() const;
+
+
+ /** Sets whether to verify host for ssl */
+ void setVerifyHostEnabled( bool enabled );
+
+ /** Whether to verify host for ssl */
+ bool verifyHostEnabled() const;
+
+
+ /** Sets whether to verify host for ssl */
+ void setVerifyPeerEnabled( bool enabled );
+
+ /** Whether to verify peer for ssl */
+ bool verifyPeerEnabled() const;
+
+
+ /** Sets the SSL certificate authorities path */
+ void setCertificateAuthoritiesPath( Pathname && val_r );
+
+ /** SSL certificate authorities path ( default: /etc/ssl/certs ) */
+ Pathname certificateAuthoritiesPath() const;
+
+
+ /** set the allowed authentication types */
+ void setAuthType( std::string && val_r );
+
+ /** get the allowed authentication types */
+ std::string authType() const;
+
+
+ /** set whether HEAD requests are allowed */
+ void setHeadRequestsAllowed(bool allowed);
+
+ /** whether HEAD requests are allowed */
+ bool headRequestsAllowed() const;
+
+
+ /** Sets the SSL client certificate file */
+ void setClientCertificatePath( Pathname && val_r );
+
+ /** SSL client certificate file */
+ Pathname clientCertificatePath() const;
+
+
+ /** Sets the SSL client key file */
+ void setClientKeyPath( Pathname && val_r );
+
+ /** SSL client key file */
+ Pathname clientKeyPath() const;
+
+ const zypp::proto::TransferSettings &protoData() const;
+ zypp::proto::TransferSettings &protoData();
+
+ protected:
+ class Impl;
+ RWCOW_pointer<Impl> _impl;
+ };
+
+ } // namespace media
+} // namespece zypp
+
+#endif // ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
--- /dev/null
+# Collect all files that may contain translatable texts
+FILE( GLOB_RECURSE POT_FILE_DEPENDS RELATIVE ${LIBZYPP_SOURCE_DIR} "*.h" "*.cc" )
+SET( POT_FILE_DEPENDS_ZYPP_MEDIA ${POT_FILE_DEPENDS} PARENT_SCOPE )
+
+INCLUDE_DIRECTORIES ( ${LIBZYPP_SOURCE_DIR} )
+
+ADD_DEFINITIONS( -DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL )
+
+SET( zypp_media_HEADERS
+ MediaConfig
+ mediaconfig.h
+ mediaexception.h
+ MediaException
+ mount.h
+ Mount
+)
+
+SET( zypp_media_private_HEADERS
+)
+
+SET( zypp_media_SRCS
+ mediaconfig.cc
+ mediaexception.cc
+ mount.cc
+)
+
+INSTALL( FILES ${zypp_media_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-media" )
+
+SET( zypp_media_auth_HEADERS
+ auth/AuthData
+ auth/authdata.h
+ auth/CredentialFileReader
+ auth/credentialfilereader.h
+ auth/CredentialManager
+ auth/credentialmanager.h
+)
+
+SET( zypp_media_auth_private_HEADERS
+)
+
+SET( zypp_media_auth_SRCS
+ auth/authdata.cc
+ auth/credentialfilereader.cc
+ auth/credentialmanager.cc
+)
+
+INSTALL( FILES ${zypp_media_auth_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-media/auth" )
+
+
+ADD_LIBRARY( zypp-media STATIC
+ ${zypp_media_SRCS} ${zypp_media_private_HEADERS} ${zypp_media_HEADERS}
+ ${zypp_media_auth_SRCS} ${zypp_media_auth_private_HEADERS} ${zypp_media_auth_HEADERS}
+ )
+#we include generated headers, so we need to wait for zypp-protobuf to be ready
+add_dependencies( zypp-media zypp-protobuf )
--- /dev/null
+#include "mediaconfig.h"
--- /dev/null
+#include "mediaexception.h"
--- /dev/null
+#include "mount.h"
--- /dev/null
+#include "authdata.h"
--- /dev/null
+#include "credentialfilereader.h"
--- /dev/null
+#include "credentialmanager.h"
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/authdata.cc
+ *
+ */
+
+#include "authdata.h"
+#include <zypp-core/base/String.h>
+
+using std::endl;
+
+namespace zypp {
+ namespace media {
+
+
+AuthData::AuthData(const Url & url)
+ : _url(url), _lastChange(0)
+{
+ _username = url.getUsername();
+ _password = url.getPassword();
+}
+
+
+bool AuthData::valid() const
+{
+ return username().size() && password().size();
+}
+
+time_t AuthData::lastDatabaseUpdate() const
+{
+ return _lastChange;
+}
+
+void AuthData::setLastDatabaseUpdate( time_t time )
+{
+ _lastChange = time;
+}
+
+std::ostream & AuthData::dumpOn( std::ostream & str ) const
+{
+ if (_url.isValid())
+ str << "[" << _url.asString( url::ViewOptions() - url::ViewOptions::WITH_USERNAME - url::ViewOptions::WITH_PASSWORD ) << "]" << endl;
+ else
+ str << "[<no-url>]" << endl;
+ str << "username: '" << _username << "'" << std::endl
+ << "password: " << (_password.empty() ? "<empty>" : "<non-empty>");
+ return str;
+}
+
+std::ostream & AuthData::dumpAsIniOn( std::ostream & str ) const
+{
+ if (_url.isValid())
+ str
+ << "[" << _url.asString(
+ url::ViewOptions()
+ - url::ViewOptions::WITH_USERNAME
+ - url::ViewOptions::WITH_PASSWORD)
+ << "]" << endl;
+
+ str
+ << "username = " << _username << endl
+ << "password = " << _password << endl;
+
+ return str;
+}
+
+std::ostream & operator << (std::ostream & str, const AuthData & auth_data)
+{
+ auth_data.dumpOn(str);
+ return str;
+}
+
+ } // namespace media
+} // namespace zypp
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/AuthData
+ * Convenience interface for handling authentication data of media user.
+ */
+#ifndef ZYPP_MEDIA_AUTH_DATA_H
+#define ZYPP_MEDIA_AUTH_DATA_H
+
+#include <zypp-core/Url.h>
+#include <zypp-core/base/PtrTypes.h>
+
+namespace zypp {
+ namespace media {
+
+///////////////////////////////////////////////////////////////////
+
+
+/**
+ * Class for handling media authentication data. This is the most generic
+ * class containing only username and password members.
+ */
+class AuthData
+{
+public:
+ AuthData()
+ {}
+
+ AuthData(const Url & url);
+
+ AuthData(const std::string & username, const std::string & password)
+ : _username(username), _password(password), _lastChange(0)
+ {}
+
+ virtual ~AuthData() {};
+
+ /**
+ * Checks validity of authentication data.
+ * \return true if the object contains non-empty username and
+ * non-empty password, false otherwise.
+ */
+ virtual bool valid() const;
+
+ void setUrl(const Url & url) { _url = url; }
+ void setUsername(const std::string & username) { _username = username; }
+ void setPassword(const std::string & password) { _password = password; }
+
+ Url url() const { return _url; }
+ std::string username() const { return _username; }
+ std::string password() const { return _password; }
+
+ /*!
+ * Returns the timestamp of the last change to the database this
+ * credential is stored in, or 0 if its not known.
+ */
+ time_t lastDatabaseUpdate () const;
+ void setLastDatabaseUpdate ( time_t time );
+
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+ virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
+
+private:
+ Url _url;
+ std::string _username;
+ std::string _password;
+ time_t _lastChange; //< timestamp of the last change to the database this credential is stored in
+};
+
+typedef shared_ptr<AuthData> AuthData_Ptr;
+std::ostream & operator << (std::ostream & str, const AuthData & auth_data);
+
+///////////////////////////////////////////////////////////////////
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_AUTH_DATA_H
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialFileReader.cc
+/** \file zypp-media/auth/credentialfilereader
*
*/
-#include <iostream>
-#include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/parser/IniDict.h>
-#include <zypp/PathInfo.h>
+#include "credentialfilereader.h"
+
+#include <iostream>
-#include <zypp/media/CredentialFileReader.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/parser/IniDict>
+#include <zypp-core/fs/PathInfo.h>
using std::endl;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/CredentialFileReader
+ *
+ */
+#ifndef ZYPP_MEDIA_AUTH_CREDENTIALFILEREADER_H
+#define ZYPP_MEDIA_AUTH_CREDENTIALFILEREADER_H
+
+#include <zypp-core/base/Function.h>
+#include <zypp-core/Url.h>
+#include <zypp-core/Pathname.h>
+
+#include <zypp-media/auth/AuthData>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{
+ ///////////////////////////////////////////////////////////////////
+ namespace media
+ {
+ //////////////////////////////////////////////////////////////////////
+ /// \class CredentialFileReader
+ /// \brief Parse credentials files and catalogs
+ class CredentialFileReader
+ {
+ public:
+ /** Callback invoked for each entry found in the file.
+ * Return \c false to abort parsing.
+ */
+ typedef function<bool(AuthData_Ptr &)> ProcessCredentials;
+
+ CredentialFileReader( const Pathname & crfile_r, const ProcessCredentials & callback_r );
+ ~CredentialFileReader();
+ private:
+ ProcessCredentials _callback;
+ };
+ //////////////////////////////////////////////////////////////////////
+
+ } // namespace media
+ ///////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+#endif /* ZYPP_MEDIA_AUTH_CREDENTIALFILEREADER_H */
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialManager.cc
+/** \file zypp-media/auth/credentialmanager.cc
*
*/
+
+#include "credentialmanager.h"
+
#include <iostream>
#include <fstream>
-#include <zypp/ZConfig.h>
-#include <zypp/base/Function.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/Easy.h>
-#include <zypp/PathInfo.h>
+#include <zypp-media/MediaConfig>
+#include <zypp-core/base/Function.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/Easy.h>
+#include <zypp-core/fs/PathInfo.h>
-#include <zypp/media/CredentialFileReader.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/auth/CredentialFileReader>
+#include <zypp-media/MediaException>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
//////////////////////////////////////////////////////////////////////
CredManagerOptions::CredManagerOptions(const Pathname & rootdir)
- : globalCredFilePath(rootdir / ZConfig::instance().credentialsGlobalFile())
- , customCredFileDir(rootdir / ZConfig::instance().credentialsGlobalDir())
+ : globalCredFilePath(rootdir / MediaConfig::instance().credentialsGlobalFile())
+ , customCredFileDir(rootdir / MediaConfig::instance().credentialsGlobalDir())
{
char * homedir = getenv("HOME");
if (homedir)
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/CredentialManager
+ *
+ */
+#ifndef ZYPP_MEDIA_AUTH_CREDENTIALMANAGER_H
+#define ZYPP_MEDIA_AUTH_CREDENTIALMANAGER_H
+
+#include <set>
+
+#include <zypp-core/Pathname.h>
+#include <zypp-media/auth/AuthData>
+
+//////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ////////////////////////////////////////////////////////////////////
+
+ class Url;
+
+ //////////////////////////////////////////////////////////////////////
+ namespace media
+ { ////////////////////////////////////////////////////////////////////
+
+
+ //////////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CredManagerOptions
+ //
+ /**
+ * \todo configurable cred file locations
+ */
+ struct CredManagerOptions
+ {
+ CredManagerOptions(const Pathname & rootdir = "");
+
+ Pathname globalCredFilePath;
+ Pathname userCredFilePath;
+ Pathname customCredFileDir;
+ };
+ //////////////////////////////////////////////////////////////////////
+
+ // comparator for CredentialSet
+ struct AuthDataComparator
+ {
+ bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs) const;
+ };
+
+ //////////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CredentialManager
+ //
+ /**
+ * \todo better method names
+ * \todo delete(AuthData) method
+ */
+ class CredentialManager
+ {
+ public:
+ typedef std::set<AuthData_Ptr, AuthDataComparator> CredentialSet;
+ typedef CredentialSet::size_type CredentialSize;
+ typedef CredentialSet::const_iterator CredentialIterator;
+
+
+ CredentialManager(const CredManagerOptions & opts = CredManagerOptions());
+
+ ~CredentialManager()
+ {}
+
+ public:
+ /**
+ * Get credentials for the specified \a url.
+ *
+ * If the URL contains also username, it will be used to find the match
+ * for this user (in case mutliple are available).
+ *
+ * \param url URL to find credentials for.
+ * \return Pointer to retrieved authentication data on success or an empty
+ * AuthData_Ptr otherwise.
+ * \todo return a copy instead?
+ */
+ AuthData_Ptr getCred(const Url & url);
+
+ /**
+ * Read credentials from a file.
+ */
+ AuthData_Ptr getCredFromFile(const Pathname & file);
+
+ /**
+ * Add new global credentials.
+ */
+ void addGlobalCred(const AuthData & cred);
+
+ /**
+ * Add new user credentials.
+ */
+ void addUserCred(const AuthData & cred);
+
+ /**
+ * Add new credentials with user callbacks.
+ *
+ * If the cred->url() contains 'credentials' query parameter, the
+ * credentials will be automatically saved to the specified file using the
+ * \ref saveInFile() method.
+ *
+ * Otherwise a callback will be called asking whether to save to custom
+ * file, or to global or user's credentials catalog.
+ *
+ * \todo Currently no callback is called, credentials are automatically
+ * saved to user's credentials.cat if no 'credentials' parameter
+ * has been specified
+ */
+ void addCred(const AuthData & cred);
+
+ /**
+ * Saves any unsaved credentials added via \ref addUserCred() or
+ * \a addGlobalCred() methods.
+ */
+ void save();
+
+ /**
+ * Saves given \a cred to global credentials file.
+ *
+ * \note Use this method to add just one piece of credentials. To add
+ * multiple items at once, use addGlobalCred() followed
+ * by save()
+ */
+ void saveInGlobal(const AuthData & cred);
+
+ /**
+ * Saves given \a cred to user's credentials file.
+ *
+ * \note Use this method to add just one piece of credentials. To add
+ * multiple items at once, use addUserCred() followed
+ * by save()
+ */
+ void saveInUser(const AuthData & cred);
+
+ /**
+ * Saves given \a cred to user specified credentials file.
+ *
+ * If the credFile path is absolute, it will be saved at that precise
+ * location. If \a credFile is just a filename, it will be saved
+ * in \ref CredManagerOptions::customCredFileDir. Otherwise the current
+ * working directory will be prepended to the file path.
+ */
+ void saveInFile(const AuthData &, const Pathname & credFile);
+
+ /**
+ * Remove all global or user credentials from memory and disk.
+ *
+ * \param global Whether to remove global or user credentials.
+ */
+ void clearAll(bool global = false);
+
+
+ CredentialIterator credsGlobalBegin() const;
+ CredentialIterator credsGlobalEnd() const;
+ CredentialSize credsGlobalSize() const;
+ bool credsGlobalEmpty() const;
+
+ CredentialIterator credsUserBegin() const;
+ CredentialIterator credsUserEnd() const;
+ CredentialSize credsUserSize() const;
+ bool credsUserEmpty() const;
+
+ struct Impl;
+ private:
+ RW_pointer<Impl> _pimpl;
+ };
+ //////////////////////////////////////////////////////////////////////
+
+
+ ////////////////////////////////////////////////////////////////////
+ } // media
+ //////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+} // zypp
+//////////////////////////////////////////////////////////////////////
+
+#endif /* ZYPP_MEDIA_AUTH_CREDENTIALMANAGER_H */
+
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/mediaconfig.cc
+ *
+*/
+
+#include "mediaconfig.h"
+#include <zypp-core/Pathname.h>
+#include <zypp-core/base/String.h>
+
+namespace zypp {
+
+ class MediaConfigPrivate {
+ public:
+
+ MediaConfigPrivate()
+ : download_max_concurrent_connections( 5 )
+ , download_min_download_speed ( 0 )
+ , download_max_download_speed ( 0 )
+ , download_max_silent_tries ( 5 )
+ , download_transfer_timeout ( 180 )
+ { }
+
+ Pathname credentials_global_dir_path;
+ Pathname credentials_global_file_path;
+
+ int download_max_concurrent_connections;
+ int download_min_download_speed;
+ int download_max_download_speed;
+ int download_max_silent_tries;
+ int download_transfer_timeout;
+ };
+
+ MediaConfig::MediaConfig() : d_ptr( new MediaConfigPrivate() )
+ { }
+
+ MediaConfig &MediaConfig::instance()
+ {
+ static MediaConfig instance;
+ return instance;
+ }
+
+ bool MediaConfig::setConfigValue( const std::string §ion, const std::string &entry, const std::string &value )
+ {
+ Z_D();
+ if ( section == "main" ) {
+ if ( entry == "credentials.global.dir" ) {
+ d->credentials_global_dir_path = Pathname(value);
+ return true;
+ } else if ( entry == "credentials.global.file" ) {
+ d->credentials_global_file_path = Pathname(value);
+ return true;
+
+ } else if ( entry == "download.max_concurrent_connections" ) {
+ str::strtonum(value, d->download_max_concurrent_connections);
+ return true;
+
+ } else if ( entry == "download.min_download_speed" ) {
+ str::strtonum(value, d->download_min_download_speed);
+ return true;
+
+ } else if ( entry == "download.max_download_speed" ) {
+ str::strtonum(value, d->download_max_download_speed);
+ return true;
+
+ } else if ( entry == "download.max_silent_tries" ) {
+ str::strtonum(value, d->download_max_silent_tries);
+ return true;
+
+ } else if ( entry == "download.transfer_timeout" ) {
+ str::strtonum(value, d->download_transfer_timeout);
+ if ( d->download_transfer_timeout < 0 ) d->download_transfer_timeout = 0;
+ else if ( d->download_transfer_timeout > 3600 ) d->download_transfer_timeout = 3600;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ Pathname MediaConfig::credentialsGlobalDir() const
+ {
+ Z_D();
+ return ( d->credentials_global_dir_path.empty() ?
+ Pathname("/etc/zypp/credentials.d") : d->credentials_global_dir_path );
+ }
+
+ Pathname MediaConfig::credentialsGlobalFile() const
+ {
+ Z_D();
+ return ( d->credentials_global_file_path.empty() ?
+ Pathname("/etc/zypp/credentials.cat") : d->credentials_global_file_path );
+ }
+
+ long MediaConfig::download_max_concurrent_connections() const
+ { return d_func()->download_max_concurrent_connections; }
+
+ long MediaConfig::download_min_download_speed() const
+ { return d_func()->download_min_download_speed; }
+
+ long MediaConfig::download_max_download_speed() const
+ { return d_func()->download_max_download_speed; }
+
+ long MediaConfig::download_max_silent_tries() const
+ { return d_func()->download_max_silent_tries; }
+
+ long MediaConfig::download_transfer_timeout() const
+ { return d_func()->download_transfer_timeout; }
+
+ ZYPP_IMPL_PRIVATE(MediaConfig)
+}
+
+
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/MediaConfig
+ *
+*/
+#ifndef ZYPP_MEDIA_MEDIACONFIG_H
+#define ZYPP_MEDIA_MEDIACONFIG_H
+
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/zyppng/base/zyppglobal.h>
+#include <memory>
+#include <string>
+
+namespace zypp {
+
+ class MediaConfigPrivate;
+
+ /*!
+ * Helper class to collect global options and settings related to zypp-media.
+ * Use it to avoid hardcoded values and calls to getZYpp() just
+ * to retrieve some value like credentials path or download related settings.
+ *
+ * Note, if you add settings to this file, please follow the following
+ * convention:
+ *
+ * namespace.settingname
+ *
+ * should become
+ *
+ * namespace_settingName()
+ *
+ * \ingroup ZyppConfig
+ * \ingroup Singleton
+ */
+ class MediaConfig : private base::NonCopyable
+ {
+ ZYPP_DECLARE_PRIVATE(MediaConfig)
+ public:
+
+ /*! Singleton ctor */
+ static MediaConfig & instance();
+
+ bool setConfigValue ( const std::string §ion, const std::string &entry, const std::string &value );
+
+ /*!
+ * Defaults to /etc/zypp/credentials.d
+ */
+ Pathname credentialsGlobalDir() const;
+
+ /*!
+ * Defaults to /etc/zypp/credentials.cat
+ */
+ Pathname credentialsGlobalFile() const;
+
+ /*!
+ * Maximum number of concurrent connections for a single transfer
+ */
+ long download_max_concurrent_connections() const;
+
+ /*!
+ * Minimum download speed (bytes per second)
+ * until the connection is dropped
+ */
+ long download_min_download_speed() const;
+
+ /*!
+ * Maximum download speed (bytes per second)
+ */
+ long download_max_download_speed() const;
+
+ /*!
+ * Maximum silent tries
+ */
+ long download_max_silent_tries() const;
+
+ /*!
+ * Maximum time in seconds that you allow a transfer operation to take.
+ */
+ long download_transfer_timeout() const;
+
+ private:
+ MediaConfig();
+ std::unique_ptr<MediaConfigPrivate> d_ptr;
+ };
+
+}
+
+#endif
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaException.cc
+/** \file zypp-media/mediaexception.cc
*
*/
#include <iostream>
-#include <zypp/base/String.h>
-#include <zypp/base/Gettext.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/Gettext.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
using std::endl;
using zypp::str::form;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/MediaException
+ *
+*/
+#ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
+#define ZYPP_MEDIA_MEDIAEXCEPTION_H
+
+#include <iosfwd>
+
+#include <string>
+#include <vector>
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/Url.h>
+#include <zypp-core/ByteCount.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ namespace media {
+ ///////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : MediaException
+ /** Just inherits Exception to separate media exceptions
+ *
+ **/
+ class MediaException : public Exception
+ {
+ public:
+ /** Ctor taking message.
+ * Use \ref ZYPP_THROW to throw exceptions.
+ */
+ MediaException() : Exception( "Media Exception" )
+ {}
+ /** Ctor taking message.
+ * Use \ref ZYPP_THROW to throw exceptions.
+ */
+ MediaException( const std::string & msg_r )
+ : Exception( msg_r )
+ {}
+
+ /** Dtor. */
+ virtual ~MediaException() noexcept override;
+ };
+
+ class MediaMountException : public MediaException
+ {
+ public:
+ MediaMountException()
+ : MediaException( "Media Mount Exception" )
+ {}
+
+ /** Ctor taking message.
+ * Use \ref ZYPP_THROW to throw exceptions.
+ */
+ MediaMountException( const std::string & error_r,
+ const std::string & source_r,
+ const std::string & target_r,
+ const std::string & cmdout_r="")
+ : MediaException()
+ , _error(error_r)
+ , _source(source_r)
+ , _target(target_r)
+ , _cmdout(cmdout_r)
+ {}
+ /** Dtor. */
+ virtual ~MediaMountException() noexcept {}
+
+ const std::string & mountError() const
+ { return _error; }
+ const std::string & mountSource() const
+ { return _source; }
+ const std::string & mountTarget() const
+ { return _target; }
+ const std::string & mountOutput() const
+ { return _cmdout; }
+
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _error;
+ std::string _source;
+ std::string _target;
+ std::string _cmdout;
+ };
+
+ class MediaUnmountException : public MediaException
+ {
+ public:
+ /** Ctor taking message.
+ * Use \ref ZYPP_THROW to throw exceptions.
+ */
+ MediaUnmountException( const std::string & error_r,
+ const std::string & path_r )
+ : MediaException()
+ , _error(error_r)
+ , _path(path_r)
+ {}
+ /** Dtor. */
+ virtual ~MediaUnmountException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _error;
+ std::string _path;
+ };
+
+ class MediaBadFilenameException : public MediaException
+ {
+ public:
+ MediaBadFilenameException(const std::string & filename_r)
+ : MediaException()
+ , _filename(filename_r)
+ {}
+ virtual ~MediaBadFilenameException() noexcept {}
+ std::string filename() const { return _filename; }
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _filename;
+ };
+
+ class MediaNotOpenException : public MediaException
+ {
+ public:
+ MediaNotOpenException(const std::string & action_r)
+ : MediaException()
+ , _action(action_r)
+ {}
+ virtual ~MediaNotOpenException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _action;
+ };
+
+ class MediaFileNotFoundException : public MediaException
+ {
+ public:
+ MediaFileNotFoundException(const Url & url_r,
+ const Pathname & filename_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _filename(filename_r.asString())
+ {}
+ virtual ~MediaFileNotFoundException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _filename;
+ };
+
+ class MediaWriteException : public MediaException
+ {
+ public:
+ MediaWriteException(const Pathname & filename_r)
+ : MediaException()
+ , _filename(filename_r.asString())
+ {}
+ virtual ~MediaWriteException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _filename;
+ };
+
+ class MediaNotAttachedException : public MediaException
+ {
+ public:
+ MediaNotAttachedException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaNotAttachedException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+ class MediaBadAttachPointException : public MediaException
+ {
+ public:
+ MediaBadAttachPointException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaBadAttachPointException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+ class MediaCurlInitException : public MediaException
+ {
+ public:
+ MediaCurlInitException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaCurlInitException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+ class MediaSystemException : public MediaException
+ {
+ public:
+ MediaSystemException(const Url & url_r,
+ const std::string & message_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _message(message_r)
+ {}
+ virtual ~MediaSystemException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _message;
+ };
+
+ class MediaNotAFileException : public MediaException
+ {
+ public:
+ MediaNotAFileException(const Url & url_r,
+ const Pathname & path_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _path(path_r.asString())
+ {}
+ virtual ~MediaNotAFileException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _path;
+ };
+
+ class MediaNotADirException : public MediaException
+ {
+ public:
+ MediaNotADirException(const Url & url_r,
+ const Pathname & path_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _path(path_r.asString())
+ {}
+ virtual ~MediaNotADirException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _path;
+ };
+
+ class MediaBadUrlException : public MediaException
+ {
+ public:
+ MediaBadUrlException(const Url & url_r,
+ const std::string &msg_r = std::string())
+ : MediaException()
+ , _url(url_r.asString())
+ , _msg(msg_r)
+ {}
+ virtual ~MediaBadUrlException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaBadUrlEmptyHostException : public MediaBadUrlException
+ {
+ public:
+ MediaBadUrlEmptyHostException(const Url & url_r)
+ : MediaBadUrlException(url_r)
+ {}
+ virtual ~MediaBadUrlEmptyHostException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+
+ class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
+ {
+ public:
+ MediaBadUrlEmptyFilesystemException(const Url & url_r)
+ : MediaBadUrlException(url_r)
+ {}
+ virtual ~MediaBadUrlEmptyFilesystemException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+
+ class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
+ {
+ public:
+ MediaBadUrlEmptyDestinationException(const Url & url_r)
+ : MediaBadUrlException(url_r)
+ {}
+ virtual ~MediaBadUrlEmptyDestinationException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+
+ class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
+ {
+ public:
+ MediaUnsupportedUrlSchemeException(const Url & url_r)
+ : MediaBadUrlException(url_r)
+ {}
+ virtual ~MediaUnsupportedUrlSchemeException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ };
+
+ class MediaNotSupportedException : public MediaException
+ {
+ public:
+ MediaNotSupportedException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaNotSupportedException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ };
+
+ class MediaCurlException : public MediaException
+ {
+ public:
+ MediaCurlException(const Url & url_r,
+ const std::string & err_r,
+ const std::string & msg_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _err(err_r)
+ , _msg(msg_r)
+ {}
+ virtual ~MediaCurlException() noexcept {}
+ std::string errstr() const { return _err; }
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _err;
+ std::string _msg;
+ };
+
+ class MediaCurlSetOptException : public MediaException
+ {
+ public:
+ MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _msg(msg_r)
+ {}
+ virtual ~MediaCurlSetOptException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaNotDesiredException : public MediaException
+ {
+ public:
+ MediaNotDesiredException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaNotDesiredException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+ class MediaIsSharedException : public MediaException
+ {
+ public:
+ /**
+ * \param name A media source as string (see MediaSource class).
+ */
+ MediaIsSharedException(const std::string &name)
+ : MediaException()
+ , _name(name)
+ {}
+ virtual ~MediaIsSharedException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _name;
+ };
+
+ class MediaNotEjectedException: public MediaException
+ {
+ public:
+ MediaNotEjectedException()
+ : MediaException("Can't eject any media")
+ , _name("")
+ {}
+
+ MediaNotEjectedException(const std::string &name)
+ : MediaException("Can't eject media")
+ , _name(name)
+ {}
+ virtual ~MediaNotEjectedException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _name;
+ };
+
+ class MediaUnauthorizedException: public MediaException
+ {
+ public:
+ MediaUnauthorizedException()
+ : MediaException("Unauthorized media access")
+ , _url("")
+ , _err("")
+ , _hint("")
+ {}
+
+ MediaUnauthorizedException(const Url &url_r,
+ const std::string &msg_r,
+ const std::string &err_r,
+ const std::string &hint_r)
+ : MediaException(msg_r)
+ , _url(url_r)
+ , _err(err_r)
+ , _hint(hint_r)
+ {}
+
+ virtual ~MediaUnauthorizedException() noexcept {}
+
+ const Url & url() const { return _url; }
+ const std::string & err() const { return _err; }
+ /** comma separated list of available authentication types */
+ const std::string & hint() const { return _hint; }
+
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ Url _url;
+ std::string _err;
+ std::string _hint;
+ };
+
+ class MediaForbiddenException : public MediaException
+ {
+ public:
+ MediaForbiddenException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaForbiddenException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaTimeoutException : public MediaException
+ {
+ public:
+ MediaTimeoutException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaTimeoutException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaFileSizeExceededException : public MediaException
+ {
+ public:
+ MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString())
+ , _msg(msg)
+ , _expectedFileSize(cnt_r)
+ {}
+ virtual ~MediaFileSizeExceededException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ ByteCount _expectedFileSize;
+ };
+
+ /** For HTTP 503 and similar. */
+ class MediaTemporaryProblemException : public MediaException
+ {
+ public:
+ MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaTemporaryProblemException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaBadCAException : public MediaException
+ {
+ public:
+ MediaBadCAException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaBadCAException() noexcept {}
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaInvalidCredentialsException : public MediaException
+ {
+ public:
+ MediaInvalidCredentialsException( const std::string & msg = "" )
+ : MediaException(msg)
+ {}
+ virtual ~MediaInvalidCredentialsException() noexcept {}
+ };
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace media
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
#include <fstream>
#include <string>
+#include <zypp-media/Mount>
#include <zypp/base/ExternalDataSource.h>
#include <zypp/base/Logger.h>
-#include <zypp/media/Mount.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/PathInfo.h>
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/Mount
+ *
+*/
+
+// -*- C++ -*-
+
+#ifndef ZYPP_MEDIA_MOUNT_H
+#define ZYPP_MEDIA_MOUNT_H
+
+#include <set>
+#include <map>
+#include <string>
+#include <iosfwd>
+
+#include <zypp/ExternalProgram.h>
+#include <zypp-core/KVMap>
+
+namespace zypp {
+ namespace media {
+
+
+ /**
+ * A "struct mntent" like mount entry structure,
+ * but using std::strings.
+ */
+ struct MountEntry
+ {
+ MountEntry(const std::string &source,
+ const std::string &target,
+ const std::string &fstype,
+ const std::string &options,
+ const int dumpfreq = 0,
+ const int passnum = 0)
+ : src(source)
+ , dir(target)
+ , type(fstype)
+ , opts(options)
+ , freq(dumpfreq)
+ , pass(passnum)
+ {}
+
+ std::string src; //!< name of mounted file system
+ std::string dir; //!< file system path prefix
+ std::string type; //!< filesystem / mount type
+ std::string opts; //!< mount options
+ int freq; //!< dump frequency in days
+ int pass; //!< pass number on parallel fsck
+ };
+
+ /** \relates MountEntry
+ * A vector of mount entries.
+ */
+ typedef std::vector<MountEntry> MountEntries;
+
+ /** \relates MountEntry Stream output */
+ std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
+
+ /**
+ * @short Interface to the mount program
+ */
+ class Mount
+ {
+ public:
+
+ /**
+ * For passing additional environment variables
+ * to mount
+ **/
+ typedef ExternalProgram::Environment Environment;
+
+ /**
+ * Mount options. 'key' or 'key=value' pairs, separated by ','
+ **/
+ typedef KVMap<kvmap::KVMapBase::CharSep<'=',','> > Options;
+
+ public:
+
+ /**
+ * Create an new instance.
+ */
+ Mount();
+
+ /**
+ * Clean up.
+ */
+ ~Mount();
+
+ /**
+ * mount device
+ *
+ * @param source what to mount (e.g. /dev/hda3)
+ * @param target where to mount (e.g. /mnt)
+ * @param filesystem which filesystem to use (e.g. reiserfs) (-t parameter)
+ * @param options mount options (e.g. ro) (-o parameter)
+ * @param environment optinal environment to pass (e.g. PASSWD="sennah")
+ *
+ * \throws MediaException
+ *
+ */
+
+ void mount ( const std::string& source,
+ const std::string& target,
+ const std::string& filesystem,
+ const std::string& options,
+ const Environment& environment = Environment() );
+
+ /** umount device
+ *
+ * @param path device or mountpoint to umount
+ *
+ * \throws MediaException
+ *
+ * */
+ void umount (const std::string& path);
+
+ public:
+
+ /**
+ * Return mount entries from /etc/mtab or /etc/fstab file.
+ *
+ * @param mtab The name of the (mounted) file system description
+ * file to read from. This file should be one /etc/mtab,
+ * /etc/fstab or /proc/mounts. Default is to read
+ * /proc/mounts and /etc/mtab in case is not a symlink
+ * to /proc/mounts.
+ * @returns A vector with mount entries or empty vector if reading
+ * or parsing of the mtab file(s) failed.
+ */
+ static MountEntries
+ getEntries(const std::string &mtab = "");
+
+ private:
+
+ /** The connection to the mount process.
+ * */
+ ExternalProgram *process;
+
+ /**
+ * Run mount with the specified arguments and handle stderr.
+ * @param argv Mount arguments
+ * @param environment Addittional environment to set
+ * @param stderr_disp How to handle stderr, merged with stdout by default
+ * */
+ void run( const char *const *argv, const Environment& environment,
+ ExternalProgram::Stderr_Disposition stderr_disp =
+ ExternalProgram::Stderr_To_Stdout);
+
+ void run( const char *const *argv,
+ ExternalProgram::Stderr_Disposition stderr_disp =
+ ExternalProgram::Stderr_To_Stdout) {
+ Environment notused;
+ run( argv, notused, stderr_disp );
+ }
+
+ /** Return the exit status of the process, closing the connection if
+ * not already done.
+ * */
+ int Status();
+
+ /** Forcably kill the process
+ * */
+ void Kill();
+
+
+ /** The exit code of the process, or -1 if not yet known.
+ * */
+ int exit_code;
+ };
+
+
+ } // namespace media
+} // namespace zypp
+
+#endif
## Translated package descriptions to download from repos.
##
## A list of locales for which translated package descriptions should
-## be downloaded, in case they are availavble and the repo supports this.
+## be downloaded, in case they are available and the repo supports this.
## Not all repo formats support downloading specific translations only.
##
## Valid values: List of locales like 'en', 'en_US'...
##
## EXPERTS ONLY: Cleanup when deleting packages. Whether the solver should
-## per default try to remove packages exclusively required by the ones he's
+## per default try to remove packages exclusively required by the ones it's
## asked to delete.
##
## This option should be used on a case by case basis, enabled via
#define LIBZYPP_SOVERSION @LIBZYPP_SO_FIRST@
#define LIBZYPP_VERSION @LIBZYPP_NUMVERSION@
-#include <zypp/Globals.h>
+#include <zypp-core/Globals.h>
#endif //ZYPP_APICONFIG_H
DEF_BUILTIN( armv7thl ); /* exists? */
DEF_BUILTIN( armv7hnl ); /* legacy: */DEF_BUILTIN( armv7nhl );
+ DEF_BUILTIN( armv8hl );
DEF_BUILTIN( armv7hl );
DEF_BUILTIN( armv6hl );
+ DEF_BUILTIN( armv8l );
DEF_BUILTIN( armv7l );
DEF_BUILTIN( armv6l );
DEF_BUILTIN( armv5tejl );
defCompatibleWith( a_armv5tejl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel() );
defCompatibleWith( a_armv6l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl() );
defCompatibleWith( a_armv7l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l() );
+ defCompatibleWith( a_armv8l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l(),a_armv7l() );
defCompatibleWith( a_armv6hl(), a_noarch() );
defCompatibleWith( a_armv7hl(), a_noarch(),a_armv6hl() );
+ defCompatibleWith( a_armv8hl(), a_noarch(),a_armv7hl() );
defCompatibleWith( a_armv7hnl(), a_noarch(),a_armv7hl(),a_armv6hl() );
/*legacy: rpm uses v7hnl */
defCompatibleWith( a_armv7nhl(), a_noarch(),a_armv7hnl(),a_armv7hl(),a_armv6hl() );
extern const Arch Arch_armv6hl;
/** \relates Arch */
+ extern const Arch Arch_armv8hl;
+ /** \relates Arch */
+ extern const Arch Arch_armv8l;
+ /** \relates Arch */
extern const Arch Arch_armv7l;
/** \relates Arch */
extern const Arch Arch_armv6l;
KeyRingContexts.cc
Locks.cc
MediaSetAccess.cc
- OnMediaLocation.cc
Package.cc
Patch.cc
PathInfo.cc
PoolQueryResult.cc
ProblemSolution.cc
Product.cc
- ProgressData.cc
ProvideFilePolicy.cc
PublicKey.cc
PurgeKernels.cc
ProblemSolution.h
ProblemTypes.h
Product.h
- ProgressData.h
ProvideFilePolicy.h
PublicKey.h
PurgeKernels.h
base/SerialNumber.cc
base/Random.cc
base/Measure.cc
- base/GzStream.cc
- base/InputStream.cc
base/SetRelationMixin.cc
base/StrMatcher.h
base/StrMatcher.cc
- base/UserRequestException.cc
- base/Sysconfig.cc
)
SET( zypp_base_HEADERS
base/DrunkenBishop.h
base/SerialNumber.h
base/Env.h
- base/fXstream.h
base/Random.h
base/Algorithm.h
base/Counter.h
base/Debug.h
- base/DefaultIntegral.h
- base/DtorReset.h
- base/UserRequestException.h
base/Functional.h
- base/GzStream.h
- base/InputStream.h
base/Json.h
base/LocaleGuard.h
base/Measure.h
base/NamedValue.h
- base/ProvideNumericId.h
base/ReferenceCounted.h
base/SetRelationMixin.h
base/SetTracker.h
base/Signal.h
- base/SimpleStreambuf.h
base/StrMatcher.h
- base/Sysconfig.h
base/TypeTraits.h
base/ValueTransform.h
- base/WatchFile.h
)
-IF (ENABLE_ZCHUNK_COMPRESSION)
-
- list( APPEND zypp_base_SRCS
- base/ZckStream.cc
- )
-
- list( APPEND zypp_base_HEADERS
- base/ZckStream.h
- )
-
-ENDIF(ENABLE_ZCHUNK_COMPRESSION)
-
INSTALL( FILES
${zypp_base_HEADERS}
DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/base
)
SET( zypp_media_SRCS
- media/CurlHelper.cc
- media/MediaException.cc
media/MediaHandler.cc
media/MediaHandlerFactory.cc
- media/Mount.cc
media/MediaNFS.cc
media/MediaCD.cc
media/MediaDIR.cc
media/MediaDISK.cc
media/MediaCIFS.cc
- media/ProxyInfo.cc
media/MediaNetworkCommonHandler.h
media/MediaCurl.cc
media/MediaMultiCurl.cc
media/MediaPlugin.cc
media/MediaSource.cc
media/MediaManager.cc
- media/MediaUserAuth.cc
- media/CredentialFileReader.cc
- media/CredentialManager.cc
- media/CurlConfig.cc
- media/TransferSettings.cc
media/MediaPriority.cc
- media/MetaLinkParser.cc
media/ZsyncParser.cc
- media/MediaBlockList.cc
media/UrlResolverPlugin.cc
)
media/MediaManager.h
media/MediaNFS.h
media/MediaSource.h
- media/MediaUserAuth.h
- media/Mount.h
- media/ProxyInfo.h
- media/CredentialFileReader.h
- media/CredentialManager.h
- media/CurlConfig.h
- media/TransferSettings.h
media/MediaPriority.h
- media/MetaLinkParser.h
media/ZsyncParser.h
- media/MediaBlockList.h
media/UrlResolverPlugin.h
)
DESTINATION ${INCLUDE_INSTALL_DIR}/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
-)
-
-INSTALL( FILES
- ${zypp_media_proxyinfo_HEADERS}
- DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media/proxyinfo
-)
-
SET( zypp_parser_SRCS
- parser/ParseException.cc
- parser/IniParser.cc
- parser/IniDict.cc
parser/HistoryLogReader.cc
parser/RepoFileReader.cc
parser/RepoindexFileReader.cc
)
SET( zypp_parser_HEADERS
- parser/ParseException.h
- parser/IniParser.h
- parser/IniDict.h
parser/HistoryLogReader.h
parser/ParserProgress.h
parser/RepoFileReader.h
TriBool.h
Pathname.h
ByteArray.h
+ ProgressData.h
)
INSTALL( FILES
base/PtrTypes.h
base/Errno.h
base/Iterable.h
+ base/DefaultIntegral.h
+ base/DtorReset.h
+ base/GzStream.h
+ base/InputStream.h
+ base/ProvideNumericId.h
+ base/SimpleStreambuf.h
+ base/Sysconfig.h
+ base/UserRequestException.h
+ base/WatchFile.h
+ base/fXstream.h
+)
+
+IF (ENABLE_ZCHUNK_COMPRESSION)
+list( APPEND zypp_core_base_compat_HEADERS
+ base/ZckStream.h
)
+ENDIF(ENABLE_ZCHUNK_COMPRESSION)
INSTALL( FILES
${zypp_core_base_compat_HEADERS}
DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/base
)
-
SET ( zypp_core_url_compat_HEADERS
url/UrlException.h
url/UrlUtils.h
DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/url
)
+
+SET ( zypp_media_compat_HEADERS
+ media/CredentialFileReader.h
+ media/CredentialManager.h
+ media/MediaBlockList.h
+ media/MediaUserAuth.h
+ media/MetaLinkParser.h
+ media/ProxyInfo.h
+ media/TransferSettings.h
+ media/Mount.h
+ media/CurlConfig.h
+)
+
+INSTALL( FILES
+ ${zypp_media_compat_HEADERS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media
+)
+
SET ( zypp_core_parser_compat_HEADERS
parser/xml/XmlEscape.h
+ parser/IniDict.h
+ parser/IniParser.h
+ parser/ParseException.h
)
INSTALL( FILES
DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/parser/xml
)
+IF ( LIBPROXY_FOUND )
+ SET(zypp_media_proxyinfo_libproxy_HEADERS media/proxyinfo/ProxyInfoLibproxy.h)
+ENDIF( LIBPROXY_FOUND )
+
+SET( zypp_media_compat_proxyinfo_HEADERS
+ media/proxyinfo/ProxyInfoImpl.h
+ media/proxyinfo/ProxyInfoSysconfig.h
+ ${zypp_media_proxyinfo_libproxy_HEADERS}
+ media/proxyinfo/ProxyInfos.h
+)
+
+INSTALL( FILES
+ ${zypp_media_compat_proxyinfo_HEADERS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media/proxyinfo
+)
+
add_subdirectory( zyppng )
SET( zypp_lib_SRCS
${zypp_parser_HEADERS}
${zypp_ui_HEADERS}
${zypp_media_HEADERS}
-${zypp_media_proxyinfo_HEADERS}
+${zypp_media_compat_proxyinfo_HEADERS}
${zypp_base_HEADERS}
${zypp_solver_HEADERS}
${zypp_solver_detail_HEADERS}
${zypp_core_base_compat_HEADERS}
${zypp_core_url_compat_HEADERS}
${zypp_core_parser_compat_HEADERS}
+${zypp_media_compat_HEADERS}
)
#
# System libraries
SET(UTIL_LIBRARY util)
- # CAUTION, link those 2 libs always first and always in that order,
+ # CAUTION, link those libs always first and always in that order,
# otherwise you get symbol lookup errors when linking against libzypp
+ TARGET_LINK_LIBRARIES(${LIBNAME} zypp-curl )
+ TARGET_LINK_LIBRARIES(${LIBNAME} zypp-media )
TARGET_LINK_LIBRARIES(${LIBNAME} zypp-core )
TARGET_LINK_LIBRARIES(${LIBNAME} zypp-protobuf )
ADD_DEPENDENCIES( zypp-allsym zypp )
#this part does nothing yet, only when switching away from using a map file to
-#a approach where symbols are exported explicitely it would make a difference
+#a approach where symbols are exported explicitly it would make a difference
#ZYPPNG symbols need to be added to the map file to be exported
IF( EXPORT_NG_API )
ADD_DEFINITIONS(-DEXPORT_EXPERIMENTAL_API)
*
* That way the sending side does not need to know whether some receiver
* is listening. And it enables the receiver to return a reasonable value,
- * in case he's got no idea, what else to return.
+ * in case it's got no idea, what else to return.
*
* \code
* struct Foo : public callback::ReportBase
*
* \note In case you must return some value and don't know which,
* return the task structures default. The author of the task
- * structure had to provide this value, so it's probabely better
+ * structure had to provide this value, so it's probably better
* than anything you \e invent.
* \code
* int somefunction()
#include <iosfwd>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/sat/detail/PoolMember.h>
#include <zypp/Capability.h>
#include <zypp/base/Easy.h>
#include <zypp/base/LogTools.h>
-#include <zypp/base/DtorReset.h>
+#include <zypp-core/base/DtorReset>
#include <zypp/base/String.h>
#include <zypp/DiskUsageCounter.h>
#include <zypp/base/LogControl.h>
#include <zypp/base/LogTools.h>
#include <zypp/base/PtrTypes.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/base/String.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/Fetcher.h>
#include <zypp/ZYppFactory.h>
#include <zypp/CheckSum.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/parser/susetags/ContentFileReader.h>
#include <zypp/parser/susetags/RepoIndex.h>
catch ( media::MediaFileNotFoundException & exception )
{
ZYPP_CAUGHT( exception );
- WAR << "Skiping subtree hidden at " << resource.filename() << endl;
+ WAR << "Skipping subtree hidden at " << resource.filename() << endl;
return;
}
#include <zypp/base/PtrTypes.h>
#include <zypp/Pathname.h>
#include <zypp/Url.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/Digest.h>
#include <zypp/MediaSetAccess.h>
#include <zypp/FileChecker.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
///////////////////////////////////////////////////////////////////
namespace zypp
#include <iosfwd>
#include <list>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/base/Exception.h>
#include <zypp/base/Function.h>
#include <zypp/PathInfo.h>
#include <zypp/base/Flags.h>
#include <zypp/base/Iterator.h>
#include <zypp/base/NonCopyable.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/Pathname.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/String.h>
#include <zypp/base/Logger.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
#include <zypp/HistoryLogData.h>
-/*---------------------------------------------------------------------\
-| |
-| __ __ ____ _____ ____ |
-| \ \ / /_ _/ ___|_ _|___ \ |
-| \ V / _` \___ \ | | __) | |
-| | | (_| |___) || | / __/ |
-| |_|\__,_|____/ |_| |_____| |
-| |
-| core system |
-| (C) SuSE Linux AG |
-\----------------------------------------------------------------------/
-
- File: KVMap.h
-
- Author: Michael Andres <ma@suse.de>
- Maintainer: Michael Andres <ma@suse.de>
-
- Purpose: Convenience stuff for handling (key,value) pairs
-
-/-*/
-#ifndef KVMap_h
-#define KVMap_h
-
-#include <iosfwd>
-#include <vector>
-#include <map>
-
-#include <zypp/base/String.h>
-
-namespace zypp {
- namespace kvmap {
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : KVMapBase::KVMapPolicy
- /**
- * @short KVMapPolicy for conversion of KVMaps to/from string.
- *
- * <b>_kvsplit</b>: The string separating key from value
- *
- * <b>_fsplit</b>: (key,value) pairs are separated by any nonempty
- * sequence of characers occurring in _fsplit
- *
- * <b>_kvjoin</b>: The string used to join key and value.
- *
- * <b>_fjoin</b>: The string used to separate (key,value) pairs.
- *
- * TODO: Maybe options for exact _fsplit handling and timming of values.
- *
- **/
- struct KVMapPolicy {
- std::string _kvsplit;
- std::string _fsplit;
- std::string _kvjoin;
- std::string _fjoin;
- KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r )
- : _kvsplit( kvsplit_r )
- , _fsplit ( fsplit_r )
- , _kvjoin ( _kvsplit )
- , _fjoin ( _fsplit )
- {}
- KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
- const std::string & kvjoin_r )
- : _kvsplit( kvsplit_r )
- , _fsplit ( fsplit_r )
- , _kvjoin ( kvjoin_r )
- , _fjoin ( _fsplit )
- {}
- KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
- const std::string & kvjoin_r, const std::string & fjoin_r )
- : _kvsplit( kvsplit_r )
- , _fsplit ( fsplit_r )
- , _kvjoin ( kvjoin_r )
- , _fjoin ( fjoin_r )
- {}
- };
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : KVMapBase
- /**
- * @short Base class for KVMaps, (key,value) pairs
- **/
- struct KVMapBase : public std::map<std::string,std::string> {
-
- /**
- * (key,value) map type
- **/
- typedef std::map<std::string,std::string> map_type;
-
- KVMapBase()
- {}
- KVMapBase( const map_type & kvmap_r )
- : std::map<std::string,std::string>( kvmap_r )
- {}
-
- /**
- * Test whether key is set.
- **/
- bool has( const std::string & key_r ) const {
- return( find( key_r ) != end() );
- }
-
- /**
- * @short KVMapPolicy for KVMaps using a single char as separator (e.g. mount options).
- **/
- template<char kv, char f>
- struct CharSep : public KVMapPolicy { CharSep() : KVMapPolicy( std::string(1,kv), std::string(1,f) ) {} };
-
- ///////////////////////////////////////////////////////////////////
-
- /**
- * Split str_r into (key,value) map, using the separators defined
- * by opts_r.
- **/
- static map_type split( const std::string & str_r,
- const KVMapPolicy & opts_r ) {
- map_type ret;
- std::vector<std::string> fields;
- str::split( str_r, std::back_inserter(fields), opts_r._fsplit );
-
- for ( unsigned i = 0; i < fields.size(); ++i ) {
- std::string::size_type pos = fields[i].find( opts_r._kvsplit );
- if ( pos == std::string::npos ) {
- ret[fields[i]] = "";
- } else {
- ret[fields[i].substr( 0, pos )] = fields[i].substr( pos+1 );
- }
- }
-
- return ret;
- }
-
- /**
- * Join (key,value) map into string, using the separators defined
- * by opts_r.
- **/
- static std::string join( const map_type & kvmap_r,
- const KVMapPolicy & opts_r ) {
- std::string ret;
-
- for ( map_type::const_iterator it = kvmap_r.begin(); it != kvmap_r.end(); ++it ) {
- if ( ! ret.empty() ) {
- ret += opts_r._fjoin;
- }
- ret += it->first;
- if ( !it->second.empty() ) {
- ret += opts_r._kvjoin + it->second;
- }
- }
-
- return ret;
- }
-
- };
-
-
-
- } // namespace kvmap
-
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : KVMap<KVMapOpts>
- /**
- * @short A map of (key,value) strings.
- *
- * The template argument defines the @ref kvmap::Options for
- * split and join.
- *
- * E.g. mount options (a comma separated list of key[=value] pairs)
- * could be handled by KVMap<kvmap::KVMapBase::Comma>.
- **/
- template<typename KVMapOpts>
- struct KVMap : public kvmap::KVMapBase {
-
- KVMap()
- {}
- KVMap( const char * str_r )
- : kvmap::KVMapBase( split( (str_r?str_r:""), KVMapOpts() ) )
- {}
- KVMap( const std::string & str_r )
- : kvmap::KVMapBase( split( str_r, KVMapOpts() ) )
- {}
- KVMap( const map_type & map_r )
- : kvmap::KVMapBase( map_r )
- {}
-
- ~KVMap() {}
-
- std::string asString() const {
- return join( *this, KVMapOpts() );
- }
-
- };
-
- ///////////////////////////////////////////////////////////////////
-
- template<typename KVMapOpts>
- std::ostream & operator<<( std::ostream & str, const KVMap<KVMapOpts> & obj )
- { return str << obj.asString(); }
-
-///////////////////////////////////////////////////////////////////
-} // namespace zypp
-
-#endif // KVMap_h
+#include <zypp-core/KVMap>
#include <zypp/base/String.h>
#include <zypp/base/Regex.h>
#include <zypp/base/Gettext.h>
-#include <zypp/base/WatchFile.h>
+#include <zypp-core/fs/WatchFile>
#include <zypp/PathInfo.h>
#include <zypp/KeyRing.h>
#include <zypp/ExternalProgram.h>
callback::SendReport<KeyRingReport> report;
MIL << "Going to verify signature for " << filedesc << " ( " << file << " ) with " << signature << endl;
- // if signature does not exists, ask user if he wants to accept unsigned file.
+ // if signature does not exists, ask user if they want to accept unsigned file.
if( signature.empty() || (!PathInfo( signature ).isExist()) )
{
bool res = report->askUserToAcceptUnsignedFile( filedesc, keyContext );
/**
* unlocks by result of query and add to toRemove.
*
- * If unlock non-saved lock (so he is in toAdd list) then both is deleted
- * and nathing happen during save
+ * If unlock non-saved lock (so it is in toAdd list) then both is deleted
+ * and nothing happens during save
*/
void removeLock( const PoolQuery& query );
/**
* remove lock by identifier (e.g. Selectable->ident()
*
- * If unlock non-saved lock (so he is in toAdd list) then both is deleted
- * and nathing happen during save
+ * If unlock non-saved lock (so it is in toAdd list) then both is deleted
+ * and nothing happens during save
*/
void removeLock( const IdString& ident_r );
/**
* remove lock by name and kind
*
- * If unlock non-saved lock (so he is in toAdd list) then both is deleted
- * and nathing happen during save
+ * If unlock non-saved lock (so it is in toAdd list) then both is deleted
+ * and nothing happens during save
*/
void removeLock( const ResKind& kind_r, const IdString& name_r );
void removeLock( const ResKind& kind_r, const C_Str & name_r );
#include <zypp/ZConfig.h>
#include <zypp/base/Logger.h>
#include <zypp/media/MediaManager.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
namespace zypp
{
#include <zypp/base/LogTools.h>
#include <zypp/base/Regex.h>
-#include <zypp/base/UserRequestException.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-core/base/UserRequestException>
+#include <zypp-media/MediaException>
#include <zypp/ZYppCallbacks.h>
#include <zypp/MediaSetAccess.h>
#include <zypp/PathInfo.h>
#include <zypp/media/MediaManager.h>
#include <zypp/Pathname.h>
#include <zypp/CheckSum.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/ManagedFile.h>
///////////////////////////////////////////////////////////////////
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/source/OnMediaLocation.h
- */
-#ifndef ZYPP_SOURCE_ONMEDIALOCATION_H
-#define ZYPP_SOURCE_ONMEDIALOCATION_H
-
-#include <iosfwd>
-
-#include <zypp/base/PtrTypes.h>
-
-#include <zypp/APIConfig.h>
-#include <zypp/Pathname.h>
-#include <zypp/ByteCount.h>
-#include <zypp/CheckSum.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
- ///////////////////////////////////////////////////////////////////
- /// \class OnMediaLocation
- /// \brief Describes a resource file located on a medium.
- ///
- /// Holds the path of a resource on a medium and contains additional
- /// info required to retrieve and verify it (like media number,
- /// checksum, size,...)
- ///
- /// It does not specify the \ref Url of the medium itself.
- ///
- /// Media number \c 0 usually indicates no media access.
- ///////////////////////////////////////////////////////////////////
- class OnMediaLocation
- {
- friend std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
- friend std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj );
-
- public:
- /** Default Ctor indicating no media access. */
- OnMediaLocation();
-
- /** Ctor taking a \a filename_r and \a medianr_r (defaults to \c 1). */
- OnMediaLocation( Pathname filename_r, unsigned medianr_r = 1 );
-
- /** Dtor */
- ~OnMediaLocation();
-
- public:
- /** The path to the resource on the medium. */
- const Pathname & filename() const;
-
- /** The media number the resource is located on. */
- unsigned medianr() const;
-
-
- /** Set \a filename_r and \a medianr_r (defaults to \c 1). */
- OnMediaLocation & setLocation( Pathname filename_r, unsigned medianr_r = 1 );
-
- /** Unset \c filename and set \c medianr to \c 0. */
- OnMediaLocation & unsetLocation();
-
-
- /** Individual manipulation of \c filename (prefer \ref setLocation). */
- OnMediaLocation & changeFilename( Pathname filename_r );
-
- /** Individual manipulation of \c medianr (prefer \ref setLocation). */
- OnMediaLocation & changeMedianr( unsigned medianr_r );
-
- /** Prepend the filename with \a prefix_r */
- OnMediaLocation & prependPath( const Pathname & prefix_r );
-
- public:
- /** Whether this is an optional resource.
- * This is a hint to the downloader not to report an error if
- * the resource is not present on the server.
- */
- bool optional() const;
- /** Set whether the resource is \ref optional. */
- OnMediaLocation & setOptional( bool val );
-
- public:
- /** The size of the resource on the server. */
- const ByteCount & downloadSize() const;
- /** Set the \ref downloadSize. */
- OnMediaLocation & setDownloadSize( ByteCount val_r );
-
- /** The checksum of the resource on the server. */
- const CheckSum & checksum() const;
- /** Set the \ref checksum. */
- OnMediaLocation & setChecksum( CheckSum val_r );
-
- public:
- /** The size of the resource once it has been uncompressed or unpacked. */
- const ByteCount & openSize() const;
- /** Set the \ref openSize. */
- OnMediaLocation & setOpenSize( ByteCount val_r );
-
- /** The checksum of the resource once it has been uncompressed or unpacked. */
- const CheckSum & openChecksum() const;
- /** Set the \ref openChecksum. */
- OnMediaLocation & setOpenChecksum( CheckSum val_r );
-
- public:
- /** The size of the header prepending the resource (e.g. for zchunk). */
- const ByteCount & headerSize() const;
- /** Set the \ref headerSize. */
- OnMediaLocation & setHeaderSize( ByteCount val_r );
-
- /** The checksum of the header prepending the resource (e.g. for zchunk). */
- const CheckSum & headerChecksum() const;
- /** Set the \ref headerChecksum. */
- OnMediaLocation & setHeaderChecksum( CheckSum val_r );
-
- /** The existing deltafile that can be used to reduce download size ( zchunk or metalink ) */
- const Pathname & deltafile() const;
- /** Set the \ref deltafile. */
- OnMediaLocation & setDeltafile( Pathname path );
-
-
- public:
- class Impl; ///< Implementation class.
- private:
- RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation.
- };
-
- /** \relates OnMediaLocation Stream output */
- std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
-
- /** \relates OnMediaLocation Verbose stream output */
- std::ostream & dumOn( std::ostream & str, const OnMediaLocation & obj );
-
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_ONMEDIALOCATION_H
+#include <zypp-core/onmedialocation.h>
#include <sstream>
#include <zypp/base/LogTools.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/base/String.h>
#include <zypp/base/Signal.h>
#include <zypp/base/IOStream.h>
*/
#include <iostream>
#include <zypp/base/Logger.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/PoolItem.h>
#include <zypp/ResPool.h>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/ProgressData.h
- *
-*/
-#ifndef ZYPP_PROGRESSDATA_H
-#define ZYPP_PROGRESSDATA_H
-
-#include <iosfwd>
-#include <string>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/Function.h>
-#include <zypp/base/ProvideNumericId.h>
-
-#include <zypp/Date.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ProgressData
- //
- /** Maintain <tt>[min,max]</tt> and counter <tt>(value)</tt> for progress counting.
- *
- * This class should provide everything the producer of progress data
- * needs. As a convention, a zero sizes range indicates that you are just
- * able to send <em>'still alive'</em> triggers.
- *
- * The counter should be updated in reasonable intervals. Don't mind whether
- * the counter value actually increased or not. ProgressData will recognize
- * your triggers and knows when to actually send notification to a consumer.
- *
- * Each ProgressData object provides a unique numeric id and you may assign
- * it a name.
- *
- * \code
- * bool exampleReceiver( const ProgressData & ticks_r )
- * {
- * DBG << "got ->" << ticks_r.reportValue() << " (" << ticks_r.val() << ")" << endl;
- * return( ticks_r.val() <= 100 ); // Abort if ( val > 100 )
- * }
- *
- * class Example
- * {
- * public:
- *
- * Example( const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() )
- * : _fnc( fnc_r )
- * {}
- *
- * void SendTo( const ProgressData::ReceiverFnc & fnc_r )
- * { _fnc = fnc_r; }
- *
- * public:
- *
- * void action()
- * {
- * ProgressData tics( 10 ); // Expect range 0 -> 10
- * tics.name( "test ticks" ); // Some arbitrary name
- * tics.sendTo( _fnc ); // Send reports to _fnc
- * tics.toMin(); // start sending min (0)
- *
- * for ( int i = 0; i < 10; ++i )
- * {
- * if ( ! tics.set( i ) )
- * return; // user requested abort
- * }
- *
- * tics.toMax(); // take care 100% are reported on success
- * }
- *
- * void action2()
- * {
- * ProgressData tics; // Just send 'still alive' messages
- * tics.name( "test ticks" ); // Some arbitrary name
- * tics.sendTo( _fnc ); // Send reports to _fnc
- * tics.toMin(); // start sending min (0)
- *
- * for ( int i = 0; i < 10; ++i )
- * {
- * if ( ! tics.set( i ) )
- * return; // user requested abort
- * }
- *
- * tics.toMax(); //
- * }
- *
- * private:
- * ProgressData::ReceiverFnc _fnc;
- * };
- * \endcode
- * \code
- * Example t( exampleReceiver );
- * DBG << "Reporting %:" << endl;
- * t.action();
- * DBG << "Reporting 'still alive':" << endl;
- * t.action2();
- * \endcode
- * \code
- * Reporting %:
- * got ->0 (0)
- * got ->10 (1)
- * got ->20 (2)
- * got ->30 (3)
- * got ->40 (4)
- * got ->50 (5)
- * got ->60 (6)
- * got ->70 (7)
- * got ->80 (8)
- * got ->90 (9)
- * got ->100 (10)
- * got ->100 (10)
- * Reporting 'still alive':
- * got ->-1 (0)
- * got ->-1 (9)
- * \endcode
- *
- * The different ammount of triggers is due to different rules for sending
- * percent or 'still alive' messages.
- */
- class ProgressData : public base::ProvideNumericId<ProgressData,unsigned>
- {
- public:
- typedef long long value_type;
- /** Most simple version of progress reporting
- * The percentage in most cases. Sometimes just keepalive.
- * \p sender ProgressData object who sends the progress info
- * \p
- */
- typedef function<bool( const ProgressData & )> ReceiverFnc;
-
- private:
- enum State { INIT, RUN, END };
-
- class Data
- {
- public:
- Data( value_type min_r, value_type max_r, value_type val_r )
- : _state( INIT ), _min( min_r ), _max( max_r ), _val( val_r )
- , _last_val( 0 ), _last_send( 0 )
- {}
-
- public:
- State _state;
- std::string _name;
- value_type _min;
- value_type _max;
- value_type _val;
-
- ReceiverFnc _receiver;
- value_type _last_val;
- Date _last_send;
-
- private:
- /** clone for RWCOW_pointer */
- friend Data * rwcowClone<Data>( const Data * rhs );
- Data * clone() const { return new Data( *this ); }
- };
-
- public:
- /** Ctor no range <tt>[0,0](0)</tt>. */
- ProgressData()
- : _d( new Data( 0, 0, 0 ) )
- {}
-
- /** Ctor <tt>[0,max](0)</tt>. */
- ProgressData( value_type max_r )
- : _d( new Data( 0, max_r, 0 ) )
- {}
-
- /** Ctor <tt>[min,max](min)</tt>. */
- ProgressData( value_type min_r, value_type max_r )
- : _d( new Data( min_r, max_r, min_r ) )
- {}
-
- /** Ctor <tt>[min,max](val)</tt>. */
- ProgressData( value_type min_r, value_type max_r, value_type val_r )
- : _d( new Data( min_r, max_r, val_r ) )
- {}
-
- ~ProgressData()
- {
- if ( _d->_state == RUN )
- {
- _d->_state = END;
- report();
- }
- }
-
- public:
- /** Set new \c min value. */
- void min( value_type min_r )
- { _d->_min = min_r; }
-
- /** Set new \c max value. */
- void max( value_type max_r )
- { _d->_max = max_r; }
-
- /** Set no range <tt>[0,0]</tt>. */
- void noRange()
- { range( 0, 0 ); }
-
- /** Set new <tt>[0,max]</tt>. */
- void range( value_type max_r )
- { range( 0, max_r ); }
-
- /** Set new <tt>[min,max]</tt>. */
- void range( value_type min_r, value_type max_r )
- { min( min_r ); max( max_r ); }
-
- public:
- /** Set counter name. */
- void name( const std::string & name_r )
- { _d->_name = name_r; }
-
- /** Set ReceiverFnc. */
- void sendTo( const ReceiverFnc & fnc_r )
- { _d->_receiver = fnc_r; }
-
- /** Set no ReceiverFnc. */
- void noSend()
- { _d->_receiver = ReceiverFnc(); }
-
- public:
- /** \name Progress reporting.
- *
- * These methods may actually cause a progress report to be sent.
- *
- * All methods return \c bool, because a progress receiver may
- * return \c false to indicate the desire to abort the pending
- * action. The incident is logged, but it's finaly up to the caller
- * to honor this.
- */
- //@{
-
- /** Set new counter \c value. */
- bool set( value_type val_r )
- {
- _d->_val = val_r;
- return report();
- }
-
- /** Set range and counter from an other \ref ProgressData. */
- bool set( const ProgressData & rhs )
- {
- min( rhs.min() );
- max( rhs.max() );
- return set( rhs.val() );
- }
-
- /** Increment counter \c value (default by 1). */
- bool incr( value_type val_r = 1 )
- { return set( val() + val_r ); }
-
- /** Decrement counter \c value (default by 1). */
- bool decr( value_type val_r = 1 )
- { return set( val() - val_r ); }
-
- /** Set counter value to current \c min value. */
- bool toMin()
- { return set( min() ); }
-
- /** Set counter value to current \c max value (unless no range). */
- bool toMax()
- { return hasRange() ? set( max() ) : tick(); }
-
- /** Leave counter value unchanged (still alive). */
- bool tick()
- { return report(); }
-
- //@}
-
- public:
- /** \name Progress receiving.
- */
- //@{
- /** @return Current \c min value. */
- value_type min() const
- { return _d->_min; }
-
- /** @return Current \c max value. */
- value_type max() const
- { return _d->_max; }
-
- /** @return Current counter \c value. */
- value_type val() const
- { return _d->_val; }
-
- /** @return Whether <tt>[min,max]</tt> defines a nonempty range. */
- bool hasRange() const
- { return min() != max(); }
-
- /** @return Whether \ref reportValue will return a percent value.
- * Same as \ref hasRange.
- * \see \ref reportAlive
- */
- bool reportPercent() const
- { return hasRange(); }
-
- /** @return Whether \ref reportValue always returns -1, because we
- * trigger 'still alive' messages. I.e. \ref hasrange is \c false.
- * \see \ref reportPercent
- */
- bool reportAlive() const
- { return ! hasRange(); }
-
- /** @return Either a a percent value or -1.
- * \see \ref reportPercent and \ref reportAlive.
- */
- value_type reportValue() const
- { return hasRange() ? val() * 100 / ( max() - min() ) : -1; }
-
- /** @return The counters name. */
- const std::string & name() const
- { return _d->_name; }
-
- /** @return The ReceiverFnc. */
- const ReceiverFnc & receiver() const
- { return _d->_receiver; }
-
- /** @return Return \c true if this is the final report sent by the
- * ProgressData dtor.
- */
- bool finalReport() const
- { return( _d->_state == END ); }
-
- //@}
-
- private:
- /** Send report if necessary. */
- bool report();
-
- /** Pointer to data. */
- RWCOW_pointer<Data> _d;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates ProgressData Stream output */
- std::ostream & operator<<( std::ostream & str, const ProgressData & obj );
-
- ///////////////////////////////////////////////////////////////////
-
- class InputStream;
- /** \relates ProgressData Setup from \ref InputStream. */
- ProgressData makeProgressData( const InputStream & input_r );
-
- ///////////////////////////////////////////////////////////////////
-
- /**
- * \short Progress callback from another progress
- *
- * This class allows you to pass a progress callback to a
- * subtask based on a current progress data, plus a weight
- * value. Every progress reported by the subtask via
- * this callback will be forwarded to the main progress
- * data, with the corresponding weight.
- *
- * Example:
- *
- * \code
- *
- * // receiver for main task
- * void task_receiver( ProgressData &progress );
- *
- * // subtask prototypes
- * void do_subtask_one( ProgressData::ReceiverFnc &fnc );
- * void do_subtask_two( ProgressData::ReceiverFnc &fnc );
- *
- * // main task
- * ProgressData progress;
- * //progress for subtask 1
- * // which is 80%
- * CombinedProgressData sub1(pd, 80);
- * // the second is only 20%
- * CombinedProgressData sub2(pd, 20);
- * do_subtask_one( sub1 );
- * do_subtask_two( sub2 );
- *
- * \endcode
- */
- class CombinedProgressData
- {
- public:
- /**
- * \short Ctor
- *
- * Creates a \ref ProgressData::ReceiverFnc
- * from a \ref ProgressData object
- *
- * \param pd \ref ProgressData object
- * \param weight Weight of the subtask
- * relative to the main task range.
- *
- * If weight is 0, or \param pd only reports
- * keepalives. then only ticks are sent.
- *
- */
- CombinedProgressData( ProgressData &pd,
- ProgressData::value_type weight = 0 );
-
- /**
- * Implements the \ref ProgressData::ReceiverFnc
- * callback interface
- */
- bool operator()( const ProgressData &progress );
-
- private:
- ProgressData::value_type _weight;
- ProgressData::value_type _last_value;
- ProgressData &_pd;
- };
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PROGRESSDATA_H
+#include <zypp-core/ui/ProgressData>
#include <zypp/base/LogTools.h>
#include <zypp/Date.h>
#include <zypp/KeyManager.h>
+#include <zypp/ZYppFactory.h>
#include <gpgme.h>
}
///////////////////////////////////////////////////////////////////
+ /// \class PublicKeySignatureData::Impl
+ /// \brief PublicKeySignatureData implementation.
+ ///////////////////////////////////////////////////////////////////
+
+ struct PublicKeySignatureData::Impl
+ {
+ std::string _keyid;
+ std::string _name;
+ Date _created;
+ Date _expires;
+
+ public:
+ /** Offer default Impl. */
+ static shared_ptr<Impl> nullimpl();
+
+ private:
+ friend Impl * rwcowClone<Impl>( const Impl * rhs );
+ /** clone for RWCOW_pointer */
+ Impl * clone() const;
+ };
+
+ shared_ptr<zypp::PublicKeySignatureData::Impl> PublicKeySignatureData::Impl::nullimpl()
+ {
+ static shared_ptr<Impl> _nullimpl( new Impl );
+ return _nullimpl;
+ }
+
+ zypp::PublicKeySignatureData::Impl *PublicKeySignatureData::Impl::clone() const
+ {
+ return new Impl( *this );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ /// class PublicKeySignatureData
+ ///////////////////////////////////////////////////////////////////
+
+ PublicKeySignatureData::PublicKeySignatureData()
+ : _pimpl( Impl::nullimpl() )
+ {}
+
+ PublicKeySignatureData::PublicKeySignatureData(const _gpgme_key_sig *rawKeySignatureData)
+ : _pimpl (new Impl)
+ {
+ _pimpl->_keyid = str::asString(rawKeySignatureData->keyid);
+ _pimpl->_name = str::asString(rawKeySignatureData->uid);
+ _pimpl->_created = zypp::Date(rawKeySignatureData->timestamp);
+ _pimpl->_expires = zypp::Date(rawKeySignatureData->expires);
+ }
+
+ PublicKeySignatureData::~PublicKeySignatureData()
+ {}
+
+ PublicKeySignatureData::operator bool() const
+ { return !_pimpl->_keyid.empty(); }
+
+ std::string PublicKeySignatureData::id() const
+ { return _pimpl->_keyid; }
+
+ std::string PublicKeySignatureData::name() const
+ { return _pimpl->_name; }
+
+ Date PublicKeySignatureData::created() const
+ { return _pimpl->_created; }
+
+ Date PublicKeySignatureData::expires() const
+ { return _pimpl->_expires; }
+
+ bool PublicKeySignatureData::expired() const
+ { return isExpired( _pimpl->_expires ); }
+
+ int PublicKeySignatureData::daysToLive() const
+ { return hasDaysToLive( _pimpl->_expires ); }
+
+ std::string PublicKeySignatureData::asString() const
+ {
+ std::string nameStr;
+ if (!name().empty()) {
+ nameStr = str::Str() << name() << " ";
+ }
+ else {
+ nameStr = "[User ID not found] ";
+ }
+ return str::Str() << nameStr
+ << id() << " "
+ << created().printDate()
+ << " [" << expiresDetail( expires() ) << "]";
+ }
+
+ bool PublicKeySignatureData::inTrustedRing() const
+ { return getZYpp()->keyRing()->isKeyTrusted(id()); }
+
+ bool PublicKeySignatureData::inKnownRing() const
+ { return getZYpp()->keyRing()->isKeyKnown(id()); }
+
+ ///////////////////////////////////////////////////////////////////
/// \class PublicKeyData::Impl
/// \brief PublicKeyData implementation.
///////////////////////////////////////////////////////////////////
Date _expires;
std::vector<PublicSubkeyData> _subkeys;
+ std::vector<PublicKeySignatureData> _signatures;
public:
bool hasSubkeyId( const std::string & id_r ) const;
shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::fromGpgmeKey(gpgme_key_t rawData)
{
- //gpgpme stores almost nothing in the top level key
+ //gpgme stores almost nothing in the top level key
//the information we look for is stored in the subkey, where subkey[0]
//is always the primary key
gpgme_subkey_t sKey = rawData->subkeys;
// versions of the same key are imported. We take the last signature here,
// the one GPGME_EXPORT_MODE_MINIMAL will later use in export.
for ( auto t = rawData->uids->signatures->next; t; t = t->next ) {
+ if (t->keyid != nullptr) {
+ data->_signatures.push_back(PublicKeySignatureData(t));
+ }
+
if ( t->timestamp > data->_created )
data->_created = t->timestamp;
}
Iterable<PublicKeyData::SubkeyIterator> PublicKeyData::subkeys() const
{ return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
+ Iterable<PublicKeyData::KeySignatureIterator> PublicKeyData::signatures() const
+ { return makeIterable( &(*_pimpl->_signatures.begin()), &(*_pimpl->_signatures.end()) ); }
+
bool PublicKeyData::providesKey( const std::string & id_r ) const
{
if ( not isSafeKeyId( id_r ) )
struct _gpgme_key;
struct _gpgme_subkey;
+struct _gpgme_key_sig;
///////////////////////////////////////////////////////////////////
namespace zypp
{ return str << obj.asString(); }
///////////////////////////////////////////////////////////////////
+ /// \class PublicKeySignatureData
+ /// \brief Class representing a signature on a GPG Public Key.
+ /// \see \ref PublicKeyData.
+ ///////////////////////////////////////////////////////////////////
+ class PublicKeySignatureData
+ {
+ public:
+ /** Default constructed: empty data. */
+ PublicKeySignatureData();
+
+ ~PublicKeySignatureData();
+
+ /** Whether this contains valid data (not default constructed). */
+ explicit operator bool() const;
+
+ public:
+ /** The key ID of key used to create the signature. */
+ std::string id() const;
+
+ /** The user ID associated with this key, if present. */
+ std::string name() const;
+
+ /** Creation date. */
+ Date created() const;
+
+ /** Expiry date, or \c Date() if the key never expires. */
+ Date expires() const;
+
+ /** Whether the key has expired. */
+ bool expired() const;
+
+ /** Number of days (24h) until the key expires (or since it expired).
+ * A value of \c 0 means the key will expire within the next 24h.
+ * Negative values indicate the key has expired less than \c N days ago.
+ * For keys without expiration date \c INT_MAX is returned.
+ */
+ int daysToLive() const;
+
+ /** Whether the signature is trusted in rpmdb. */
+ bool inTrustedRing() const;
+
+ /** Whether the key has been seen before. */
+ bool inKnownRing() const;
+
+ /** Simple string representation.
+ * Encodes \ref id, \ref created and \ref expires
+ * \code
+ * 640DB551 2016-04-12 [expires: 2019-04-12]
+ * \endcode
+ */
+ std::string asString() const;
+
+ private:
+ struct Impl;
+ RWCOW_pointer<Impl> _pimpl;
+ friend class PublicKeyData;
+ friend std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj );
+ PublicKeySignatureData(const _gpgme_key_sig *rawKeySignatureData);
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates PublicKeySignatureData Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const PublicKeySignatureData & obj )
+ { return str << obj.asString(); }
+
+ ///////////////////////////////////////////////////////////////////
/// \class PublicKeyData
/// \brief Class representing one GPG Public Keys data.
/// \ref PublicKeyData are provided e.g. by a \ref PublicKey or
int daysToLive() const;
/** * Expiry info in a human readable form.
- * The exipry daye plus an annotation if the key has expired, or will
+ * The expiry date plus an annotation if the key has expired, or will
* expire within 90 days.
* \code
* (does not expire)
public:
typedef const PublicSubkeyData * SubkeyIterator;
+ typedef const PublicKeySignatureData * KeySignatureIterator;
/** Whether \ref subkeys is not empty. */
bool hasSubkeys() const;
/** Iterate any subkeys. */
Iterable<SubkeyIterator> subkeys() const;
+ /** Iterate all key signatures. */
+ Iterable<KeySignatureIterator> signatures() const;
+
/** Whether \a id_r is the \ref id or \ref fingerprint of the primary key or of a subkey.
* As a convenience also allows to test the 8byte short ID e.g. rpm uses as version.
*/
{ return id_r.size() >= 16; }
public:
+ /** Whether \ref signatures is not empty. */
+ bool hasSignatures() const;
+
+ public:
/** Random art fingerprint visualization type (\ref base::DrunkenBishop). */
typedef base::DrunkenBishop AsciiArt;
currOff++;
currROff--;
- // a kernel package might be explicitely locked by version
+ // a kernel package might be explicitly locked by version
// We need to go over all package name provides ( provides is named like the package ) and match
// them against the specified version to know which ones to keep. (bsc#1176740 bsc#1176192)
std::for_each( kernelMap.second.begin(), kernelMap.second.end(), [ & ]( sat::Solvable solv ){
editionToSolvableMap[edToUse].push_back( installedKrnlPck );
- //in the first step we collect all packages in this list, then later we will remove the packages we want to explicitely keep
+ //in the first step we collect all packages in this list, then later we will remove the packages we want to explicitly keep
packagesToRemove.insert( installedKrnlPck );
};
} else {
- // if adapting the groups do not forget to explicitely handle the group when querying the matches
- const str::regex explicitelyHandled("kernel-syms(-.*)?|kernel(-.*)?-devel");
+ // if adapting the groups do not forget to explicitly handle the group when querying the matches
+ const str::regex explicitlyHandled("kernel-syms(-.*)?|kernel(-.*)?-devel");
MIL << "Not a kernel package, inspecting more closely " << std::endl;
// we directly handle all noarch packages that export multiversion(kernel)
if ( installedKrnlPck.arch() == Arch_noarch ) {
- MIL << "Handling package explicitely due to architecture (noarch)."<< std::endl;
+ MIL << "Handling package explicitly due to architecture (noarch)."<< std::endl;
addPackageToMap( GroupInfo::Sources, installedKrnlPck.name(), "", installedKrnlPck );
- } else if ( str::smatch match; str::regex_match( installedKrnlPck.name(), match, explicitelyHandled ) ) {
+ } else if ( str::smatch match; str::regex_match( installedKrnlPck.name(), match, explicitlyHandled ) ) {
// try to get the flavour from the name
// if we have a kernel-syms getting no flavour means we have the "default" one, otherwise we use the flavour
else if ( installedKrnlPck.name() == "kernel-syms" )
flav = "default";
- MIL << "Handling package explicitely due to name match."<< std::endl;
+ MIL << "Handling package explicitly due to name match."<< std::endl;
addPackageToMap ( GroupInfo::RelatedBinaries, installedKrnlPck.name(), flav, installedKrnlPck );
} else {
- MIL << "Package not explicitely handled" << std::endl;
+ MIL << "Package not explicitly handled" << std::endl;
}
}
#include <zypp/base/Gettext.h>
#include <zypp/base/LogTools.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/parser/xml/XmlEscape.h>
#include <zypp/ManagedFile.h>
#include <zypp/ExternalProgram.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/parser/xml/Reader.h>
{
WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
// Using the fist locale instead of returning no text at all.
- // So the user might recognize that there is a license, even if he
+ // So the user might recognize that there is a license, even if they
// can't read it.
getLang = *avlocales.begin();
}
#include <solv/solvversion.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/LogTools.h>
#include <zypp/base/Gettext.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/base/Function.h>
#include <zypp/base/Regex.h>
#include <zypp/PathInfo.h>
#include <zypp/RepoManager.h>
#include <zypp/media/MediaManager.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/auth/CredentialManager>
+#include <zypp-media/MediaException>
#include <zypp/MediaSetAccess.h>
#include <zypp/ExternalProgram.h>
#include <zypp/ManagedFile.h>
#include <zypp/repo/ServiceType.h>
#include <zypp/ServiceInfo.h>
#include <zypp/RepoStatus.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
///////////////////////////////////////////////////////////////////
namespace zypp
//------------------------------------------------------------------------
// get/set functions, returnig \c true if requested status change
- // was successfull (i.e. leading to the desired transaction).
+ // was successful (i.e. leading to the desired transaction).
// If a lower level (e.g.SOLVER) wants to transact, but it's
// already set by a higher level, \c true should be returned.
// Removing a higher levels transaction bit should fail.
* Default for all flags is \c false unless overwritten by zypp.conf.
*/
//@{
- /** Whether to allow to downgrade installed solvable */
+ /** Whether to allow one to downgrade installed solvable */
void setAllowDowngrade( bool yesno_r );
void setDefaultAllowDowngrade(); // Set back to default
bool allowDowngrade() const;
- /** Whether to allow to change name of installed solvable */
+ /** Whether to allow one to change name of installed solvable */
void setAllowNameChange( bool yesno_r );
void setDefaultAllowNameChange(); // Set back to default
bool allowNameChange() const;
- /** Whether to allow to change architecture of installed solvables */
+ /** Whether to allow one to change architecture of installed solvables */
void setAllowArchChange( bool yesno_r );
void setDefaultAllowArchChange(); // Set back to default
bool allowArchChange() const;
- /** Whether to allow to change vendor of installed solvables
+ /** Whether to allow one to change vendor of installed solvables
* \see \ref VendorAttr for definition of vendor equivalence.
*/
void setAllowVendorChange( bool yesno_r );
/**
* Cleanup when deleting packages. Whether the solver should per default
- * try to remove packages exclusively required by the ones he's asked to delete.
+ * try to remove packages exclusively required by the ones it's asked to delete.
*/
void setCleandepsOnRemove( bool yesno_r );
void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
* all DUP flags is \c true unless overwritten by zypp.conf.
*/
//@{
- /** dup mode: allow to downgrade installed solvable */
+ /** dup mode: allow one to downgrade installed solvable */
void dupSetAllowDowngrade( bool yesno_r );
void dupSetDefaultAllowDowngrade(); // Set back to default (in zypp.conf)
bool dupAllowDowngrade() const;
- /** dup mode: allow to change name of installed solvable */
+ /** dup mode: allow one to change name of installed solvable */
void dupSetAllowNameChange( bool yesno_r );
void dupSetDefaultAllowNameChange(); // Set back to default (in zypp.conf)
bool dupAllowNameChange() const;
- /** dup mode: allow to change architecture of installed solvables */
+ /** dup mode: allow one to change architecture of installed solvables */
void dupSetAllowArchChange( bool yesno_r );
void dupSetDefaultAllowArchChange(); // Set back to default (in zypp.conf)
bool dupAllowArchChange() const;
- /** dup mode: allow to change vendor of installed solvables*/
+ /** dup mode: allow one to change vendor of installed solvables*/
void dupSetAllowVendorChange( bool yesno_r );
void dupSetDefaultAllowVendorChange(); // Set back to default (in zypp.conf)
bool dupAllowVendorChange() const;
#include <iostream>
#include <zypp/base/String.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/parser/xml/XmlEscape.h>
#include <zypp/RepoInfo.h>
public:
/** \name Base product and registration.
*
- * Static methods herein allow to retrieve the values without explicitly
+ * Static methods herein allow one to retrieve the values without explicitly
* initializing the \ref Target. They take a targets root directory as
* argument. If an empty \ref Pathname is passed, an already existing
* Targets root is used, otherwise \c "/" is assumed.
#include <zypp/ZConfig.h>
#include <zypp/PathInfo.h>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr"
#include <fstream>
#include <zypp/base/LogTools.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/String.h>
#include <zypp/base/Regex.h>
#include <zypp/ZConfig.h>
#include <zypp/ZYppFactory.h>
#include <zypp/PathInfo.h>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
#include <zypp/sat/Pool.h>
#include <zypp/sat/detail/PoolImpl.h>
+#include <zypp-media/MediaConfig>
+
using std::endl;
using namespace zypp::filesystem;
using namespace zypp::parser;
ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
}
}
- else if ( architecture == Arch_armv7l || architecture == Arch_armv6l )
+ else if ( architecture == Arch_armv8l || architecture == Arch_armv7l || architecture == Arch_armv6l )
{
std::ifstream platform( "/etc/rpm/platform" );
if (platform)
{
for( iostr::EachLine in( platform ); in; in.next() )
{
+ if ( str::hasPrefix( *in, "armv8hl-" ) )
+ {
+ architecture = Arch_armv8hl;
+ WAR << "/etc/rpm/platform contains armv8hl-: architecture upgraded to '" << architecture << "'" << endl;
+ break;
+ }
if ( str::hasPrefix( *in, "armv7hl-" ) )
{
architecture = Arch_armv7hl;
, download_use_deltarpm_always ( false )
, download_media_prefer_download( true )
, download_mediaMountdir ( "/var/adm/mount" )
- , download_max_concurrent_connections( 5 )
- , download_min_download_speed ( 0 )
- , download_max_download_speed ( 0 )
- , download_max_silent_tries ( 5 )
- , download_transfer_timeout ( 180 )
, commit_downloadMode ( DownloadDefault )
, gpgCheck ( true )
, repoGpgCheck ( indeterminate )
INT << "Reconfigure to " << _parsedZyppConf << endl;
ZConfig::instance()._pimpl.reset( this );
}
+
if ( PathInfo(_parsedZyppConf).isExist() )
{
parser::IniDict dict( _parsedZyppConf );
{
std::string entry(it->first);
std::string value(it->second);
+
+ if ( _mediaConf.setConfigValue( section, entry, value ) )
+ continue;
+
//DBG << (*it).first << "=" << (*it).second << endl;
if ( section == "main" )
{
{
download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
}
-
else if ( entry == "download.media_mountdir" )
{
download_mediaMountdir.restoreToDefault( Pathname(value) );
}
-
- else if ( entry == "download.max_concurrent_connections" )
- {
- str::strtonum(value, download_max_concurrent_connections);
- }
- else if ( entry == "download.min_download_speed" )
- {
- str::strtonum(value, download_min_download_speed);
- }
- else if ( entry == "download.max_download_speed" )
- {
- str::strtonum(value, download_max_download_speed);
- }
- else if ( entry == "download.max_silent_tries" )
- {
- str::strtonum(value, download_max_silent_tries);
- }
- else if ( entry == "download.transfer_timeout" )
- {
- str::strtonum(value, download_transfer_timeout);
- if ( download_transfer_timeout < 0 ) download_transfer_timeout = 0;
- else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600;
- }
else if ( entry == "commit.downloadMode" )
{
commit_downloadMode.set( deserializeDownloadMode( value ) );
{
history_log_path = Pathname(value);
}
- else if ( entry == "credentials.global.dir" )
- {
- credentials_global_dir_path = Pathname(value);
- }
- else if ( entry == "credentials.global.file" )
- {
- credentials_global_file_path = Pathname(value);
- }
else if ( entry == "techpreview.ZYPP_SINGLE_RPMTRANS" )
{
DBG << "techpreview.ZYPP_SINGLE_RPMTRANS=" << value << endl;
DefaultOption<bool> download_media_prefer_download;
DefaultOption<Pathname> download_mediaMountdir;
- int download_max_concurrent_connections;
- int download_min_download_speed;
- int download_max_download_speed;
- int download_max_silent_tries;
- int download_transfer_timeout;
-
Option<DownloadMode> commit_downloadMode;
DefaultOption<bool> gpgCheck;
target::rpm::RpmInstFlags rpmInstallFlags;
Pathname history_log_path;
- Pathname credentials_global_dir_path;
- Pathname credentials_global_file_path;
std::string userData;
Option<Pathname> pluginsPath;
+ /* Other config singleton instances */
+ MediaConfig &_mediaConf = MediaConfig::instance();
+
private:
// HACK for bnc#906096: let pool re-evaluate multiversion spec
// if target root changes. ZConfig returns data sensitive to
if ( ! cacheHit )
{
- if ( root_r == "/" )
- ret.swap( _specMap[Pathname()] ); // original zypp.conf
- else
- scanConfAt( root_r, ret, zConfImpl_r ); // scan zypp.conf at root_r
+ // bsc#1193488: If no (/root)/.../zypp.conf exists use the default zypp.conf
+ // multiversion settings. It is a legacy that the packaged multiversion setting
+ // in zypp.conf (the kernel) may differ from the builtin default (empty).
+ // But we want a missing config to behave similar to the default one, otherwise
+ // a bare metal install easily runs into trouble.
+ if ( root_r == "/" || scanConfAt( root_r, ret, zConfImpl_r ) == 0 )
+ ret = _specMap[Pathname()];
scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
using zypp::operator<<;
MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
{ return _specMap[Pathname()]; }
private:
- void scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
+ int scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
{
static const str::regex rx( "^multiversion *= *(.*)" );
str::smatch what;
- iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
+ return iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
[&]( int num_r, std::string line_r )->bool
{
if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
{ _pimpl->download_media_prefer_download.restoreToDefault(); }
long ZConfig::download_max_concurrent_connections() const
- { return _pimpl->download_max_concurrent_connections; }
+ { return _pimpl->_mediaConf.download_max_concurrent_connections(); }
long ZConfig::download_min_download_speed() const
- { return _pimpl->download_min_download_speed; }
+ { return _pimpl->_mediaConf.download_min_download_speed(); }
long ZConfig::download_max_download_speed() const
- { return _pimpl->download_max_download_speed; }
+ { return _pimpl->_mediaConf.download_max_download_speed(); }
long ZConfig::download_max_silent_tries() const
- { return _pimpl->download_max_silent_tries; }
+ { return _pimpl->_mediaConf.download_max_silent_tries(); }
long ZConfig::download_transfer_timeout() const
- { return _pimpl->download_transfer_timeout; }
+ { return _pimpl->_mediaConf.download_transfer_timeout(); }
Pathname ZConfig::download_mediaMountdir() const { return _pimpl->download_mediaMountdir; }
void ZConfig::set_download_mediaMountdir( Pathname newval_r ) { _pimpl->download_mediaMountdir.set( std::move(newval_r) ); }
Pathname ZConfig::credentialsGlobalDir() const
{
- return ( _pimpl->credentials_global_dir_path.empty() ?
- Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
+ return _pimpl->_mediaConf.credentialsGlobalDir();
}
Pathname ZConfig::credentialsGlobalFile() const
{
- return ( _pimpl->credentials_global_file_path.empty() ?
- Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
+ return _pimpl->_mediaConf.credentialsGlobalFile();
}
///////////////////////////////////////////////////////////////////
*
* It reads /etc/zypp/zypp.conf, the filename can be overridden by
* setting the ZYPP_CONF environment variable to a different file.
+ * Config values for \ref MediaConfig are forwarded to the MediaConfig
+ * singleton.
*
* Note, if you add settings to this file, please follow the following
* convention:
#include <zypp/Package.h>
#include <zypp/Patch.h>
#include <zypp/Url.h>
-#include <zypp/ProgressData.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-core/ui/ProgressData>
+#include <zypp-media/auth/AuthData>
///////////////////////////////////////////////////////////////////
namespace zypp
*
* Userdata accepted:
* \param "Action" DownloadResolvableReport::Action user advice how to behave on error (ABORT).
- * If you set just an empty value here, a default probelm report will be triggered.
+ * If you set just an empty value here, a default problem report will be triggered.
*
* Legacy data:
* \param "Package" Replaced by \c "ResObject" in 16.10.0. Package::constPtr of the package (\c nullptr in case of a SrcPackage)
* data. As an input parameter auth_data can be prefilled with
* username (from previous try) or auth_type (available
* authentication methods aquired from server (only CurlAuthData)).
- * As an output parameter it serves for sending username, pasword
+ * As an output parameter it serves for sending username, password
* or other special data (derived AuthData objects).
* \return true if user chooses to continue with authentication,
* false otherwise
};
#endif
+ ///////////////////////////////////////////////////////////////////
+ /// \brief Report active throughout the whole rpm transaction.
+ ///
+ /// The report covers events not directly related to an individual
+ /// sub-task. Mostly log lines.
+ /// \todo maybe include the sub-task reports here as well, so it
+ /// becomes the only report needed to follow the transaction.
+ ///////////////////////////////////////////////////////////////////
+ struct SingleTransReport : public callback::ReportBase
+ {
+ /** \c "zypp-rpm/logline" report a line suitable to be written to the screen.
+ * UserData:
+ * \c "line" : std::reference_wrapper<const std::string>; the line to show
+ * \c "level" : enum class loglevel; rendering hint
+ */
+ static const UserData::ContentType contentLogline;
+ /** Rendering hint for log-lines to show. */
+ enum class loglevel { dbg, msg, war, err, crt };
+ /** Suggested prefix for log-lines to show. */
+ static const char *const loglevelPrefix( loglevel level_r )
+ {
+ switch ( level_r ) {
+ case loglevel::crt: return "fatal error: ";
+ case loglevel::err: return "error: ";
+ case loglevel::war: return "warning: ";
+ case loglevel::msg: return "";
+ case loglevel::dbg: return "D: ";
+ }
+ }
+ };
+
// Generic transaction reports, this is used for verifying and preparing tasks, the name param
// for the start function defines which report we are looking at
struct TransactionReportSA : public callback::ReportBase
* type of conflict of old and new lock
*/
enum ConflictState{
- SAME_RESULTS, /**< locks lock same item in pool but his parameters is different */
+ SAME_RESULTS, /**< locks lock same item in pool but its parameters are different */
INTERSECT /**< locks lock some file and unlocking lock unlock only part
* of iti, so removing old lock can unlock more items in pool */
};
//@}
};
+ ///////////////////////////////////////////////////////////////////
+ /// \class UserDataJobReport
+ /// \brief \ref JobReport convenience sending this instance of \ref UserData with each message.
+ ///////////////////////////////////////////////////////////////////
+ struct UserDataJobReport : public JobReport::UserData
+ {
+ using JobReport::UserData::UserData;
+
+ bool debug( const std::string & msg_r ) { return JobReport::debug( msg_r, *this ); }
+ bool info( const std::string & msg_r ) { return JobReport::info( msg_r, *this ); }
+ bool warning( const std::string & msg_r ) { return JobReport::warning( msg_r, *this ); }
+ bool error( const std::string & msg_r ) { return JobReport::error( msg_r, *this ); }
+ bool important( const std::string & msg_r ) { return JobReport::important( msg_r, *this ); }
+ bool data( const std::string & msg_r ) { return JobReport::data( msg_r, *this ); }
+ };
/////////////////////////////////////////////////////////////////
} // namespace zypp
#include <zypp/PoolItem.h>
#include <zypp/sat/Transaction.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
///////////////////////////////////////////////////////////////////
namespace zypp
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
#include <zypp/ExternalProgram.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/ProvideNumericId>
///////////////////////////////////////////////////////////////////
namespace zypp
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/DefaultIntegral.h
- *
-*/
-#ifndef ZYPP_BASE_DEFAULTINTEGRAL_H
-#define ZYPP_BASE_DEFAULTINTEGRAL_H
-
-#include <iosfwd>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits/is_integral.hpp>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : DefaultIntegral<Tp,TInitial>
- //
- /** Integral type with defined initial value when default constructed.
- *
- * \code
- * typedef DefaultIntegral<unsigned,0> Counter;
- * std::map<KeyType,Counter> stats;
- * for ( all keys )
- * ++(stats[key]);
- * \endcode
- *
- * \todo maybe specialize for bool, add logical and bit operators
- * \todo let TInitial default to 0 then remove base/Counter.h
- */
- template<class Tp, Tp TInitial>
- class DefaultIntegral
- {
- public:
- typedef Tp value_type;
-
- public:
- DefaultIntegral( Tp val_r = TInitial )
- : _val( val_r )
- { BOOST_STATIC_ASSERT(boost::is_integral<Tp>::value); }
-
- /** Conversion to Tp. */
- //@{
- Tp & get() { return _val; }
- Tp get() const { return _val; }
-
- operator Tp &() { return get(); }
- operator Tp () const { return get(); }
- //@}
-
- /** The initial value. */
- constexpr Tp initial() const { return TInitial; }
-
- /** Reset to the defined initial value. */
- DefaultIntegral & reset() { _val = TInitial; return *this; }
-
- /** \name Arithmetic operations.
- * \c + \c - \c * \c / are provided via conversion to Tp.
- */
- //@{
- DefaultIntegral & operator=( Tp rhs ) { _val = rhs; return *this; }
- DefaultIntegral & operator+=( Tp rhs ) { _val += rhs; return *this; }
- DefaultIntegral & operator-=( Tp rhs ) { _val -= rhs; return *this; }
- DefaultIntegral & operator*=( Tp rhs ) { _val *= rhs; return *this; }
- DefaultIntegral & operator/=( Tp rhs ) { _val /= rhs; return *this; }
-
- DefaultIntegral & operator++(/*prefix*/) { ++_val; return *this; }
- DefaultIntegral & operator--(/*prefix*/) { --_val; return *this; }
-
- DefaultIntegral operator++(int/*postfix*/) { return _val++; }
- DefaultIntegral operator--(int/*postfix*/) { return _val--; }
- //@}
-
- private:
- Tp _val;
- };
-
- /** \relates DefaultIntegral \c true initialized \c bool */
- typedef DefaultIntegral<bool,true> TrueBool;
-
- /** \relates DefaultIntegral \c false initialized \c bool */
- typedef DefaultIntegral<bool,false> FalseBool;
-
- /** \relates DefaultIntegral \c zero initialized \c integral */
- template<typename TIntegral>
- using ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>;
-
- template<class Tp, Tp TInitial>
- std::string asString( const DefaultIntegral<Tp,TInitial> & obj )
- { return asString( obj.get() ); }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_DEFAULTINTEGRAL_H
+#include <zypp-core/base/DefaultIntegral>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/DtorReset.h
- *
-*/
-#ifndef ZYPP_BASE_DTORRESET_H
-#define ZYPP_BASE_DTORRESET_H
-
-#include <zypp/base/PtrTypes.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : DtorReset
- //
- /** Assign a vaiable a certain value when going out of scope.
- * Use it e.g. to reset/cleanup in presence of exceptions.
- * \code
- * struct Foo
- * {
- * void consume()
- * {
- * DtorReset x(_inConsume,false);
- * _inConsume = true;
- * MIL << _inConsume << endl;
- * };
- *
- * DefaultIntegral<bool,false> _inConsume;
- * };
- *
- * Foo f;
- * MIL << f._inConsume << endl; // 0
- * f.consume(); // 1
- * MIL << f._inConsume << endl; // 0
- * \endcode
- * \ingroup g_RAII
- * \todo Check if using call_traits enables 'DtorReset(std::string,"value")',
- * as this currently would require assignment of 'char[]'.
- */
- class DtorReset
- {
- public:
- DtorReset() {}
-
- template<class TVar>
- DtorReset( TVar & var_r )
- : _pimpl( new Impl<TVar,TVar>( var_r, var_r ) )
- {}
- template<class TVar, class TVal>
- DtorReset( TVar & var_r, const TVal & val_r )
- : _pimpl( new Impl<TVar,TVal>( var_r, val_r ) )
- {}
-
- private:
- /** Requires TVal being copy constructible, and assignment
- * <tt>TVar = TVal</tt> defined. */
- template<class TVar, class TVal>
- struct Impl
- {
- Impl( TVar & var_r, const TVal & val_r )
- : _var( var_r )
- , _val( val_r )
- {}
- ~Impl()
- { _var = _val; }
- TVar & _var;
- TVal _val;
- };
- shared_ptr<void> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_DTORRESET_H
+#include <zypp-core/base/DtorReset>
-/*---------------------------------------------------------------------\
-| |
-| __ __ ____ _____ ____ |
-| \ \ / /_ _/ ___|_ _|___ \ |
-| \ V / _` \___ \ | | __) | |
-| | | (_| |___) || | / __/ |
-| |_|\__,_|____/ |_| |_____| |
-| |
-| core system |
-| (C) SuSE Linux Products GmbH |
-\----------------------------------------------------------------------/
-
- File: GzStream.h
-
- Author: Michael Andres <ma@suse.de>
- Maintainer: Michael Andres <ma@suse.de>
-
- Purpose: Streams reading and writing gzip files.
-
-/-*/
-#ifndef ZYPP_BASE_GZSTREAM_H
-#define ZYPP_BASE_GZSTREAM_H
-
-#include <iosfwd>
-#include <streambuf>
-#include <vector>
-#include <zlib.h>
-
-#include <zypp/base/SimpleStreambuf.h>
-#include <zypp/base/fXstream.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- namespace gzstream_detail
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ZlibError
- /**
- * @short Helper class to ship zlib errors.
- **/
- struct ZlibError
- {
- /**
- * The zlib error code
- **/
- int _zError;
-
- /**
- * errno, valid if zError is Z_ERRNO
- **/
- int _errno;
-
- ZlibError()
- : _zError( 0 ), _errno( 0 )
- {}
-
- /**
- * Return string describing the zlib error code
- **/
- std::string
- strerror() const;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates ZlibError Stream output. */
- inline std::ostream & operator<<( std::ostream & str, const ZlibError & obj )
- { return str << obj.strerror(); }
-
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : gzstreambufimpl
- /**
- * @short Streambuffer reading or writing gzip files.
- *
- * Read and write mode are mutual exclusive. Seek is supported,
- * but zlib restrictions appy (only forward seek in write mode;
- * backward seek in read mode might be expensive).Putback is not
- * supported.
- *
- * Reading plain (no gziped) files is possible as well.
- *
- * This streambuf is used in @ref ifgzstream and @ref ofgzstream.
- **/
- class gzstreambufimpl {
- public:
-
- using error_type = ZlibError;
-
- ~gzstreambufimpl()
- { closeImpl(); }
-
- bool
- isOpen () const
- { return _file; }
-
- bool
- canRead () const
- { return( _mode == std::ios_base::in ); }
-
- bool
- canWrite () const
- { return( _mode == std::ios_base::out ); }
-
- bool
- canSeek ( std::ios_base::seekdir way_r ) const
- { return ( way_r == std::ios_base::beg || way_r == std::ios_base::cur ); }
-
- protected:
- bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
- bool closeImpl ();
-
- //! Tell the file position in the compressed file.
- //! Analogous to tell(2), complementary to gztell.
- off_t compressed_tell() const;
-
- public:
- /**
- * The last error returned fron zlib.
- **/
- error_type
- error() const
- { return _error; }
-
- std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r );
- bool writeData( const char * buffer_r, std::streamsize count_r );
- off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
- off_t tell() const;
-
- private:
-
- void
- setZError() const
- { gzerror( _file, &_error._zError ); }
-
- //! file descriptor of the compressed file
- int _fd = -1;
-
- gzFile _file = nullptr;
-
- std::ios_base::openmode _mode = std::ios_base::openmode(0);
-
- mutable ZlibError _error;
-
- };
- using fgzstreambuf = detail::SimpleStreamBuf<gzstreambufimpl>;
- } // namespace gzstream_detail
-
- /**
- * istream reading gzip files as well as plain files.
- **/
- typedef detail::fXstream<std::istream,gzstream_detail::fgzstreambuf> ifgzstream;
-
- /**
- * ostream writing gzip files.
- **/
- typedef detail::fXstream<std::ostream,gzstream_detail::fgzstreambuf> ofgzstream;
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-#endif // ZYPP_BASE_GZSTREAM_H
+#include <zypp-core/base/GzStream>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/InputStream.h
- *
-*/
-#ifndef ZYPP_BASE_INPUTSTREAM_H
-#define ZYPP_BASE_INPUTSTREAM_H
-
-#include <iosfwd>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/DefaultIntegral.h>
-#include <zypp/Pathname.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : InputStream
- //
- /** Helper to create and pass std::istream.
- * The provided std::istream may either be std::cin,
- * sone (gziped) file or an aleady existig \c std::istream.
- *
- * An optional \c name arument may be passed to the ctor,
- * to identify the stream in log messages, even if it is
- * not a file.
- *
- * Per default the name is "STDIN", the path to an input file
- * or empty.
- *
- * \code
- * void parse( const InputStream & input = InputStream() )
- * {
- * // process input.stream() and refer to input.name()
- * // in log messages.
- * }
- *
- * parse(); // std::cin
- * parse( "/some/file" ); // file
- * parse( "/some/file.gz" ); // gziped file
- * std::istream & mystream;
- * parse( mystream ); // some existing stream
- * parse( InputStream( mystream,
- * "my stream's name" ) );
- * \endcode
- */
- class InputStream
- {
- public:
- /** Default ctor providing \c std::cin. */
- InputStream();
-
- /** Ctor providing an aleady existig \c std::istream. */
- InputStream( std::istream & stream_r,
- const std::string & name_r = std::string() );
-
- /** Ctor for reading a (gziped) file. */
- InputStream( const Pathname & file_r );
-
- /** Ctor for reading a (gziped) file. */
- InputStream( const Pathname & file_r,
- const std::string & name_r );
-
- /** Ctor for reading a (gziped) file. */
- InputStream( const std::string & file_r );
-
- /** Ctor for reading a (gziped) file. */
- InputStream( const std::string & file_r,
- const std::string & name_r );
-
- /** Ctor for reading a (gziped) file. */
- InputStream( const char * file_r );
-
- /** Ctor for reading a (gziped) file. */
- InputStream( const char * file_r,
- const std::string & name_r );
-
- /** Dtor. */
- ~InputStream();
-
- /** The std::istream.
- * \note The provided std::istream is never \c const.
- */
- std::istream & stream() const
- { return *_stream; }
-
- /** Allow implicit conversion to std::istream.*/
- operator std::istream &() const
- { return *_stream; }
-
- /** Name of the std::istream.
- * Per default this is "STDIN", the path to an input file or
- * empty. A custom string may be provided to the ctor.
- *
- * This may be used in log messages to identify the stream even
- * even if it is not a file.
- */
- const std::string & name() const
- { return _name; }
-
- /** Path to the input file or empty if no file. */
- const Pathname & path() const
- { return _path; }
-
- /** Size of the input stream (informal).
- * If constructed from an uncompressed file, the file size.
- * Otherwise \c -1. See \ref setSize;
- */
- std::streamoff size() const
- { return _size; }
-
- /** Set the size of the input stream.
- * You may set it to whatever vaule is appropriate. E.g.
- * <tt>*=10</tt> to compensate gzip comression. or the
- * number of items, lines, ... The value is not used here,
- * just provided.
- */
- void setSize( std::streamoff val_r )
- { _size = val_r; }
-
- private:
- Pathname _path;
- shared_ptr<std::istream> _stream;
- std::string _name;
- DefaultIntegral<std::streamoff,-1> _size;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates InputStream Stream output */
- std::ostream & operator<<( std::ostream & str, const InputStream & obj );
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_INPUTSTREAM_H
+#include <zypp-core/base/InputStream>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/ProvideNumericId.h
- *
-*/
-#ifndef ZYPP_BASE_PROVIDENUMERICID_H
-#define ZYPP_BASE_PROVIDENUMERICID_H
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace base
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ProvideNumericId
- //
- /** Base class for objects providing a numeric Id.
- * The ctor creates a NumericId from some static counter.
- *
- * The only assertion is that \c 0 is not used as an Id,
- * \b unless the derived class explicitly requests this by
- * using \ref ProvideNumericId( const void *const ).
- *
- * Why should you want to use \c 0 as an Id? E.g if your class
- * provides some (singleton) No-object. Might be desirable to
- * make the No-object have No-Id.
- *
- * \code
- * struct Foo : public base::ProvideNumericId<Foo,unsigned>
- * {};
- * Foo foo;
- * foo.numericId(); // returns foo's NumericId.
- * \endcode
- */
- template<class TDerived, class TNumericIdType>
- struct ProvideNumericId
- {
- public:
- /** \return The objects numeric Id. */
- TNumericIdType numericId() const
- { return _numericId; }
-
- protected:
- /** Default ctor */
- ProvideNumericId()
- : _numericId( nextId() )
- {}
- /** Copy ctor */
- ProvideNumericId( const ProvideNumericId & /*rhs*/ )
- : _numericId( nextId() )
- {}
- /** Assign */
- ProvideNumericId & operator=( const ProvideNumericId & /*rhs*/ )
- { return *this; }
- /** Move ctor */
- ProvideNumericId( ProvideNumericId && rhs )
- : _numericId( rhs._numericId )
- { /*rhs._numericId = 0;*/ }
- /** Move Assign */
- ProvideNumericId & operator=( ProvideNumericId && rhs )
- { if ( &rhs != this ) { _numericId = rhs._numericId; /*rhs._numericId = 0;*/ } return *this; }
- /** Dtor */
- ~ProvideNumericId()
- {}
- protected:
- /** No-Id ctor (0).
- * Explicitly request Id \c 0. Use it with care!
- */
- ProvideNumericId( const void *const )
- : _numericId( 0 )
- {}
- private:
- /** Provide the next Id to use. */
- static TNumericIdType nextId()
- {
- static TNumericIdType _staticCounter = 0;
- // Assert not returning 0
- return ++_staticCounter;
- }
- /** */
- const TNumericIdType _numericId;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace base
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_PROVIDENUMERICID_H
+#include <zypp-core/base/ProvideNumericId>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/SimpleStreambuf.h
- *
-*/
-#ifndef ZYPP_BASE_SIMPLESTREAMBUF_H_DEFINED
-#define ZYPP_BASE_SIMPLESTREAMBUF_H_DEFINED
-
-#include <streambuf>
-#include <vector>
-
-namespace zypp {
- namespace detail {
-
- /*!
- * Implementation of a std::streambuf that is using a std::vector<char> as buffer,
- * relies on a Impl class that must implement the basic i/o functionality:
- *
- * \code
- * class streambufimpl {
- * public:
- * using error_type = my_error_type;
- *
- * ~streambufimpl();
- *
- * bool isOpen () const; // returns true if the file is currently open
- * bool canRead () const; // returns true if in read mode
- * bool canWrite () const; // returns true if in write mode
- * bool canSeek ( std::ios_base::seekdir way_r ) const; // returns true if the backend can seek in the given way
- *
- * std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r ); // reads data from the file and returns it in buffer_r
- * bool writeData( const char * buffer_r, std::streamsize count_r ); // writes data ( if in write mode ) to file from buffer
- * off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); // seeks in file if supported
- * off_t tell() const; // returns the current FP
- *
- * error_type error() const; // returns the last error that happend in backend
- *
- * protected:
- * bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); // backend implementation of opening the file
- * bool closeImpl (); // closes the file
- * };
- * using FullStreamBuf = detail::SimpleStreamBuf<streambufimpl>;
- * \endcode
- *
- * \note Currently only supports reading or writing at the same time, but can be extended to support both
- */
- template<typename Impl>
- class SimpleStreamBuf : public std::streambuf, public Impl
- {
-
- public:
-
- SimpleStreamBuf( size_t bufsize_r = 512) : _buffer( bufsize_r ) { }
- virtual ~SimpleStreamBuf() { close(); }
-
- SimpleStreamBuf * open( const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in ) {
-
- if ( !this->openImpl( name_r, mode_r ) )
- return nullptr;
-
- if ( this->canRead() ) {
- setp( NULL, NULL );
- setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
- } else {
- setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
- setg( NULL, NULL, NULL );
- }
-
- return this;
- }
-
- SimpleStreamBuf * close() {
-
- if ( !this->isOpen() )
- return nullptr;
-
- if ( this->canWrite() )
- sync();
-
- if ( !this->closeImpl() )
- return nullptr;
-
- return this;
- }
-
- protected:
-
- virtual int sync() {
- int ret = 0;
- if ( pbase() < pptr() ) {
- const int_type res = overflow();
- if ( traits_type::eq_int_type( res, traits_type::eof() ) )
- ret = -1;
- }
- return ret;
- }
-
- virtual int_type overflow( int_type c = traits_type::eof() ) {
- int_type ret = traits_type::eof();
- if ( this->canWrite() ) {
- if ( ! traits_type::eq_int_type( c, traits_type::eof() ) )
- {
- *pptr() = traits_type::to_char_type( c );
- pbump(1);
- }
- if ( pbase() <= pptr() )
- {
- if ( this->writeData( pbase(), pptr() - pbase() ) )
- {
- setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
- ret = traits_type::not_eof( c );
- }
- // else: error writing the file
- }
- }
- return ret;
- }
-
- virtual int_type underflow() {
- int_type ret = traits_type::eof();
- if ( this->canRead() )
- {
- if ( gptr() < egptr() )
- return traits_type::to_int_type( *gptr() );
-
- const std::streamsize got = this->readData( &(_buffer[0]), _buffer.size() );
- if ( got > 0 )
- {
- setg( &(_buffer[0]), &(_buffer[0]), &(_buffer.data()[got]) );
- ret = traits_type::to_int_type( *gptr() );
- }
- else if ( got == 0 )
- {
- // EOF
- setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
- }
- // else: error reading the file
- }
- return ret;
- }
-
- virtual pos_type seekpos( pos_type pos_r, std::ios_base::openmode openMode ) {
- return seekoff( off_type(pos_r), std::ios_base::beg, openMode );
- }
-
-
- virtual pos_type seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode openMode ) {
- pos_type ret = pos_type(off_type(-1));
- if ( !this->canSeek( way_r) )
- return ret;
-
- if ( this->isOpen() ) {
- if ( openMode == std::ios_base::out ) {
- //write the buffer out and invalidate it , no need to keep it around
- if ( !this->canWrite() || sync() != 0 )
- return ret;
-
- ret = this->seekTo( off_r, way_r, openMode );
-
- } else if ( openMode == std::ios_base::in ) {
- if ( !this->canRead() )
- return ret;
-
- //current physical FP, should point to end of buffer
- const off_type buffEndOff = this->tell();
-
- if ( buffEndOff != off_type(-1) ) {
- if ( way_r == std::ios_base::end ) {
- setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
- ret = this->seekTo( off_r, way_r, openMode );
- }
-
- const off_type bufLen = egptr() - eback();
- const off_type bufStartFileOff = buffEndOff - bufLen;
- const off_type currPtrFileOffset = buffEndOff - ( egptr() - gptr() );
- off_type newFOff = off_r;
-
- // Transform into ios_base::beg and seek.
- if ( way_r == std::ios_base::cur ) {
- newFOff += currPtrFileOffset;
- way_r = std::ios_base::beg;
- }
-
- //check if a seek would go out of the buffers boundaries
- if ( way_r == std::ios_base::beg ) {
- if ( bufStartFileOff <= newFOff && newFOff <= buffEndOff ) {
- // Still inside buffer, adjust gptr and
- // calculate new position.
- setg( eback(),
- eback() + ( newFOff - bufStartFileOff ),
- egptr() );
- ret = pos_type( newFOff );
- } else {
- // Invalidate buffer and seek.
- setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
- ret = this->seekTo( off_r, way_r, openMode );
- }
- }
- }
- }
- }
- return ret;
- }
-
- private:
- typedef std::vector<char> buffer_type;
- buffer_type _buffer;
- };
- }
-}
-#endif
+#include <zypp-core/base/SimpleStreambuf>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/Sysconfig.h
- *
-*/
-#ifndef ZYPP_BASE_SYSCONFIG_H
-#define ZYPP_BASE_SYSCONFIG_H
-
-#include <string>
-#include <map>
-#include <zypp/Pathname.h>
-
-namespace zypp {
- namespace base {
- namespace sysconfig {
-
- /** Read sysconfig file \a path_r and return <tt>(key,valye)</tt> pairs. */
- std::map<std::string,std::string> read( const Pathname & _path );
-
- /** Add or change a value in sysconfig file \a path_r.
- *
- * If \a key_r already exists, only the \a val_r is changed accordingly.
- *
- * In case \a key_r is not yet present in the file, a new entry may be created
- * at the end of the file, using the lines in \a newcomment_r as comment
- * block. If \a newcomment_r is not provided or empty, a new value is not
- * created and \c false is returned.
- *
- * \returns \c TRUE if an entry was changed or created.
- *
- * \throws Exception if \a path_r can not be read or written.
- *
- * \note \a val_r is written as it is. The caller is responsible for escaping and
- * enclosing in '"', in case this is needed (\see \ref writeStringVal and \ref str::escape).
- *
- * \note Lines in \a newcomment_r which do not already start with a '#',
- * are prefixes with "# ".
- *
- * \code
- * ## Type: string
- * ## Default: ""
- * #
- * # A multiline description of
- * # the options purpose.
- * #
- * KEY="value"
- * \endcode
- */
- bool write( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
- const std::string & newcomment_r = std::string() );
-
- /** Convenience to add or change a string-value in sysconfig file \a path_r.
- *
- * \a val_r is expected to be a plain string value, so it is propery escaped and enclosed in
- * double quotes before it is written to the sysconfig file \a path_r.
- *
- * \see \ref write
- */
- bool writeStringVal( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
- const std::string & newcomment_r = std::string() );
-
- } // namespace sysconfig
- } // namespace base
-} // namespace zypp
-
-#endif // ZYPP_BASE_SYSCONFIG_H
+#include <zypp-core/parser/Sysconfig>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/UserRequestException.h
- *
-*/
-#ifndef ZYPP_BASE_USERREQUESTEXCEPTION_H
-#define ZYPP_BASE_USERREQUESTEXCEPTION_H
-
-#include <iosfwd>
-
-#include <zypp/base/Exception.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : UserRequestException
- //
- /** Base for exceptions caused by explicit user request.
- *
- * Use the derived convenience classes to throw exceptions
- * of a certain kind.
- * \code
- * ProgressData ticks( makeProgressData( input_r ) );
- * ticks.sendTo( fnc_r );
- * ticks.toMin(); // start sending min (0)
- *
- * iostr::EachLine line( input_r );
- * for( ; line; line.next() )
- * {
- * // process the line
- *
- * if ( ! ticks.set( input_r.stream().tellg() ) )
- * ZYPP_THROW( AbortRequestException( "" ) );
- * }
- * \endcode
- * \code
- * // either this way
- * catch ( const AbortRequestException & excpt_r )
- * {
- * ...
- * }
- *
- * // or that
- * catch ( const UserRequestException & excpt_r )
- * {
- * switch ( excpt_r.kind() )
- * {
- * case UserRequestException::ABORT:
- * ...
- * break;
- * }
- * }
- * \endcode
- */
- class UserRequestException : public Exception
- {
- public:
- enum Kind { UNSPECIFIED, IGNORE, SKIP, RETRY, ABORT };
- public:
- explicit
- UserRequestException( const std::string & msg_r = std::string() );
- UserRequestException( const std::string & msg_r, const Exception & history_r );
- explicit
- UserRequestException( Kind kind_r, const std::string & msg_r = std::string() );
- UserRequestException( Kind kind_r, const std::string & msg_r, const Exception & history_r );
- public:
- Kind kind() const
- { return _kind; }
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- Kind _kind;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** Convenience macro to declare more specific PluginScriptExceptions. */
-#define declException( EXCP, KIND ) \
- struct EXCP : public UserRequestException { \
- explicit \
- EXCP( const std::string & msg_r = std::string() ) \
- : UserRequestException( KIND, msg_r ) \
- {} \
- EXCP( const std::string & msg_r, const Exception & history_r ) \
- : UserRequestException( KIND, msg_r, history_r ) \
- {} \
- }
-
- declException( IgnoreRequestException, IGNORE );
- declException( SkipRequestException, SKIP );
- declException( RetryRequestException, RETRY );
- declException( AbortRequestException, ABORT );
-
-#undef declException
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_USERREQUESTEXCEPTION_H
+#include <zypp-core/base/UserRequestException>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/WatchFile.h
- *
-*/
-#ifndef ZYPP_BASE_WATCHFILE_H
-#define ZYPP_BASE_WATCHFILE_H
-
-#include <iosfwd>
-
-#include <zypp/PathInfo.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : WatchFile
- //
- /** Remember a files attributes to detect content changes.
- *
- * Repeatedly call \ref hasChanged to check whether the content has
- * changed since the last call. Creation or deletion of the file will
- * be reported as change as well.
- *
- * Per default the ctor stats the file, so \ref hasChanged will detect
- * changes done after \ref WatchFile was created.
- *
- * You may omit the initial stat by passing \c NO_INIT as second argument
- * to the ctor. \ref WatchFile will behave as if the file did not exist
- * at the time \ref WatchFile was created.
- *
- * \code
- * static WatchFile sysconfigFile( "/etc/sysconfig/SuSEfirewall2",
- * WatchFile::NO_INIT );
- * if ( sysconfigFile.hasChanged() )
- * {
- * // reload the file...
- * }
- * \endcode
- */
- class WatchFile
- {
- public:
- enum Initial { NO_INIT, INIT };
-
- public:
- /** */
- WatchFile( const Pathname & path_r = Pathname(),
- Initial mode = INIT )
- : _path( path_r )
- {
- PathInfo pi( mode == INIT ? path_r : Pathname() );
- _size = pi.size();
- _mtime = pi.mtime();
- }
-
- const Pathname & path() const
- { return _path; }
-
- off_t lastSize() const
- { return _size;}
-
- time_t lastMtime() const
- { return _mtime; }
-
- bool isDirty() const
- {
- PathInfo pi( _path );
- return( _size != pi.size() || _mtime != pi.mtime() );
- }
-
- bool hasChanged()
- {
- PathInfo pi( _path );
- if ( _size != pi.size() || _mtime != pi.mtime() )
- {
- _size = pi.size();
- _mtime = pi.mtime();
- return true;
- }
- return false;
- }
-
- private:
- Pathname _path;
- off_t _size;
- time_t _mtime;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_WATCHFILE_H
+#include <zypp-core/fs/WatchFile>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-#ifndef ZYPP_BASE_ZCKSTREAM_H
-#define ZYPP_BASE_ZCKSTREAM_H
-
-#include <iosfwd>
-#include <streambuf>
-#include <vector>
-#include <zypp/base/SimpleStreambuf.h>
-#include <zypp/base/fXstream.h>
-
-typedef struct zckCtx zckCtx;
-
-namespace zypp {
-
- namespace detail {
-
- /**
- * @short Streambuffer reading or writing zchunk files.
- *
- * Read and write mode are mutual exclusive. Seek is not supported.
- *
- * This streambuf is used in @ref ifzckstream and @ref ofzckstream.
- **/
- class zckstreambufimpl {
- public:
-
- using error_type = std::string;
-
- ~zckstreambufimpl();
-
- bool isOpen () const;
- bool canRead () const;
- bool canWrite () const;
- bool canSeek ( std::ios_base::seekdir way_r ) const;
-
- std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r );
- bool writeData( const char * buffer_r, std::streamsize count_r );
- off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
- off_t tell() const;
-
- error_type error() const { return _lastErr; }
-
- protected:
- bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
- bool closeImpl ();
-
- private:
- void setError ();
- int _fd = -1;
- bool _isReading = false;
- zckCtx *_zContext = nullptr;
- off_t _currfp = 0;
- error_type _lastErr;
-
- };
- using ZChunkStreamBuf = detail::SimpleStreamBuf<detail::zckstreambufimpl>;
- }
-
- /**
- * istream reading zchunk files.
- **/
- using ifzckstream = detail::fXstream<std::istream,detail::ZChunkStreamBuf>;
-
- /**
- * ostream writing zchunk files.
- **/
- using ofzckstream = detail::fXstream<std::ostream,detail::ZChunkStreamBuf>;
-}
-
-#endif
+#include <zypp-core/base/ZckStream>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-#ifndef ZYPP_BASE_FXSTREAM_H
-#define ZYPP_BASE_FXSTREAM_H
-
-#include <iosfwd>
-#include <iostream>
-
-namespace zypp {
- namespace detail {
- /**
- * @short Common template to define ifgzstream/ofgzstream
- * reading/writing compressed files.
- *
- * Don't use fXstream directly, but @ref ifgzstream or
- * @ref ofgzstream. fXstream is just to avoid almost
- * duplicate code.
- **/
- template<class TBStream,class TStreamBuf>
- class fXstream : public TBStream
- {
- public:
-
- using ZlibError = typename TStreamBuf::error_type;
- using stream_type = TBStream;
- using streambuf_type = TStreamBuf;
-
- fXstream()
- : stream_type( nullptr )
- { this->init( &_streambuf ); }
-
- explicit
- fXstream( const char * file_r )
- : stream_type( nullptr )
- { this->init( &_streambuf ); this->open( file_r ); }
-
- virtual
- ~fXstream()
- {}
-
- bool
- is_open() const
- { return _streambuf.isOpen(); }
-
- void
- open( const char * file_r )
- {
- if ( !_streambuf.open( file_r, defMode(*this) ) )
- this->setstate(std::ios_base::failbit);
- else
- this->clear();
- }
-
- void
- close()
- {
- if ( !_streambuf.close() )
- this->setstate(std::ios_base::failbit);
- }
-
- /**
- * The last error returned retuned from zlib.
- **/
- ZlibError
- zError() const
- { return _streambuf.error(); }
-
- //! Similar to ios::rdbuf.
- //! But it returns our specific type, not the generic streambuf *.
- const streambuf_type&
- getbuf() const
- { return _streambuf; }
-
- private:
-
- streambuf_type _streambuf;
-
- std::ios_base::openmode
- defMode( const std::istream & )
- { return std::ios_base::in; }
-
- std::ios_base::openmode
- defMode( const std::ostream & )
- { return std::ios_base::out; }
-
- };
- }
-}
-
-#endif
+#include <zypp-core/base/fxstream.h>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialFileReader.h
- *
- */
-#ifndef ZYPP_MEDIA_CREDENTIALFILEREADER_H
-#define ZYPP_MEDIA_CREDENTIALFILEREADER_H
-
-#include <zypp/base/Function.h>
-#include <zypp/Url.h>
-#include <zypp/Pathname.h>
-
-#include <zypp/media/MediaUserAuth.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
- ///////////////////////////////////////////////////////////////////
- namespace media
- {
- //////////////////////////////////////////////////////////////////////
- /// \class CredentialFileReader
- /// \brief Parse credentials files and catalogs
- class CredentialFileReader
- {
- public:
- /** Callback invoked for each entry found in the file.
- * Return \c false to abort parsing.
- */
- typedef function<bool(AuthData_Ptr &)> ProcessCredentials;
-
- CredentialFileReader( const Pathname & crfile_r, const ProcessCredentials & callback_r );
- ~CredentialFileReader();
- private:
- ProcessCredentials _callback;
- };
- //////////////////////////////////////////////////////////////////////
-
- } // namespace media
- ///////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-#endif /* ZYPP_MEDIA_CREDENTIALFILEREADER_H */
+#include <zypp-media/auth/CredentialFileReader>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialManager.h
- *
- */
-#ifndef ZYPP_MEDIA_CREDENTIALMANAGER_H
-#define ZYPP_MEDIA_CREDENTIALMANAGER_H
-
-#include <set>
-
-#include <zypp/Pathname.h>
-#include <zypp/media/MediaUserAuth.h>
-
-//////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ////////////////////////////////////////////////////////////////////
-
- class Url;
-
- //////////////////////////////////////////////////////////////////////
- namespace media
- { ////////////////////////////////////////////////////////////////////
-
-
- //////////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CredManagerOptions
- //
- /**
- * \todo configurable cred file locations
- */
- struct CredManagerOptions
- {
- CredManagerOptions(const Pathname & rootdir = "");
-
- Pathname globalCredFilePath;
- Pathname userCredFilePath;
- Pathname customCredFileDir;
- };
- //////////////////////////////////////////////////////////////////////
-
- // comparator for CredentialSet
- struct AuthDataComparator
- {
- bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs) const;
- };
-
- //////////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CredentialManager
- //
- /**
- * \todo better method names
- * \todo delete(AuthData) method
- */
- class CredentialManager
- {
- public:
- typedef std::set<AuthData_Ptr, AuthDataComparator> CredentialSet;
- typedef CredentialSet::size_type CredentialSize;
- typedef CredentialSet::const_iterator CredentialIterator;
-
-
- CredentialManager(const CredManagerOptions & opts = CredManagerOptions());
-
- ~CredentialManager()
- {}
-
- public:
- /**
- * Get credentials for the specified \a url.
- *
- * If the URL contains also username, it will be used to find the match
- * for this user (in case mutliple are available).
- *
- * \param url URL to find credentials for.
- * \return Pointer to retrieved authentication data on success or an empty
- * AuthData_Ptr otherwise.
- * \todo return a copy instead?
- */
- AuthData_Ptr getCred(const Url & url);
-
- /**
- * Read credentials from a file.
- */
- AuthData_Ptr getCredFromFile(const Pathname & file);
-
- /**
- * Add new global credentials.
- */
- void addGlobalCred(const AuthData & cred);
-
- /**
- * Add new user credentials.
- */
- void addUserCred(const AuthData & cred);
-
- /**
- * Add new credentials with user callbacks.
- *
- * If the cred->url() contains 'credentials' query parameter, the
- * credentials will be automatically saved to the specified file using the
- * \ref saveInFile() method.
- *
- * Otherwise a callback will be called asking whether to save to custom
- * file, or to global or user's credentials catalog.
- *
- * \todo Currently no callback is called, credentials are automatically
- * saved to user's credentials.cat if no 'credentials' parameter
- * has been specified
- */
- void addCred(const AuthData & cred);
-
- /**
- * Saves any unsaved credentials added via \ref addUserCred() or
- * \a addGlobalCred() methods.
- */
- void save();
-
- /**
- * Saves given \a cred to global credentials file.
- *
- * \note Use this method to add just one piece of credentials. To add
- * multiple items at once, use addGlobalCred() followed
- * by save()
- */
- void saveInGlobal(const AuthData & cred);
-
- /**
- * Saves given \a cred to user's credentials file.
- *
- * \note Use this method to add just one piece of credentials. To add
- * multiple items at once, use addUserCred() followed
- * by save()
- */
- void saveInUser(const AuthData & cred);
-
- /**
- * Saves given \a cred to user specified credentials file.
- *
- * If the credFile path is absolute, it will be saved at that precise
- * location. If \a credFile is just a filename, it will be saved
- * in \ref CredManagerOptions::customCredFileDir. Otherwise the current
- * working directory will be prepended to the file path.
- */
- void saveInFile(const AuthData &, const Pathname & credFile);
-
- /**
- * Remove all global or user credentials from memory and disk.
- *
- * \param global Whether to remove global or user credentials.
- */
- void clearAll(bool global = false);
-
-
- CredentialIterator credsGlobalBegin() const;
- CredentialIterator credsGlobalEnd() const;
- CredentialSize credsGlobalSize() const;
- bool credsGlobalEmpty() const;
-
- CredentialIterator credsUserBegin() const;
- CredentialIterator credsUserEnd() const;
- CredentialSize credsUserSize() const;
- bool credsUserEmpty() const;
-
- struct Impl;
- private:
- RW_pointer<Impl> _pimpl;
- };
- //////////////////////////////////////////////////////////////////////
-
-
- ////////////////////////////////////////////////////////////////////
- } // media
- //////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-} // zypp
-//////////////////////////////////////////////////////////////////////
-
-#endif /* ZYPP_MEDIA_CREDENTIALMANAGER_H */
-
+#include <zypp-media/auth/CredentialManager>
-#ifndef ZYPP_MEDIA_CURLRCONFIG_H_
-#define ZYPP_MEDIA_CURLRCONFIG_H_
-
-//#include <zypp/base/NonCopyable.h>
-#include <zypp/base/String.h>
-
-namespace zypp
-{
- namespace media
- {
-
-
- /**
- * Structure holding values of curlrc options.
- */
- struct CurlConfig
- {
- public:
- /**
- * Parse a curlrc file and store the result in the \a config structure.
- *
- * \param config a CurlConfig structure
- * \param filename path to the curlrc file. If empty, ~/.curlrc is used.
- * \return 0 on success, 1 if problem occurs.
- */
- static int parseConfig(CurlConfig & config, const std::string & filename = "");
-
- /**
- * Stores the \a value of the \a option in the \a config structure or
- * logs an unknown option.
- *
- * \return 0 on success, 1 if problem occurs.
- */
- static int setParameter(CurlConfig & config,
- const std::string & option,
- const std::string & value);
-
- public:
- std::string proxyuserpwd;
- // add more curl config data here as they become needed
- };
-
-
- } // namespace media
-} // namespace zypp
-
-#endif /*ZYPP_MEDIA_CURLRCONFIG_H_*/
+#include <zypp-curl/CurlConfig>
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-----------------------------------------------------------------------/
-*
-* This file contains private API, this might break at any time between releases.
-* You have been warned!
-*
-*/
-#ifndef ZYPP_MEDIA_CURLHELPER_H_INCLUDED
-#define ZYPP_MEDIA_CURLHELPER_H_INCLUDED
-
-#include <curl/curl.h>
-#include <zypp/Url.h>
-#include <zypp/media/TransferSettings.h>
-#include <zypp/ZYppCallbacks.h>
-
-#define CONNECT_TIMEOUT 60
-#define TRANSFER_TIMEOUT_MAX 60 * 60
-#define DETECT_DIR_INDEX 0
-
-#define EXPLICITLY_NO_PROXY "_none_"
-
-#undef CURLVERSION_AT_LEAST
-#define CURLVERSION_AT_LEAST(M,N,O) LIBCURL_VERSION_NUM >= ((((M)<<8)+(N))<<8)+(O)
-
-namespace zypp
-{
- namespace env
- {
- /** Long number for setting CURLOPT_DEBUGDATA */
- inline long ZYPP_MEDIA_CURL_DEBUG()
- {
- long ret = 0L;
- if ( char *ptr = ::getenv("ZYPP_MEDIA_CURL_DEBUG"); ptr && *ptr )
- str::strtonum( ptr, ret );
- return ret;
- }
-
- /** 4/6 to force IPv4/v6 */
- int ZYPP_MEDIA_CURL_IPRESOLVE();
- } // namespace env
-} //namespace zypp
-
-//do not export
-namespace internal {
-
-struct ProgressData
-{
- ProgressData( CURL *_curl, time_t _timeout = 0, const zypp::Url & _url = zypp::Url(),
- zypp::ByteCount expectedFileSize_r = 0,
- zypp::callback::SendReport<zypp::media::DownloadProgressReport> *_report = nullptr );
-
- CURL *curl;
- zypp::Url url;
- time_t timeout;
- bool reached;
- bool fileSizeExceeded;
- zypp::callback::SendReport<zypp::media::DownloadProgressReport> *report;
- zypp::ByteCount _expectedFileSize;
-
- time_t _timeStart = 0; ///< Start total stats
- time_t _timeLast = 0; ///< Start last period(~1sec)
- time_t _timeRcv = 0; ///< Start of no-data timeout
- time_t _timeNow = 0; ///< Now
-
- double _dnlTotal = 0.0; ///< Bytes to download or 0 if unknown
- double _dnlLast = 0.0; ///< Bytes downloaded at period start
- double _dnlNow = 0.0; ///< Bytes downloaded now
-
- int _dnlPercent= 0; ///< Percent completed or 0 if _dnlTotal is unknown
-
- double _drateTotal= 0.0; ///< Download rate so far
- double _drateLast = 0.0; ///< Download rate in last period
-
- void updateStats( double dltotal = 0.0, double dlnow = 0.0 );
-
- int reportProgress() const;
-
-
- // download rate of the last period (cca 1 sec)
- double drate_period;
- // bytes downloaded at the start of the last period
- double dload_period;
- // seconds from the start of the download
- long secs;
- // average download rate
- double drate_avg;
- // last time the progress was reported
- time_t ltime;
- // bytes downloaded at the moment the progress was last reported
- double dload;
- // bytes uploaded at the moment the progress was last reported
- double uload;
-};
-
-void globalInitCurlOnce();
-int log_curl(CURL *curl, curl_infotype info, char *ptr, size_t len, void *max_lvl);
-size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata);
-
-
-void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
-void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
-
-/**
- * initialized only once, this gets the anonymous id
- * from the target, which we pass in the http header
- */
-const char * anonymousIdHeader();
-
-/**
- * initialized only once, this gets the distribution flavor
- * from the target, which we pass in the http header
- */
-const char * distributionFlavorHeader();
-
-/**
- * initialized only once, this gets the agent string
- * which also includes the curl version
- */
-const char * agentString();
-
-void curlEscape( std::string & str_r, const char char_r, const std::string & escaped_r );
-std::string curlEscapedPath( std::string path_r );
-std::string curlUnEscape( std::string text_r );
-
-zypp::Url clearQueryString(const zypp::Url &url);
-zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
-
-}
-
-
-
-
-#endif
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaBlockList.h
- *
-*/
-#ifndef ZYPP_MEDIA_MEDIABLOCKLIST_H
-#define ZYPP_MEDIA_MEDIABLOCKLIST_H
-
-#include <sys/types.h>
-#include <vector>
-#include <optional>
-
-#include <zypp/Digest.h>
-
-namespace zypp {
- namespace media {
-
-/**
- * a single block from the blocklist, consisting of an offset and a size
- **/
-struct MediaBlock {
- MediaBlock( off_t off_r, size_t size_r )
- : off( off_r )
- , size( size_r )
- {}
- off_t off;
- size_t size;
-};
-
-class MediaBlockList {
-public:
- MediaBlockList(off_t filesize=off_t(-1));
-
- /**
- * do we have a blocklist describing the file?
- * set to true when addBlock() is called
- **/
- inline bool haveBlocks() const {
- return haveblocks;
- }
- /**
- * add a block with offset off and size size to the block list. Note
- * that blocks must be ordered and must not overlap. returns the
- * block number.
- **/
- size_t addBlock(off_t off, size_t size);
-
- /**
- * return the offset/size of a block with number blkno
- **/
- inline MediaBlock getBlock(size_t blkno) const {
- return blocks[blkno];
- }
- /**
- * return the number of blocks in the blocklist
- **/
- inline size_t numBlocks() const {
- return blocks.size();
- }
-
- /**
- * set / return the size of the whole file
- **/
- inline void setFilesize(off_t newfilesize=off_t(-1)) {
- filesize = newfilesize;
- }
- inline off_t getFilesize() const {
- return filesize;
- }
- inline bool haveFilesize() const {
- return filesize != off_t(-1);
- }
-
- /**
- * set / verify the checksum over the whole file
- **/
- void setFileChecksum(std::string ctype, int cl, unsigned char *c);
- std::string fileChecksumType () const;
-
- const UByteArray &getFileChecksum( );
- bool createFileDigest(Digest &digest) const;
- bool verifyFileDigest(Digest &digest) const;
- inline bool haveFileChecksum() const {
- return !fsumtype.empty() && fsum.size();
- }
-
- /**
- * set / verify the (strong) checksum over a single block
- **/
- void setChecksum(size_t blkno, std::string cstype, int csl, unsigned char *cs, size_t cspad=0);
- bool checkChecksum(size_t blkno, const unsigned char *buf, size_t bufl) const;
- UByteArray getChecksum( size_t blkno ) const;
- std::string getChecksumType( ) const;
- bool createDigest(Digest &digest) const;
- bool verifyDigest(size_t blkno, Digest &digest) const;
- inline bool haveChecksum(size_t blkno) const {
- return chksumlen && chksums.size() >= chksumlen * (blkno + 1);
- }
-
- /**
- * set / verify the (weak) rolling checksum over a single block
- **/
- void setRsum(size_t blkno, int rsl, unsigned int rs, size_t rspad=0);
- bool checkRsum(size_t blkno, const unsigned char *buf, size_t bufl) const;
- unsigned int updateRsum(unsigned int rs, const char *bytes, size_t len) const;
- bool verifyRsum(size_t blkno, unsigned int rs) const;
- inline bool haveRsum(size_t blkno) const {
- return rsumlen && rsums.size() >= blkno + 1;
- }
-
- /**
- * scan a file for blocks from our blocklist. if we find a suitable block,
- * it is removed from the list
- **/
- void reuseBlocks(FILE *wfp, std::string filename);
-
- /**
- * return block list as string
- **/
- std::string asString() const;
-
-private:
- void writeBlock(size_t blkno, FILE *fp, const unsigned char *buf, size_t bufl, size_t start, std::vector<bool> &found) const;
- bool checkChecksumRotated(size_t blkno, const unsigned char *buf, size_t bufl, size_t start) const;
-
- off_t filesize;
- std::string fsumtype;
- UByteArray fsum;
-
- bool haveblocks;
- std::vector<MediaBlock> blocks;
-
- std::string chksumtype;
- int chksumlen;
- size_t chksumpad;
- std::vector<unsigned char> chksums;
-
- std::string rsumtype;
- int rsumlen;
- size_t rsumpad;
- std::vector<unsigned int> rsums;
-};
-
-inline std::ostream & operator<<(std::ostream &str, const MediaBlockList &bl)
-{ return str << bl.asString(); }
-
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_MEDIABLOCKLIST_H
-
+#include <zypp-curl/parser/MediaBlockList>
#include <zypp/base/Logger.h>
#include <zypp/ExternalProgram.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
#include <zypp/media/MediaCD.h>
#include <zypp/media/MediaManager.h>
#include <zypp/Url.h>
#include <zypp/base/Logger.h>
#include <zypp/base/Gettext.h>
#include <zypp/TmpPath.h>
-#include <zypp/KVMap.h>
-#include <zypp/media/Mount.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-core/KVMap>
+#include <zypp-media/Mount>
+#include <zypp-media/auth/AuthData>
+#include <zypp-media/auth/CredentialManager>
#include <zypp/ZYppCallbacks.h>
#include <zypp/ZConfig.h>
#include <zypp/ExternalProgram.h>
#include <zypp/base/String.h>
#include <zypp/base/Gettext.h>
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/parser/Sysconfig>
#include <zypp/base/Gettext.h>
#include <zypp/media/MediaCurl.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/media/CurlConfig.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/auth/CurlAuthData>
+#include <zypp-media/auth/CredentialManager>
+#include <zypp-curl/CurlConfig>
+#include <zypp-curl/private/curlhelper_p.h>
#include <zypp/Target.h>
#include <zypp/ZYppFactory.h>
#include <zypp/ZConfig.h>
using std::endl;
+namespace internal {
+ using namespace zypp;
+ struct ProgressData
+ {
+ ProgressData( CURL *_curl, time_t _timeout = 0, const zypp::Url & _url = zypp::Url(),
+ zypp::ByteCount expectedFileSize_r = 0,
+ zypp::callback::SendReport<zypp::media::DownloadProgressReport> *_report = nullptr );
+
+ CURL *curl;
+ zypp::Url url;
+ time_t timeout;
+ bool reached;
+ bool fileSizeExceeded;
+ zypp::callback::SendReport<zypp::media::DownloadProgressReport> *report;
+ zypp::ByteCount _expectedFileSize;
+
+ time_t _timeStart = 0; ///< Start total stats
+ time_t _timeLast = 0; ///< Start last period(~1sec)
+ time_t _timeRcv = 0; ///< Start of no-data timeout
+ time_t _timeNow = 0; ///< Now
+
+ double _dnlTotal = 0.0; ///< Bytes to download or 0 if unknown
+ double _dnlLast = 0.0; ///< Bytes downloaded at period start
+ double _dnlNow = 0.0; ///< Bytes downloaded now
+
+ int _dnlPercent= 0; ///< Percent completed or 0 if _dnlTotal is unknown
+
+ double _drateTotal= 0.0; ///< Download rate so far
+ double _drateLast = 0.0; ///< Download rate in last period
+
+ void updateStats( double dltotal = 0.0, double dlnow = 0.0 );
+
+ int reportProgress() const;
+
+
+ // download rate of the last period (cca 1 sec)
+ double drate_period;
+ // bytes downloaded at the start of the last period
+ double dload_period;
+ // seconds from the start of the download
+ long secs;
+ // average download rate
+ double drate_avg;
+ // last time the progress was reported
+ time_t ltime;
+ // bytes downloaded at the moment the progress was last reported
+ double dload;
+ // bytes uploaded at the moment the progress was last reported
+ double uload;
+ };
+
+
+
+ ProgressData::ProgressData(CURL *_curl, time_t _timeout, const Url &_url, ByteCount expectedFileSize_r, zypp::callback::SendReport< zypp::media::DownloadProgressReport> *_report)
+ : curl( _curl )
+ , url( _url )
+ , timeout( _timeout )
+ , reached( false )
+ , fileSizeExceeded ( false )
+ , report( _report )
+ , _expectedFileSize( expectedFileSize_r )
+ {}
+
+ void ProgressData::updateStats(double dltotal, double dlnow)
+ {
+ time_t now = _timeNow = time(0);
+
+ // If called without args (0.0), recompute based on the last values seen
+ if ( dltotal && dltotal != _dnlTotal )
+ _dnlTotal = dltotal;
+
+ if ( dlnow && dlnow != _dnlNow )
+ {
+ _timeRcv = now;
+ _dnlNow = dlnow;
+ }
+ else if ( !_dnlNow && !_dnlTotal )
+ {
+ // Start time counting as soon as first data arrives.
+ // Skip the connection / redirection time at begin.
+ return;
+ }
+
+ // init or reset if time jumps back
+ if ( !_timeStart || _timeStart > now )
+ _timeStart = _timeLast = _timeRcv = now;
+
+ // timeout condition
+ if ( timeout )
+ reached = ( (now - _timeRcv) > timeout );
+
+ // check if the downloaded data is already bigger than what we expected
+ fileSizeExceeded = _expectedFileSize > 0 && _expectedFileSize < static_cast<ByteCount::SizeType>(_dnlNow);
+
+ // percentage:
+ if ( _dnlTotal )
+ _dnlPercent = int(_dnlNow * 100 / _dnlTotal);
+
+ // download rates:
+ _drateTotal = _dnlNow / std::max( int(now - _timeStart), 1 );
+
+ if ( _timeLast < now )
+ {
+ _drateLast = (_dnlNow - _dnlLast) / int(now - _timeLast);
+ // start new period
+ _timeLast = now;
+ _dnlLast = _dnlNow;
+ }
+ else if ( _timeStart == _timeLast )
+ _drateLast = _drateTotal;
+ }
+
+ int ProgressData::reportProgress() const
+ {
+ if ( fileSizeExceeded )
+ return 1;
+ if ( reached )
+ return 1; // no-data timeout
+ if ( report && !(*report)->progress( _dnlPercent, url, _drateTotal, _drateLast ) )
+ return 1; // user requested abort
+ return 0;
+ }
+
+ const char * anonymousIdHeader()
+ {
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is guessed.
+ static const std::string _value(
+ str::trim( str::form(
+ "X-ZYpp-AnonymousId: %s",
+ Target::anonymousUniqueId( Pathname()/*guess root*/ ).c_str() ) )
+ );
+ return _value.c_str();
+ }
+
+ const char * distributionFlavorHeader()
+ {
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is guessed.
+ static const std::string _value(
+ str::trim( str::form(
+ "X-ZYpp-DistributionFlavor: %s",
+ Target::distributionFlavor( Pathname()/*guess root*/ ).c_str() ) )
+ );
+ return _value.c_str();
+ }
+
+ const char * agentString()
+ {
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is guessed.
+ static const std::string _value(
+ str::form(
+ "ZYpp " LIBZYPP_VERSION_STRING " (curl %s) %s"
+ , curl_version_info(CURLVERSION_NOW)->version
+ , Target::targetDistribution( Pathname()/*guess root*/ ).c_str()
+ )
+ );
+ return _value.c_str();
+ }
+}
+
+
using namespace internal;
using namespace zypp::base;
}
else
{
- WAR << "Could not get the reponse code." << endl;
+ WAR << "Could not get the response code." << endl;
}
if (modified || infoRet != CURLE_OK)
#include <zypp/media/MediaNetworkCommonHandler.h>
#include <curl/curl.h>
+
namespace zypp {
namespace media {
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
#include <zypp/media/MediaDISK.h>
#include <zypp/media/MediaManager.h>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaException.h
- *
-*/
-#ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
-#define ZYPP_MEDIA_MEDIAEXCEPTION_H
-
-#include <iosfwd>
-
-#include <string>
-#include <vector>
-
-#include <zypp/base/Exception.h>
-#include <zypp/Pathname.h>
-#include <zypp/Url.h>
-#include <zypp/ByteCount.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- namespace media {
- ///////////////////////////////////////////////////////////////
- //
- // CLASS NAME : MediaException
- /** Just inherits Exception to separate media exceptions
- *
- **/
- class MediaException : public Exception
- {
- public:
- /** Ctor taking message.
- * Use \ref ZYPP_THROW to throw exceptions.
- */
- MediaException() : Exception( "Media Exception" )
- {}
- /** Ctor taking message.
- * Use \ref ZYPP_THROW to throw exceptions.
- */
- MediaException( const std::string & msg_r )
- : Exception( msg_r )
- {}
-
- /** Dtor. */
- virtual ~MediaException() noexcept override;
- };
-
- class MediaMountException : public MediaException
- {
- public:
- MediaMountException()
- : MediaException( "Media Mount Exception" )
- {}
-
- /** Ctor taking message.
- * Use \ref ZYPP_THROW to throw exceptions.
- */
- MediaMountException( const std::string & error_r,
- const std::string & source_r,
- const std::string & target_r,
- const std::string & cmdout_r="")
- : MediaException()
- , _error(error_r)
- , _source(source_r)
- , _target(target_r)
- , _cmdout(cmdout_r)
- {}
- /** Dtor. */
- virtual ~MediaMountException() noexcept {}
-
- const std::string & mountError() const
- { return _error; }
- const std::string & mountSource() const
- { return _source; }
- const std::string & mountTarget() const
- { return _target; }
- const std::string & mountOutput() const
- { return _cmdout; }
-
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _error;
- std::string _source;
- std::string _target;
- std::string _cmdout;
- };
-
- class MediaUnmountException : public MediaException
- {
- public:
- /** Ctor taking message.
- * Use \ref ZYPP_THROW to throw exceptions.
- */
- MediaUnmountException( const std::string & error_r,
- const std::string & path_r )
- : MediaException()
- , _error(error_r)
- , _path(path_r)
- {}
- /** Dtor. */
- virtual ~MediaUnmountException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _error;
- std::string _path;
- };
-
- class MediaBadFilenameException : public MediaException
- {
- public:
- MediaBadFilenameException(const std::string & filename_r)
- : MediaException()
- , _filename(filename_r)
- {}
- virtual ~MediaBadFilenameException() noexcept {}
- std::string filename() const { return _filename; }
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _filename;
- };
-
- class MediaNotOpenException : public MediaException
- {
- public:
- MediaNotOpenException(const std::string & action_r)
- : MediaException()
- , _action(action_r)
- {}
- virtual ~MediaNotOpenException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _action;
- };
-
- class MediaFileNotFoundException : public MediaException
- {
- public:
- MediaFileNotFoundException(const Url & url_r,
- const Pathname & filename_r)
- : MediaException()
- , _url(url_r.asString())
- , _filename(filename_r.asString())
- {}
- virtual ~MediaFileNotFoundException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- std::string _filename;
- };
-
- class MediaWriteException : public MediaException
- {
- public:
- MediaWriteException(const Pathname & filename_r)
- : MediaException()
- , _filename(filename_r.asString())
- {}
- virtual ~MediaWriteException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _filename;
- };
-
- class MediaNotAttachedException : public MediaException
- {
- public:
- MediaNotAttachedException(const Url & url_r)
- : MediaException()
- , _url(url_r.asString())
- {}
- virtual ~MediaNotAttachedException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- };
-
- class MediaBadAttachPointException : public MediaException
- {
- public:
- MediaBadAttachPointException(const Url & url_r)
- : MediaException()
- , _url(url_r.asString())
- {}
- virtual ~MediaBadAttachPointException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- };
-
- class MediaCurlInitException : public MediaException
- {
- public:
- MediaCurlInitException(const Url & url_r)
- : MediaException()
- , _url(url_r.asString())
- {}
- virtual ~MediaCurlInitException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- };
-
- class MediaSystemException : public MediaException
- {
- public:
- MediaSystemException(const Url & url_r,
- const std::string & message_r)
- : MediaException()
- , _url(url_r.asString())
- , _message(message_r)
- {}
- virtual ~MediaSystemException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- std::string _message;
- };
-
- class MediaNotAFileException : public MediaException
- {
- public:
- MediaNotAFileException(const Url & url_r,
- const Pathname & path_r)
- : MediaException()
- , _url(url_r.asString())
- , _path(path_r.asString())
- {}
- virtual ~MediaNotAFileException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- std::string _path;
- };
-
- class MediaNotADirException : public MediaException
- {
- public:
- MediaNotADirException(const Url & url_r,
- const Pathname & path_r)
- : MediaException()
- , _url(url_r.asString())
- , _path(path_r.asString())
- {}
- virtual ~MediaNotADirException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- std::string _path;
- };
-
- class MediaBadUrlException : public MediaException
- {
- public:
- MediaBadUrlException(const Url & url_r,
- const std::string &msg_r = std::string())
- : MediaException()
- , _url(url_r.asString())
- , _msg(msg_r)
- {}
- virtual ~MediaBadUrlException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- };
-
- class MediaBadUrlEmptyHostException : public MediaBadUrlException
- {
- public:
- MediaBadUrlEmptyHostException(const Url & url_r)
- : MediaBadUrlException(url_r)
- {}
- virtual ~MediaBadUrlEmptyHostException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
-
- class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
- {
- public:
- MediaBadUrlEmptyFilesystemException(const Url & url_r)
- : MediaBadUrlException(url_r)
- {}
- virtual ~MediaBadUrlEmptyFilesystemException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
-
- class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
- {
- public:
- MediaBadUrlEmptyDestinationException(const Url & url_r)
- : MediaBadUrlException(url_r)
- {}
- virtual ~MediaBadUrlEmptyDestinationException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
-
- class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
- {
- public:
- MediaUnsupportedUrlSchemeException(const Url & url_r)
- : MediaBadUrlException(url_r)
- {}
- virtual ~MediaUnsupportedUrlSchemeException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
-
- class MediaNotSupportedException : public MediaException
- {
- public:
- MediaNotSupportedException(const Url & url_r)
- : MediaException()
- , _url(url_r.asString())
- {}
- virtual ~MediaNotSupportedException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- };
-
- class MediaCurlException : public MediaException
- {
- public:
- MediaCurlException(const Url & url_r,
- const std::string & err_r,
- const std::string & msg_r)
- : MediaException()
- , _url(url_r.asString())
- , _err(err_r)
- , _msg(msg_r)
- {}
- virtual ~MediaCurlException() noexcept {}
- std::string errstr() const { return _err; }
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _err;
- std::string _msg;
- };
-
- class MediaCurlSetOptException : public MediaException
- {
- public:
- MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
- : MediaException()
- , _url(url_r.asString())
- , _msg(msg_r)
- {}
- virtual ~MediaCurlSetOptException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- };
-
- class MediaNotDesiredException : public MediaException
- {
- public:
- MediaNotDesiredException(const Url & url_r)
- : MediaException()
- , _url(url_r.asString())
- {}
- virtual ~MediaNotDesiredException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _url;
- };
-
- class MediaIsSharedException : public MediaException
- {
- public:
- /**
- * \param name A media source as string (see MediaSource class).
- */
- MediaIsSharedException(const std::string &name)
- : MediaException()
- , _name(name)
- {}
- virtual ~MediaIsSharedException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _name;
- };
-
- class MediaNotEjectedException: public MediaException
- {
- public:
- MediaNotEjectedException()
- : MediaException("Can't eject any media")
- , _name("")
- {}
-
- MediaNotEjectedException(const std::string &name)
- : MediaException("Can't eject media")
- , _name(name)
- {}
- virtual ~MediaNotEjectedException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- std::string _name;
- };
-
- class MediaUnauthorizedException: public MediaException
- {
- public:
- MediaUnauthorizedException()
- : MediaException("Unauthorized media access")
- , _url("")
- , _err("")
- , _hint("")
- {}
-
- MediaUnauthorizedException(const Url &url_r,
- const std::string &msg_r,
- const std::string &err_r,
- const std::string &hint_r)
- : MediaException(msg_r)
- , _url(url_r)
- , _err(err_r)
- , _hint(hint_r)
- {}
-
- virtual ~MediaUnauthorizedException() noexcept {}
-
- const Url & url() const { return _url; }
- const std::string & err() const { return _err; }
- /** comma separated list of available authentication types */
- const std::string & hint() const { return _hint; }
-
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- Url _url;
- std::string _err;
- std::string _hint;
- };
-
- class MediaForbiddenException : public MediaException
- {
- public:
- MediaForbiddenException(const Url & url_r, const std::string & msg = "")
- : MediaException(msg)
- , _url(url_r.asString()), _msg(msg)
- {}
- virtual ~MediaForbiddenException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- };
-
- class MediaTimeoutException : public MediaException
- {
- public:
- MediaTimeoutException(const Url & url_r, const std::string & msg = "")
- : MediaException(msg)
- , _url(url_r.asString()), _msg(msg)
- {}
- virtual ~MediaTimeoutException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- };
-
- class MediaFileSizeExceededException : public MediaException
- {
- public:
- MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
- : MediaException(msg)
- , _url(url_r.asString())
- , _msg(msg)
- , _expectedFileSize(cnt_r)
- {}
- virtual ~MediaFileSizeExceededException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- ByteCount _expectedFileSize;
- };
-
- /** For HTTP 503 and similar. */
- class MediaTemporaryProblemException : public MediaException
- {
- public:
- MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
- : MediaException(msg)
- , _url(url_r.asString()), _msg(msg)
- {}
- virtual ~MediaTemporaryProblemException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- };
-
- class MediaBadCAException : public MediaException
- {
- public:
- MediaBadCAException(const Url & url_r, const std::string & msg = "")
- : MediaException(msg)
- , _url(url_r.asString()), _msg(msg)
- {}
- virtual ~MediaBadCAException() noexcept {}
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- std::string _url;
- std::string _msg;
- };
-
- class MediaInvalidCredentialsException : public MediaException
- {
- public:
- MediaInvalidCredentialsException( const std::string & msg = "" )
- : MediaException(msg)
- {}
- virtual ~MediaInvalidCredentialsException() noexcept {}
- };
-
- /////////////////////////////////////////////////////////////////
- } // namespace media
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
+#include <zypp-media/MediaException>
#include <zypp/base/String.h>
#include <zypp/media/MediaHandler.h>
#include <zypp/media/MediaManager.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
{
if( attach_prefix.empty())
{
- MIL << "Reseting to built-in attach point prefixes."
+ MIL << "Resetting to built-in attach point prefixes."
<< std::endl;
MediaHandler::_attachPrefix = attach_prefix;
return true;
#include <zypp/Url.h>
#include <zypp/media/MediaSource.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/APIConfig.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::media"
#include <zypp/base/Logger.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/media/MediaHandler.h>
#include <zypp/media/MediaNFS.h>
#include <iostream>
#include <zypp/base/Logger.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
#include <zypp/media/MediaISO.h>
if( _filesystem.empty())
_filesystem = "auto";
- std::string arg;
- zypp::Url src;
- try
+ Url src;
{
- // this percent-decodes the query parameter, it must be later encoded
- // again before used in a Url object
- arg = _url.getQueryParam("url");
- if( arg.empty() && _isofile.dirname().absolute())
- {
- src = std::string("dir:///");
- src.setPathName(url::encode(_isofile.dirname().asString(), URL_SAFE_CHARS));
+ const std::string & arg { _url.getQueryParam("url") };
+ if ( arg.empty() ) {
+ src = "dir:/";
+ src.setPathName( _isofile.dirname() );
_isofile = _isofile.basename();
}
- else
+ else try {
+ src = arg;
+ }
+ catch( const url::UrlException & e )
{
- src = url::encode(arg, URL_SAFE_CHARS);
+ ZYPP_CAUGHT(e);
+ ERR << "Unable to parse iso filename source media url" << std::endl;
+ MediaBadUrlException ne(_url);
+ ne.remember(e);
+ ZYPP_THROW(ne);
}
}
- catch(const zypp::url::UrlException &e)
- {
- ZYPP_CAUGHT(e);
- ERR << "Unable to parse iso filename source media url" << std::endl;
- MediaBadUrlException ne(_url);
- ne.remember(e);
- ZYPP_THROW(ne);
- }
if( !src.isValid())
{
ERR << "Invalid iso filename source media url" << std::endl;
#include <iostream>
#include <typeinfo>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/media/MediaManager.h>
#include <zypp/media/MediaHandlerFactory.h>
#include <zypp/media/MediaHandler.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
#include <zypp/base/String.h>
#include <zypp/base/Logger.h>
{
try
{
- close(); // !!! make sure handler gets properly deleted.
+ if ( _handler )
+ close(); // !!! make sure handler gets properly deleted.
}
catch(...) {}
}
#include <zypp/Pathname.h>
#include <zypp/PathInfo.h>
#include <zypp/Url.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/media/MediaSource.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <list>
#include <zypp/ZConfig.h>
#include <zypp/base/Logger.h>
#include <zypp/media/MediaMultiCurl.h>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/parser/MetaLinkParser>
#include <zypp/ManagedFile.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-curl/auth/CurlAuthData>
using std::endl;
using namespace zypp::base;
}
else
{
- WAR << "Could not get the reponse code." << endl;
+ WAR << "Could not get the response code." << endl;
}
bool ismetalink = false;
#include <zypp/media/MediaHandler.h>
#include <zypp/media/MediaCurl.h>
-#include <zypp/media/MediaBlockList.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/parser/MediaBlockList>
+#include <zypp-curl/TransferSettings>
#include <zypp/ZYppCallbacks.h>
namespace zypp {
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
#include <zypp/media/MediaNFS.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
#include <dirent.h>
#define ZYPP_MEDIA_MEDIANETWORKCOMMONHANDLER_H
#include <zypp/media/MediaHandler.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
///////////////////////////////////////////////////////////////////
namespace zypp
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaUserAuth.cc
- *
- */
-
-#include <list>
-#include <curl/curl.h>
-
-#include <zypp/base/Gettext.h>
-#include <zypp/base/String.h>
-
-#include <zypp/media/MediaException.h>
-#include <zypp/media/MediaUserAuth.h>
-
-using std::endl;
-
-namespace zypp {
- namespace media {
-
-
-AuthData::AuthData(const Url & url)
- : _url(url), _lastChange(0)
-{
- _username = url.getUsername();
- _password = url.getPassword();
-}
-
-
-bool AuthData::valid() const
-{
- return username().size() && password().size();
-}
-
-time_t AuthData::lastDatabaseUpdate() const
-{
- return _lastChange;
-}
-
-void AuthData::setLastDatabaseUpdate( time_t time )
-{
- _lastChange = time;
-}
-
-std::ostream & AuthData::dumpOn( std::ostream & str ) const
-{
- if (_url.isValid())
- str << "[" << _url.asString( url::ViewOptions() - url::ViewOptions::WITH_USERNAME - url::ViewOptions::WITH_PASSWORD ) << "]" << endl;
- else
- str << "[<no-url>]" << endl;
- str << "username: '" << _username << "'" << std::endl
- << "password: " << (_password.empty() ? "<empty>" : "<non-empty>");
- return str;
-}
-
-std::ostream & AuthData::dumpAsIniOn( std::ostream & str ) const
-{
- if (_url.isValid())
- str
- << "[" << _url.asString(
- url::ViewOptions()
- - url::ViewOptions::WITH_USERNAME
- - url::ViewOptions::WITH_PASSWORD)
- << "]" << endl;
-
- str
- << "username = " << _username << endl
- << "password = " << _password << endl;
-
- return str;
-}
-
-CurlAuthData::CurlAuthData()
- : AuthData()
- , _auth_type_str()
- , _auth_type(CURLAUTH_NONE)
-{}
-
-CurlAuthData::CurlAuthData(const AuthData & authData)
- : AuthData(authData)
- , _auth_type_str()
- , _auth_type(CURLAUTH_NONE)
-{}
-
-bool CurlAuthData::valid() const
-{
- return username().size() && password().size();
-}
-
-std::ostream & CurlAuthData::dumpOn( std::ostream & str ) const
-{
- AuthData::dumpOn(str) << endl
- << " auth_type: " << _auth_type_str << " (" << _auth_type << ")";
- return str;
-}
-
-long CurlAuthData::auth_type_str2long( std::string & auth_type_str )
-{
- return auth_type_str2long( const_cast< const std::string &>(auth_type_str) );
-}
-
-long CurlAuthData::auth_type_str2long( const std::string & auth_type_str )
-{
- curl_version_info_data *curl_info = curl_version_info(CURLVERSION_NOW);
-
- std::vector<std::string> list;
- std::vector<std::string>::const_iterator it;
- long auth_type = CURLAUTH_NONE;
-
- zypp::str::split(auth_type_str, std::back_inserter(list), ",");
-
- for(it = list.begin(); it != list.end(); ++it)
- {
- if(*it == "basic")
- {
- auth_type |= CURLAUTH_BASIC;
- }
- else
- if(*it == "digest")
- {
- auth_type |= CURLAUTH_DIGEST;
- }
- else
- if((curl_info && (curl_info->features & CURL_VERSION_NTLM)) &&
- (*it == "ntlm"))
- {
- auth_type |= CURLAUTH_NTLM;
- }
- else
- if((curl_info && (curl_info->features & CURL_VERSION_SPNEGO)) &&
- (*it == "spnego" || *it == "negotiate"))
- {
- // there is no separate spnego flag for this auth type
- auth_type |= CURLAUTH_GSSNEGOTIATE;
- }
- else
- if((curl_info && (curl_info->features & CURL_VERSION_GSSNEGOTIATE)) &&
- (*it == "gssnego" || *it == "negotiate"))
- {
- auth_type |= CURLAUTH_GSSNEGOTIATE;
- }
- else
- {
- ZYPP_THROW(MediaException(str::Format(_("Unsupported HTTP authentication method '%s'")) % *it));
- }
- }
-
- return auth_type;
-}
-
-std::string CurlAuthData::auth_type_long2str(long auth_type)
-{
- std::list<std::string> auth_list;
-
- if(auth_type & CURLAUTH_GSSNEGOTIATE)
- auth_list.push_back("negotiate");
-
- if(auth_type & CURLAUTH_NTLM)
- auth_list.push_back("ntlm");
-
- if(auth_type & CURLAUTH_DIGEST)
- auth_list.push_back("digest");
-
- if(auth_type & CURLAUTH_BASIC)
- auth_list.push_back("basic");
-
- return str::join(auth_list, ",");
-}
-
-
-std::ostream & operator << (std::ostream & str, const AuthData & auth_data)
-{
- auth_data.dumpOn(str);
- return str;
-}
-
-std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data)
-{
- auth_data.dumpOn(str);
- return str;
-}
-
-
- } // namespace media
-} // namespace zypp
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaUserAuth.h
- * Convenience interface for handling authentication data of media user.
- */
-#ifndef ZYPP_MEDIA_USER_AUTH_H
-#define ZYPP_MEDIA_USER_AUTH_H
-
-#include <zypp/APIConfig.h>
-
-#include <zypp/Url.h>
-#include <zypp/base/PtrTypes.h>
-
-namespace zypp {
- namespace media {
-
-///////////////////////////////////////////////////////////////////
-
-
-/**
- * Class for handling media authentication data. This is the most generic
- * class containing only username and password members.
- */
-class AuthData
-{
-public:
- AuthData()
- {}
-
- AuthData(const Url & url);
-
- AuthData(const std::string & username, const std::string & password)
- : _username(username), _password(password), _lastChange(0)
- {}
-
- virtual ~AuthData() {};
-
- /**
- * Checks validity of authentication data.
- * \return true if the object contains non-empty username and
- * non-empty password, false otherwise.
- */
- virtual bool valid() const;
-
- void setUrl(const Url & url) { _url = url; }
- void setUsername(const std::string & username) { _username = username; }
- void setPassword(const std::string & password) { _password = password; }
-
- Url url() const { return _url; }
- std::string username() const { return _username; }
- std::string password() const { return _password; }
-
- /*!
- * Returns the timestamp of the last change to the database this
- * credential is stored in, or 0 if its not known.
- */
- time_t lastDatabaseUpdate () const;
- void setLastDatabaseUpdate ( time_t time );
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
- virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
-
-private:
- Url _url;
- std::string _username;
- std::string _password;
- time_t _lastChange; //< timestamp of the last change to the database this credential is stored in
-};
-
-typedef shared_ptr<AuthData> AuthData_Ptr;
-
-/**
- * Curl HTTP authentication data.
- */
-class CurlAuthData : public AuthData {
-public:
- /**
- * Default constructor. Initializes username and password to empty strings
- * and authetication type to CURLAUTH_NONE.
- */
- CurlAuthData();
-
- CurlAuthData(const AuthData & authData);
-
- CurlAuthData(std::string & username, std::string & password, std::string & auth_type)
- : AuthData(username,password), _auth_type_str(auth_type)
- {
- _auth_type = auth_type_str2long(auth_type);
- }
-
- CurlAuthData(std::string & username, std::string & password, long auth_type)
- : AuthData(username,password), _auth_type(auth_type)
- {
- _auth_type_str = auth_type_long2str(auth_type);
- }
-
- /**
- * Checks validity of authentication data.
- * \return true if the object contains non-empty username,
- * non-empty password, and specifies authentication type; false otherwise.
- */
- virtual bool valid() const;
-
- /**
- * Set HTTP authentication type(s) to use.
- * \param comma separated list of HTTP authentication type names
- */
- void setAuthType(std::string auth_type)
- {
- _auth_type_str = auth_type; _auth_type = auth_type_str2long(auth_type);
- }
-
- /*
- * Set HTTP authentication type(s) to use.
- * \param HTTP authentication type as in long ORed form.
- * \see curl.h for available auth types
- */
- void setAuthType(long auth_type)
- {
- _auth_type = auth_type;
- _auth_type_str = auth_type_long2str(auth_type);
- }
-
- long authType() const { return _auth_type; }
- std::string authTypeAsString() const { return _auth_type_str; }
-
- std::string getUserPwd() const { return username() + ":" + password(); }
-
-
- /**
- * Converts a string of comma separated list of authetication type names
- * into a long of ORed CURLAUTH_* identifiers.
- * The method also automatically leaves out any auth types declared
- * not supported by curl_version_info().
- *
- * \throws MediaException if an invalid authentication type name is
- * encountered.
- */
- static long auth_type_str2long( std::string & auth_type_str );
- static long auth_type_str2long( const std::string &auth_type_str );
-
- /**
- * Converts a long of ORed CURLAUTH_* identifiers into a string of comma
- * separated list of authentication type names.
- */
- static std::string auth_type_long2str(long auth_type);
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
-private:
- std::string _auth_type_str;
- long _auth_type;
-};
-
-typedef shared_ptr<CurlAuthData> CurlAuthData_Ptr;
-
-std::ostream & operator << (std::ostream & str, const AuthData & auth_data);
-std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data);
-
-///////////////////////////////////////////////////////////////////
-
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_USER_AUTH_H
+#include <zypp-media/auth/AuthData>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MetaLinkParser.h
- *
-*/
-#ifndef ZYPP_MEDIA_METALINKPARSER_H
-#define ZYPP_MEDIA_METALINKPARSER_H
-
-#include <string>
-
-#include <zypp/base/Exception.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/media/MediaBlockList.h>
-#include <zypp/Url.h>
-#include <zypp/ByteArray.h>
-
-namespace zypp::media {
-
-struct ml_parsedata;
-
-struct MetalinkMirror {
- int priority = 0;
- int maxConnections = -1; //< How many connections can be opened to that mirror, -1 means no limit was defined.
- Url url;
-};
-
-class MetaLinkParser : private zypp::base::NonCopyable {
-public:
- MetaLinkParser();
- ~MetaLinkParser();
-
- /**
- * parse a file consisting of metalink xml data
- * \throws Exception
- **/
- void parse(const Pathname &filename);
-
- /**
- * parse an InputStream consisting of metalink xml data
- * \throws Exception
- **/
- void parse(const InputStream &is);
-
- /**
- * parse a chunk of a file consisting of metalink xml data.
- * \throws Exception
- **/
- void parseBytes(const char* bytes, size_t len);
- /**
- * tells the parser that all chunks are now processed
- * \throws Exception
- **/
- void parseEnd();
-
- /**
- * return the download urls from the parsed metalink data
- **/
- std::vector<Url> getUrls() const;
-
- /**
- * return the mirrors from the parsed metalink data
- */
- const std::vector<MetalinkMirror> &getMirrors() const;
-
- /**
- * return the block list from the parsed metalink data
- **/
- MediaBlockList getBlockList() const;
-
- const std::vector<UByteArray> &getZsyncBlockHashes() const;
- const std::vector<UByteArray> &getSHA1BlockHashes() const;
-
-private:
- struct ml_parsedata *pd;
-};
-
-UByteArray hexstr2bytes( std::string str );
-
-} // namespace zypp::media
-
-#endif // ZYPP_MEDIA_METALINKPARSER_H
+#include <zypp-curl/parser/MetaLinkParser>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/Mount.h
- *
-*/
-
-// -*- C++ -*-
-
-#ifndef ZYPP_MEDIA_MOUNT_H
-#define ZYPP_MEDIA_MOUNT_H
-
-#include <set>
-#include <map>
-#include <string>
-#include <iosfwd>
-
-#include <zypp/ExternalProgram.h>
-#include <zypp/KVMap.h>
-
-namespace zypp {
- namespace media {
-
-
- /**
- * A "struct mntent" like mount entry structure,
- * but using std::strings.
- */
- struct MountEntry
- {
- MountEntry(const std::string &source,
- const std::string &target,
- const std::string &fstype,
- const std::string &options,
- const int dumpfreq = 0,
- const int passnum = 0)
- : src(source)
- , dir(target)
- , type(fstype)
- , opts(options)
- , freq(dumpfreq)
- , pass(passnum)
- {}
-
- std::string src; //!< name of mounted file system
- std::string dir; //!< file system path prefix
- std::string type; //!< filesystem / mount type
- std::string opts; //!< mount options
- int freq; //!< dump frequency in days
- int pass; //!< pass number on parallel fsck
- };
-
- /** \relates MountEntry
- * A vector of mount entries.
- */
- typedef std::vector<MountEntry> MountEntries;
-
- /** \relates MountEntry Stream output */
- std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
-
- /**
- * @short Interface to the mount program
- */
- class Mount
- {
- public:
-
- /**
- * For passing additional environment variables
- * to mount
- **/
- typedef ExternalProgram::Environment Environment;
-
- /**
- * Mount options. 'key' or 'key=value' pairs, separated by ','
- **/
- typedef KVMap<kvmap::KVMapBase::CharSep<'=',','> > Options;
-
- public:
-
- /**
- * Create an new instance.
- */
- Mount();
-
- /**
- * Clean up.
- */
- ~Mount();
-
- /**
- * mount device
- *
- * @param source what to mount (e.g. /dev/hda3)
- * @param target where to mount (e.g. /mnt)
- * @param filesystem which filesystem to use (e.g. reiserfs) (-t parameter)
- * @param options mount options (e.g. ro) (-o parameter)
- * @param environment optinal environment to pass (e.g. PASSWD="sennah")
- *
- * \throws MediaException
- *
- */
-
- void mount ( const std::string& source,
- const std::string& target,
- const std::string& filesystem,
- const std::string& options,
- const Environment& environment = Environment() );
-
- /** umount device
- *
- * @param path device or mountpoint to umount
- *
- * \throws MediaException
- *
- * */
- void umount (const std::string& path);
-
- public:
-
- /**
- * Return mount entries from /etc/mtab or /etc/fstab file.
- *
- * @param mtab The name of the (mounted) file system description
- * file to read from. This file should be one /etc/mtab,
- * /etc/fstab or /proc/mounts. Default is to read
- * /proc/mounts and /etc/mtab in case is not a symlink
- * to /proc/mounts.
- * @returns A vector with mount entries or empty vector if reading
- * or parsing of the mtab file(s) failed.
- */
- static MountEntries
- getEntries(const std::string &mtab = "");
-
- private:
-
- /** The connection to the mount process.
- * */
- ExternalProgram *process;
-
- /**
- * Run mount with the specified arguments and handle stderr.
- * @param argv Mount arguments
- * @param environment Addittional environment to set
- * @param stderr_disp How to handle stderr, merged with stdout by default
- * */
- void run( const char *const *argv, const Environment& environment,
- ExternalProgram::Stderr_Disposition stderr_disp =
- ExternalProgram::Stderr_To_Stdout);
-
- void run( const char *const *argv,
- ExternalProgram::Stderr_Disposition stderr_disp =
- ExternalProgram::Stderr_To_Stdout) {
- Environment notused;
- run( argv, notused, stderr_disp );
- }
-
- /** Return the exit status of the process, closing the connection if
- * not already done.
- * */
- int Status();
-
- /** Forcably kill the process
- * */
- void Kill();
-
-
- /** The exit code of the process, or -1 if not yet known.
- * */
- int exit_code;
- };
-
-
- } // namespace media
-} // namespace zypp
-
-#endif
+#include <zypp-media/Mount>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/ProxyInfo.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_H
-#define ZYPP_MEDIA_PROXYINFO_H
-
-#include <string>
-#include <list>
-
-#include <zypp/base/PtrTypes.h>
-
-namespace zypp {
-
- class Url;
-
- namespace media {
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ProxyInfo
- class ProxyInfo
- {
- public:
- typedef intrusive_ptr<ProxyInfo> Ptr;
- typedef intrusive_ptr<ProxyInfo> constPtr;
- typedef std::list<std::string> NoProxyList;
- typedef std::list<std::string>::const_iterator NoProxyIterator;
-
- /** Implementation */
- struct Impl;
- typedef shared_ptr<Impl> ImplPtr;
-
- /** Default Ctor: guess the best available implementation. */
- ProxyInfo();
- /** Ctor taking a specific implementation. */
- ProxyInfo( ProxyInfo::ImplPtr pimpl_r );
-
- bool enabled() const;
- std::string proxy(const Url & url) const;
- NoProxyList noProxy() const;
- NoProxyIterator noProxyBegin() const;
- NoProxyIterator noProxyEnd() const;
-
- /** Return \c true if \ref enabled and \a url_r does not match \ref noProxy. */
- bool useProxyFor( const Url & url_r ) const;
-
- private:
- /** Pointer to implementation */
- RW_pointer<Impl> _pimpl;
- };
-
-
-///////////////////////////////////////////////////////////////////
-
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_H
+#include <zypp-curl/ProxyInfo>
-
-#ifndef TRANSFER_SETTINGS_H_
-#define TRANSFER_SETTINGS_H_
-
-#include <string>
-#include <vector>
-#include <zypp/base/Flags.h>
-#include <zypp/base/PtrTypes.h>
-#include <zypp/Pathname.h>
-#include <zypp/Url.h>
-
-namespace zypp::proto {
- class TransferSettings;
-}
-
-namespace zypp
-{
- namespace media
- {
-
- /**
- * Holds transfer setting
- */
- class TransferSettings
- {
- public:
- /** Constructs a transfer program cmd line access. */
- TransferSettings();
-
- TransferSettings( const zypp::proto::TransferSettings &settings );
-
- typedef std::vector<std::string> Headers;
-
- /** reset the settings to the defaults */
- void reset();
-
-
- /** add a header, on the form "Foo: Bar" */
- void addHeader( std::string && val_r );
-
- /** returns a list of all added headers */
- Headers headers() const;
-
- /** sets the user agent ie: "Mozilla v3" */
- void setUserAgentString( std::string && val_r );
-
- /** user agent string */
- std::string userAgentString() const;
-
-
- /** sets the auth username */
- void setUsername( std::string && val_r );
-
- /** auth username */
- std::string username() const;
-
- /** sets the auth password */
- void setPassword( std::string && val_r );
-
- /** auth password */
- std::string password() const;
-
- /** returns the user and password as a user:pass string */
- std::string userPassword() const;
-
- /** sets anonymous authentication (ie: for ftp) */
- void setAnonymousAuth();
-
-
- /** whether the proxy is used or not */
- void setProxyEnabled( bool enabled );
-
- /** proxy is enabled */
- bool proxyEnabled() const;
-
-
- /** proxy to use if it is enabled */
- void setProxy( std::string && val_r );
-
- /** proxy host */
- std::string proxy() const;
-
-
- /** sets the proxy user */
- void setProxyUsername( std::string && val_r );
-
- /** proxy auth username */
- std::string proxyUsername() const;
-
- /** sets the proxy password */
- void setProxyPassword( std::string && val_r );
-
- /** proxy auth password */
- std::string proxyPassword() const;
-
- /** returns the proxy user and password as a user:pass string */
- std::string proxyUserPassword() const;
-
-
- /** set the connect timeout */
- void setConnectTimeout( long t );
-
- /** connection timeout */
- long connectTimeout() const;
-
-
- /** set the transfer timeout */
- void setTimeout( long t );
-
- /** transfer timeout */
- long timeout() const;
-
-
- /** Set maximum number of concurrent connections for a single transfer */
- void setMaxConcurrentConnections(long v);
-
- /** Maximum number of concurrent connections for a single transfer */
- long maxConcurrentConnections() const;
-
-
- /** Set minimum download speed (bytes per second) until the connection is dropped */
- void setMinDownloadSpeed(long v);
-
- /** Minimum download speed (bytes per second) until the connection is dropped */
- long minDownloadSpeed() const;
-
-
- /** Set max download speed (bytes per second) */
- void setMaxDownloadSpeed(long v);
-
- /** Maximum download speed (bytes per second) */
- long maxDownloadSpeed() const;
-
-
- /** Set maximum silent retries */
- void setMaxSilentTries(long v);
-
- /** Maximum silent retries */
- long maxSilentTries() const;
-
-
- /** Sets whether to verify host for ssl */
- void setVerifyHostEnabled( bool enabled );
-
- /** Whether to verify host for ssl */
- bool verifyHostEnabled() const;
-
-
- /** Sets whether to verify host for ssl */
- void setVerifyPeerEnabled( bool enabled );
-
- /** Whether to verify peer for ssl */
- bool verifyPeerEnabled() const;
-
-
- /** Sets the SSL certificate authorities path */
- void setCertificateAuthoritiesPath( Pathname && val_r );
-
- /** SSL certificate authorities path ( default: /etc/ssl/certs ) */
- Pathname certificateAuthoritiesPath() const;
-
-
- /** set the allowed authentication types */
- void setAuthType( std::string && val_r );
-
- /** get the allowed authentication types */
- std::string authType() const;
-
-
- /** set whether HEAD requests are allowed */
- void setHeadRequestsAllowed(bool allowed);
-
- /** whether HEAD requests are allowed */
- bool headRequestsAllowed() const;
-
-
- /** Sets the SSL client certificate file */
- void setClientCertificatePath( Pathname && val_r );
-
- /** SSL client certificate file */
- Pathname clientCertificatePath() const;
-
-
- /** Sets the SSL client key file */
- void setClientKeyPath( Pathname && val_r );
-
- /** SSL client key file */
- Pathname clientKeyPath() const;
-
- const zypp::proto::TransferSettings &protoData() const;
- zypp::proto::TransferSettings &protoData();
-
- protected:
- class Impl;
- RWCOW_pointer<Impl> _impl;
- };
-
- } // namespace media
-} // namespece zypp
-
-#endif
+#include <zypp-curl/TransferSettings>
#include <iostream>
#include <zypp/base/Logger.h>
#include <zypp/media/UrlResolverPlugin.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/PluginScript.h>
#include <zypp/ZConfig.h>
#include <zypp/base/Exception.h>
#include <zypp/base/NonCopyable.h>
-#include <zypp/media/MediaBlockList.h>
+#include <zypp-curl/parser/MediaBlockList>
#include <zypp/Url.h>
namespace zypp {
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoImpl.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
-
-#include <string>
-#include <list>
-
-#include <zypp/Url.h>
-#include <zypp/base/String.h>
-#include <zypp/media/ProxyInfo.h>
-
-namespace zypp {
- namespace media {
-
- struct ProxyInfo::Impl
- {
- /** Ctor */
- Impl()
- {}
-
- /** Dtor */
- virtual ~Impl()
- {}
-
- public:
- /** */
- virtual bool enabled() const = 0;
- /** */
- virtual std::string proxy(const Url & url_r) const = 0;
- /** */
- virtual ProxyInfo::NoProxyList noProxy() const = 0;
- /** */
- virtual ProxyInfo::NoProxyIterator noProxyBegin() const = 0;
- /** */
- virtual ProxyInfo::NoProxyIterator noProxyEnd() const = 0;
-
- /** Return \c true if \ref enabled and \a url_r does not match \ref noProxy. */
- bool useProxyFor( const Url & url_r ) const
- {
- if ( ! enabled() || proxy( url_r ).empty() )
- return false;
-
- ProxyInfo::NoProxyList noproxy( noProxy() );
- if ( noproxy.size() == 1 && noproxy.front() == "*" )
- return false; // just an asterisk disables all.
-
- // No proxy: Either an exact match, or the previous character
- // is a '.', so host is within the same domain.
- // A leading '.' in the pattern is ignored. Some implementations
- // need '.foo.ba' to prevent 'foo.ba' from matching 'xfoo.ba'.
- std::string host( str::toLower( url_r.getHost() ) );
- for_( it, noproxy.begin(), noproxy.end() )
- {
- std::string pattern( str::toLower( (*it)[0] == '.' ? it->c_str() + 1 : it->c_str() ) );
- if ( str::hasSuffix( host, pattern )
- && ( host.size() == pattern.size()
- || host[host.size()-pattern.size()-1] == '.' ) )
- return false;
- }
- return true;
- }
-
- public:
- /** Default Impl: empty sets. */
- static shared_ptr<Impl> _nullimpl;
- };
-
-
-///////////////////////////////////////////////////////////////////
-
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
+#include <zypp-curl/proxyinfo/proxyinfoimpl.h>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoLibproxy.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
-
-#include <string>
-#include <map>
-
-#include <proxy.h>
-
-#include <zypp/base/DefaultIntegral.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/proxyinfo/ProxyInfoImpl.h>
-
-namespace zypp {
- namespace media {
-
-
- class ProxyInfoLibproxy : public ProxyInfo::Impl
- {
- public:
- ProxyInfoLibproxy();
- /** */
- ~ProxyInfoLibproxy();
- /** */
- bool enabled() const
- { return _enabled; }
- /** */
- std::string proxy(const Url & url_r) const;
- /** */
- ProxyInfo::NoProxyList noProxy() const
- { return _no_proxy; }
- /** */
- virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
- /** */
- virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
- private:
- DefaultIntegral<bool,false> _enabled;
- ProxyInfo::NoProxyList _no_proxy;
- pxProxyFactory *_factory;
- };
-
-///////////////////////////////////////////////////////////////////
-
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
+#include <zypp-curl/proxyinfo/ProxyInfoLibproxy>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoSysconfig.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOSYSCONFIG_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOSYSCONFIG_H
-
-#include <string>
-#include <map>
-
-#include <zypp/base/Sysconfig.h>
-#include <zypp/base/DefaultIntegral.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/proxyinfo/ProxyInfoImpl.h>
-
-namespace zypp {
- namespace media {
-
-
- class ProxyInfoSysconfig : public ProxyInfo::Impl
- {
- public:
- ProxyInfoSysconfig(const Pathname & path);
- /** */
- bool enabled() const
- { return _enabled; }
- /** */
- std::string proxy(const Url & url_r) const;
- /** */
- ProxyInfo::NoProxyList noProxy() const
- { return _no_proxy; }
- /** */
- virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
- /** */
- virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
- private:
- DefaultIntegral<bool,false> _enabled;
- ProxyInfo::NoProxyList _no_proxy;
- std::map<std::string,std::string> _proxies;
- };
-
-///////////////////////////////////////////////////////////////////
-
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOSYSCONFIG_H
+#include <zypp-curl/proxyinfo/ProxyInfoSysconfig>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfos.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOS_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOS_H
-
-#include <string>
-#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
+#include <zypp-curl/proxyinfo/proxyinfos.h>
#include <zypp/ExternalProgram.h>
#include <zypp/base/Regex.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/target/rpm/librpmDb.h>
#include <zypp/misc/CheckAccessDeleted.h>
} else if (node->equals( "trial" )) {
if ( !setupDone ) {
- if ( err ) *err = "Any trials must be preceeded by the setup!";
+ if ( err ) *err = "Any trials must be preceded by the setup!";
return false;
}
TestcaseTrial trial;
auto doc = YAML::LoadFile( fName );
if ( !parseJobs( doc, target, err ) )
return false;
- MIL << "Including file " << fName << "was successfull" << std::endl;
+ MIL << "Including file " << fName << "was successful" << std::endl;
} catch ( YAML::Exception &e ) {
if ( err ) *err = e.what();
return false;
*/
#include <iostream>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/IOStream.h>
#include <zypp/base/Logger.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
#include <zypp/parser/HistoryLogReader.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/Flags.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/Pathname.h>
#include <zypp/HistoryLogData.h>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/IniDict.h
- *
-*/
-#ifndef ZYPP_PARSER_INIDICT_H
-#define ZYPP_PARSER_INIDICT_H
-
-#include <iosfwd>
-#include <map>
-#include <string>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/base/Iterable.h>
-#include <zypp/parser/IniParser.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : IniDict
- //
- /**
- * Parses a INI file and offers its structure as a
- * dictionary.
- *
- */
- class IniDict : public IniParser
- {
- friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
- public:
- typedef std::map<std::string, std::string> EntrySet;
- typedef std::map<std::string, EntrySet> SectionSet;
- typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator section_const_iterator;
- typedef EntrySet::const_iterator entry_const_iterator;
-
- /**
- * \name Section Iterators
- * Iterate trough ini file sections
- * \code
- * for ( IniDict::section_const_iterator it = dict.sectionsBegin();
- * it != dict.sectionsEnd();
- * ++it )
- * {
- * MIL << (*it) << endl;
- * }
- * \endcode
- */
- //@{
- section_const_iterator sectionsBegin() const;
- section_const_iterator sectionsEnd() const;
- Iterable<section_const_iterator> sections() const;
- //@}
-
- /**
- * \name Entries Iterators
- * Iterate trough ini file entries in a section
- * \code
- * for ( IniDict::entry_const_iterator it = dict.entriesBegin("updates");
- * it != dict.entriesEnd("updates");
- * ++it )
- * {
- * MIL << (*it).first << endl;
- * }
- * \endcode
- */
-
- //@{
- entry_const_iterator entriesBegin(const std::string §ion) const;
- entry_const_iterator entriesEnd(const std::string §ion) const;
- Iterable<entry_const_iterator> entries(const std::string §ion) const;
- //@{
-
- /**
- * Creates a dictionary from a InputStream
- * containing a ini structured file
- */
- IniDict( const InputStream &is,
- const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
-
- /**
- * Creates a mepty dictionary
- */
- IniDict();
-
- /** Dtor */
- ~IniDict();
-
- /**
- * Fill a dictionary from a InputStream
- * containing a ini structured file
- */
- void read( const InputStream &is,
- const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
-
- /**
- * \short add an entry
- * \param section
- * \param key
- * \param value
- */
- void insertEntry( const std::string §ion,
- const std::string &key,
- const std::string &value );
-
- /**
- * \short add an entry
- * \param section
- * \param key
- * \param value
- */
- void deleteSection( const std::string §ion );
-
- /**
- * \short True if there is a section with that name
- * \param section Section Name
- */
- bool hasSection( const std::string §ion ) const;
-
- /**
- * \short True if an entry exists in the section
- * \param section Section name
- * \param entry entry name
- *
- * \note If the given section does not exist, this will
- * of course return false.
- */
- bool hasEntry( const std::string §ion,
- const std::string &entry ) const;
- public:
-
- /** Called when a section is found. */
- virtual void consume( const std::string §ion );
- /** Called when a key value is found. */
- virtual void consume( const std::string §ion,
- const std::string &key,
- const std::string &value );
-
- private:
- SectionSet _dict;
- /**
- * empty map used to simulate
- * iteration in non existant
- * sections
- */
- EntrySet _empty_map;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates IniDict Stream output */
- std::ostream & operator<<( std::ostream & str, const IniDict & obj );
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_INIDICT_H
+#include <zypp-core/parser/IniDict>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/IniParser.h
- *
-*/
-#ifndef ZYPP_PARSER_INIPARSER_H
-#define ZYPP_PARSER_INIPARSER_H
-
-#include <iosfwd>
-#include <string>
-#include <list>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/ProgressData.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace parser
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-/// \class IniParser
-/// \brief Simple INI-file parser
-///
-/// Lines staring with \c ; or \c # are treated as comment. Section
-/// names are enclosed by <tt>[]</tt>. Key and value are separated by \c =.
-///
-/// Lines without \c = or with a key containing any of "<tt>,|\\/</tt>"
-/// or section lines without closing \c ] are considered garbage.
-///
-class IniParser : private base::NonCopyable
-{
-public:
- /** Default ctor */
- IniParser();
- /** Dtor */
- virtual ~IniParser();
- /** Parse the stream.
- * \throw ParseException on errors. Invoke \ref consume
- * for each tag. \ref consume might throw other exceptions
- * as well.
- */
- void parse( const InputStream & imput_r, const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
-
-public:
- /** Called when start parsing. */
- virtual void beginParse();
- /** Called when a section is found. */
- virtual void consume( const std::string §ion );
- /** Called when a key value is found. */
- virtual void consume( const std::string §ion, const std::string &key, const std::string &value );
- /** Called when the parse is done. */
- virtual void endParse();
-
- /** Called whenever a garbage line is found.
- *
- * \throw ParseException if not overloaded.
- *
- * Derived parsers may overload this to examine the line
- * and call this method to actually throw the exception.
- *
- * Used by some parsers to accept multi-line entires.
- */
- virtual void garbageLine( const std::string §ion, const std::string &line );
-
-public:
- /** Name of the current InputStream. */
- const std::string & inputname() const
- {
- return _inputname;
- }
-
-private:
- std::string _inputname;
- std::string _current_section;
- int _line_nr;
- //ProgressData _ticks;
-};
-
-/////////////////////////////////////////////////////////////////
-} // namespace parser
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_INIPARSER_H
+#include <zypp-core/parser/IniParser>
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/tagfile/ParseException.h
- *
-*/
-#ifndef ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
-#define ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
-
-#include <iosfwd>
-#include <string>
-
-#include <zypp/base/Exception.h>
-#include <zypp/base/UserRequestException.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ParseException
- //
- /** */
- class ParseException : public Exception
- {
- public:
- /** Default ctor */
- ParseException();
- /** Ctor */
- ParseException( const std::string & msg_r );
- /** Dtor */
- virtual ~ParseException() throw();
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
+#include <zypp-core/parser/ParseException>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/Function.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/Pathname.h>
#include <zypp/IdString.h>
#include <zypp/base/LogTools.h>
#include <zypp/base/String.h>
#include <zypp/base/StringV.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/UserRequestException>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
#include <zypp/parser/RepoFileReader.h>
using std::endl;
#include <iosfwd>
#include <zypp/base/PtrTypes.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/RepoInfo.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
///////////////////////////////////////////////////////////////////
namespace zypp
#include <zypp/base/String.h>
#include <zypp/base/Logger.h>
#include <zypp/base/Gettext.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/Pathname.h>
#include <zypp/parser/xml/Reader.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
#include <zypp/RepoInfo.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/NonCopyable.h>
#include <zypp/base/Function.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/Pathname.h>
#include <zypp/Date.h>
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
#include <zypp/base/Regex.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/UserRequestException>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
#include <zypp/parser/ServiceFileReader.h>
#include <zypp/ServiceInfo.h>
#include <iosfwd>
#include <zypp/base/PtrTypes.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/Pathname.h>
///////////////////////////////////////////////////////////////////
#include <zypp/base/LogTools.h>
#include <zypp/base/String.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/UserRequestException.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/base/UserRequestException>
+#include <zypp-core/parser/ParseException>
#include <zypp/parser/susetags/ContentFileReader.h>
#include <zypp/parser/susetags/RepoIndex.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/NonCopyable.h>
#include <zypp/base/Function.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
///////////////////////////////////////////////////////////////////
namespace zypp
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
-#include <zypp/base/DtorReset.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DtorReset>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/parser/xml/ParseDef.h>
#include <zypp/parser/xml/ParseDefException.h>
#include <zypp/base/Function.h>
#include <zypp/base/Hash.h>
#include <zypp/base/String.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/parser/xml/Node.h>
#include <iosfwd>
#include <zypp/base/NonCopyable.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/Function.h>
#include <zypp/parser/xml/Node.h>
for ( const std::string & tag : keywords() ) {
// Get keyhints on the fly:
// gpg-pubkey-39db7c82-5847eb1f.asc?fpr=22C07BA534178CD02EFE22AAB88B2FD43DBDC284
- // Fingerprint is explicitely mentioned or id/fpr can be derived from the filename
+ // Fingerprint is explicitly mentioned or id/fpr can be derived from the filename
if ( tag.compare( 0,10,"gpg-pubkey" ) != 0 )
continue;
#include <zypp/base/NonCopyable.h>
#include <zypp/base/Function.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
namespace zypp
{
| "sparcv8"
| "sparc"
| "aarch64"
+ | "armv8hl"
+ | "armv8l"
| "armv7tnhl"
| "armv7thl"
| "armv7nhl"
<value>sparcv8</value>
<value>sparc</value>
<value>aarch64</value>
+ <value>armv8hl</value>
+ <value>armv8l</value>
<value>armv7tnhl</value>
<value>armv7thl</value>
<value>armv7nhl</value>
#include <zypp/Url.h>
#include <zypp/Pathname.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/RepoStatus.h>
#include <zypp/MediaSetAccess.h>
#include <zypp/Fetcher.h>
#include <zypp/base/Function.h>
#include "MediaInfoDownloader.h"
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
namespace zypp
#include <zypp/Url.h>
#include <zypp/Pathname.h>
#include <zypp/Fetcher.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/MediaSetAccess.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
namespace zypp
{
break;
default:
- WAR << "Igore unknown attribute: " << it << endl;
+ WAR << "Ignore unknown attribute: " << it << endl;
}
}
#include <iosfwd>
#include <list>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/Edition.h>
#include <zypp/Arch.h>
#include <zypp/Date.h>
#include <zypp/repo/PackageDelta.h>
#include <zypp/base/Logger.h>
#include <zypp/base/Gettext.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/base/NonCopyable.h>
#include <zypp/repo/PackageProvider.h>
#include <zypp/repo/Applydeltarpm.h>
#include <zypp/base/Logger.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/String.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/UserRequestException>
#include <zypp/repo/PluginServices.h>
#include <zypp/ServiceInfo.h>
#include <iosfwd>
#include <zypp/base/PtrTypes.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/Pathname.h>
///////////////////////////////////////////////////////////////////
#include <string>
#include <zypp/base/Exception.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/RepoInfo.h>
#include <zypp/ServiceInfo.h>
#include <vector>
#include <time.h>
#include <zypp/repo/RepoMirrorList.h>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/parser/MetaLinkParser>
#include <zypp/MediaSetAccess.h>
#include <zypp/base/LogTools.h>
#include <zypp/ZConfig.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/repo/RepoProvideFile.h>
#include <zypp/ZYppCallbacks.h>
#include <zypp/MediaSetAccess.h>
#include <zypp/base/Functional.h>
#include <zypp/RepoInfo.h>
#include <zypp/ManagedFile.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/ProvideFilePolicy.h>
///////////////////////////////////////////////////////////////////
#include <zypp/base/Logger.h>
#include <zypp/repo/ServiceRepos.h>
#include <zypp/repo/RepoException.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp/parser/RepoFileReader.h>
#include <zypp/media/MediaManager.h>
#include <zypp/parser/RepoindexFileReader.h>
#define ZYPP_REPO_SERVICE_REPOS
#include <zypp/base/NonCopyable.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/ServiceInfo.h>
#include <zypp/RepoInfo.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/String.h>
#include <zypp/base/Regex.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/MediaSetAccess.h>
#include <zypp/Fetcher.h>
#include <zypp/Locale.h>
#include <zypp/ZConfig.h>
#include <zypp/repo/MediaInfoDownloader.h>
#include <zypp/repo/susetags/Downloader.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
#include <zypp/parser/susetags/RepoIndex.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
using namespace zypp::parser;
using namespace zypp::parser::susetags;
#include <zypp/Url.h>
#include <zypp/Pathname.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/RepoInfo.h>
#include <zypp/RepoStatus.h>
#include <zypp/MediaSetAccess.h>
#include "Downloader.h"
#include <zypp/repo/MediaInfoDownloader.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/parser/xml/Reader.h>
#include <zypp/parser/yum/RepomdFileReader.h>
#include <zypp/Url.h>
#include <zypp/Pathname.h>
#include <zypp/Fetcher.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/MediaSetAccess.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/RepoInfo.h>
#include <zypp/RepoStatus.h>
#include <zypp/repo/Downloader.h>
return str << "search nothing";
if ( obj.attr() )
- str << "seach " << obj.attr() << " in ";
+ str << "search " << obj.attr() << " in ";
else
- str << "seach ALL in ";
+ str << "search ALL in ";
if ( obj.solvable() )
return str << obj.solvable();
#include <iosfwd>
#include <zypp/base/PtrTypes.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/sat/detail/PoolMember.h>
#include <zypp/sat/SolvAttr.h>
#include <zypp/sat/LookupAttr.h>
#include <zypp/Repository.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/ZConfig.h>
#include <zypp/ui/Selectable.h>
#include <zypp/APIConfig.h>
#include <zypp/base/PtrTypes.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/base/String.h>
#include <zypp/sat/SolvableType.h>
#include <zypp/sat/Solvable.h>
#include <zypp/Repository.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
#include <zypp/ByteCount.h>
#include <zypp/CheckSum.h>
#include <zypp/CpeId.h>
#include <iostream>
#include <zypp/base/LogTools.h>
#include <zypp/base/SerialNumber.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/base/NonCopyable.h>
#include <zypp/base/Hash.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/Flags.h>
#include <zypp/base/Iterator.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/sat/SolvIterMixin.h>
#include <zypp/sat/Solvable.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/Exception.h>
#include <zypp/base/Measure.h>
-#include <zypp/base/WatchFile.h>
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/fs/WatchFile>
+#include <zypp-core/parser/Sysconfig>
#include <zypp/base/IOStream.h>
#include <zypp/ZConfig.h>
description = str::Format(_("install %1% although it has been retracted")) % s.asString();
} else if ( s.isPtf() ) {
// translator: %1% is a package name
- description = str::Format(_("allow to install the PTF %1%")) % s.asString();
+ description = str::Format(_("allow installing the PTF %1%")) % s.asString();
} else {
// translator: %1% is a package name
description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
ResolverFocus _focus; // The resolvers general attitude
bool _fixsystem:1; // repair errors in rpm dependency graph
- bool _allowdowngrade:1; // allow to downgrade installed solvable
- bool _allownamechange:1; // allow to change name of installed solvable
- bool _allowarchchange:1; // allow to change architecture of installed solvables
- bool _allowvendorchange:1; // allow to change vendor of installed solvables
+ bool _allowdowngrade:1; // allow one to downgrade installed solvable
+ bool _allownamechange:1; // allow one to change name of installed solvable
+ bool _allowarchchange:1; // allow one to change architecture of installed solvables
+ bool _allowvendorchange:1; // allow one to change vendor of installed solvables
bool _allowuninstall:1; // allow removal of installed solvables
bool _updatesystem:1; // update
bool _noupdateprovide:1; // true: update packages needs not to provide old package
bool _ignorealreadyrecommended:1; // true: ignore recommended packages that were already recommended by the installed packages
bool _distupgrade:1;
bool _distupgrade_removeunsupported:1;
- bool _dup_allowdowngrade:1; // dup mode: allow to downgrade installed solvable
- bool _dup_allownamechange:1; // dup mode: allow to change name of installed solvable
- bool _dup_allowarchchange:1; // dup mode: allow to change architecture of installed solvables
- bool _dup_allowvendorchange:1; // dup mode: allow to change vendor of installed solvables
+ bool _dup_allowdowngrade:1; // dup mode: allow one to downgrade installed solvable
+ bool _dup_allownamechange:1; // dup mode: allow one to change name of installed solvable
+ bool _dup_allowarchchange:1; // dup mode: allow one to change architecture of installed solvables
+ bool _dup_allowvendorchange:1; // dup mode: allow one to change vendor of installed solvables
bool _solveSrcPackages:1; // false: generate no job rule for source packages selected in the pool
bool _cleandepsOnRemove:1; // whether removing a package should also remove no longer needed requirements
#include <zypp/solver/detail/Testcase.h>
#include <zypp/base/Logger.h>
#include <zypp/base/LogControl.h>
-#include <zypp/base/GzStream.h>
+#include <zypp-core/base/GzStream>
#include <zypp/base/String.h>
#include <zypp/base/PtrTypes.h>
#include <zypp/base/NonCopyable.h>
#include <zypp/base/Logger.h>
#include <zypp/base/Exception.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
#include <zypp/Repository.h>
#include <zypp/TmpPath.h>
#include <zypp/target/CommitPackageCacheImpl.h>
public:
Impl( const Pathname & root_r )
: _root( root_r )
+ , _myJobReport { "cmdout", "%posttrans" }
{}
~Impl()
Pathname noRootScriptDir( ZConfig::instance().update_scriptsPath() / tmpDir().basename() );
- ProgressData scriptProgress( static_cast<ProgressData::value_type>(_scripts.size()) );
callback::SendReport<ProgressReport> report;
+ ProgressData scriptProgress( static_cast<ProgressData::value_type>(_scripts.size()) );
scriptProgress.sendTo( ProgressReportAdaptor( ProgressData::ReceiverFnc(), report ) );
+ str::Format fmtScriptProgress { _("Executing %%posttrans script '%1%'") };
bool firstScript = true;
+ str::Format fmtScriptFailedMsg { "warning: %%posttrans(%1%) scriptlet failed, exit status %2%\n" }; // like rpm would report it (intentionally not translated and NL-terminated)
while ( ! _scripts.empty() )
{
const auto &scriptPair = _scripts.front();
const std::string & script = scriptPair.first;
const std::string & pkgident( script.substr( 0, script.size()-6 ) ); // strip tmp file suffix
- scriptProgress.name( str::Format(_("Executing %%posttrans script '%1%'")) % pkgident );
+ scriptProgress.name( fmtScriptProgress % pkgident );
bool canContinue = true;
if (firstScript) {
msg << "Execution of %posttrans scripts cancelled";
WAR << msg << endl;
historylog.comment( msg, true /*timestamp*/);
- JobReport::warning( msg );
+ _myJobReport.warning( msg );
return false;
}
};
ExternalProgram prog( cmd, ExternalProgram::Stderr_To_Stdout, false, -1, true, _root );
+ // For now we continue to collect the lines and write the history file at the end.
+ // But JobReport lines are now sent immediately as they occur.
str::Str collect;
for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
{
DBG << line;
- collect << " " << line;
+ collect << line;
+ _myJobReport.info( line );
}
//script was executed, remove it from the list
_scripts.pop_front();
int ret = prog.close();
- const std::string & scriptmsg( collect );
+ if ( ret != 0 )
+ {
+ const std::string & msg { fmtScriptFailedMsg % pkgident % ret };
+ WAR << msg;
+ collect << msg;
+ _myJobReport.info( msg ); // info!, as rpm would have reported it.
+ }
- if ( ret != 0 || ! scriptmsg.empty() )
+ const std::string & scriptmsg( collect );
+ if ( ! scriptmsg.empty() )
{
- if ( ! scriptmsg.empty() )
- {
- str::Str msg;
- msg << "Output of " << pkgident << " %posttrans script:\n" << scriptmsg;
- historylog.comment( msg, true /*timestamp*/);
- JobReport::UserData userData( "cmdout", "%posttrans" );
- JobReport::info( msg, userData );
- }
-
- if ( ret != 0 )
- {
- str::Str msg;
- msg << pkgident << " %posttrans script failed (returned " << ret << ")";
- WAR << msg << endl;
- historylog.comment( msg, true /*timestamp*/);
- JobReport::warning( msg );
- }
+ str::Str msg;
+ msg << "Output of " << pkgident << " %posttrans script:\n" << scriptmsg;
+ historylog.comment( msg, true /*timestamp*/);
}
}
}
historylog.comment( msg, true /*timestamp*/);
- JobReport::warning( msg );
+ _myJobReport.warning( msg );
_scripts.clear();
}
Pathname _root;
std::list< std::pair< std::string, std::string > > _scripts;
boost::scoped_ptr<filesystem::TmpDir> _ptrTmpdir;
+
+ UserDataJobReport _myJobReport; ///< JobReport with ContentType "cmdout/%posttrans"
};
/** \relates RpmPostTransCollector::Impl Stream output */
#include <zypp/base/Gettext.h>
#include <zypp/base/IOStream.h>
#include <zypp/base/Functional.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/base/Json.h>
#include <zypp/ZConfig.h>
// include the error codes from zypp-rpm
#include "tools/zypp-rpm/errorcodes.h"
+#include <rpm/rpmlog.h>
#include <optional>
/** Execute script and report against report_r.
* Return \c std::pair<bool,PatchScriptReport::Action> to indicate if
- * execution was successfull (<tt>first = true</tt>), or the desired
+ * execution was successful (<tt>first = true</tt>), or the desired
* \c PatchScriptReport::Action in case execution failed
* (<tt>first = false</tt>).
*
}
else
{
- DBG << "dryRun: Not stroring non-package data." << endl;
+ DBG << "dryRun: Not storing non-package data." << endl;
}
///////////////////////////////////////////////////////////////////
}
}
+
+ ///////////////////////////////////////////////////////////////////
+ /// \brief Convenience SendReport<rpm::SingleTransReport> wrapper.
+ ///
+ /// Provide convenience methods to invoke a generic \ref report
+ /// supplied with the proper \ref UserData and \ref ContentType,
+ ///////////////////////////////////////////////////////////////////
+ struct SendSingleTransReport : public callback::SendReport<rpm::SingleTransReport>
+ {
+ /** Convenience to send a \ref contentLogline. */
+ void sendLogline( const std::string & line_r, ReportType::loglevel level_r = ReportType::loglevel::msg )
+ {
+ callback::UserData data { ReportType::contentLogline };
+ data.set( "line", std::cref(line_r) );
+ data.set( "level", level_r );
+ report( data );
+ }
+ /** Convenience to send a \ref contentLogline translating a rpm loglevel. */
+ void sendLoglineRpm( const std::string & line_r, unsigned rpmlevel_r )
+ {
+ auto u2rpmlevel = []( unsigned rpmlevel_r ) -> ReportType::loglevel {
+ switch ( rpmlevel_r ) {
+ case RPMLOG_EMERG: [[fallthrough]]; // system is unusable
+ case RPMLOG_ALERT: [[fallthrough]]; // action must be taken immediately
+ case RPMLOG_CRIT: // critical conditions
+ return ReportType::loglevel::crt;
+ case RPMLOG_ERR: // error conditions
+ return ReportType::loglevel::err;
+ case RPMLOG_WARNING: // warning conditions
+ return ReportType::loglevel::war;
+ default: [[fallthrough]];
+ case RPMLOG_NOTICE: [[fallthrough]]; // normal but significant condition
+ case RPMLOG_INFO: // informational
+ return ReportType::loglevel::msg;
+ case RPMLOG_DEBUG:
+ return ReportType::loglevel::dbg;
+ }
+ };
+ sendLogline( line_r, u2rpmlevel( rpmlevel_r ) );
+ }
+
+ private:
+ void report( const callback::UserData & userData_r )
+ { (*this)->report( userData_r ); }
+ };
+
+ const callback::UserData::ContentType rpm::SingleTransReport::contentLogline { "zypp-rpm", "logline" };
+
const callback::UserData::ContentType rpm::InstallResolvableReportSA::contentRpmout( "zypp-rpm","installpkgsa" );
const callback::UserData::ContentType rpm::RemoveResolvableReportSA::contentRpmout( "zypp-rpm","removepkgsa" );
const callback::UserData::ContentType rpm::CommitScriptReportSA::contentRpmout( "zypp-rpm","scriptsa" );
void TargetImpl::commitInSingleTransaction(const ZYppCommitPolicy &policy_r, CommitPackageCache &packageCache_r, ZYppCommitResult &result_r)
{
namespace zpt = zypp::proto::target;
+
+ SendSingleTransReport report; // active throughout the whole rpm transaction
+
// steps: this is our todo-list
ZYppCommitResult::TransactionStepList & steps( result_r.rTransactionStepList() );
MIL << "TargetImpl::commit(<list>" << policy_r << ")" << steps.size() << endl;
bool abort = false;
zypp::AutoDispose<std::unordered_map<int, ManagedFile>> locCache([]( std::unordered_map<int, ManagedFile> &data ){
- for ( auto &[key, value] : data ) {
+ for ( auto &[_, value] : data ) {
+ (void)_; // unsused; for older g++ versions
value.resetDispose();
}
data.clear();
} else if ( cleanupreport ) {
sendLogRep( (*cleanupreport), rpm::CleanupPackageReportSA::contentRpmout );
} else {
- WAR << "Got rpm output without active report " << line << std::endl;
+ WAR << "Got rpm output without active report " << line; // no endl! - readLine does not trim
}
// remember rpm output
std::string l = scriptSource->readLine().asString();
if( str::endsWith( l, endOfScriptTag ) ) {
- DBG << "Received end of script tag" << std::endl;
gotEndOfScript = true;
- l = l.substr( 0, l.size() - endOfScriptTag.size() );
- if ( l.size() == 0 )
+ std::string::size_type rawsize { l.size() - endOfScriptTag.size() };
+ if ( not rawsize )
return;
+ l = l.substr( 0, rawsize );
}
-
+ L_DBG("zypp-rpm") << "[rpm> " << l; // no endl! - readLine does not trim
sendRpmLineToReport( l );
}
};
assert(false);
}
- DBG << "Starting new report, setting gotEndOfScript to false" << std::endl;
gotEndOfScript = false;
};
( *cleanupreport)->progress( 100 );
( *cleanupreport)->finish( rpm::CleanupPackageReportSA::NO_ERROR );
}
- DBG << "Report finalized" << std::endl;
currentStepId = -1;
lineno = 0;
rpmmsg.clear();
// read the stdout and forward it to our log
prog->stdoutDevice()->connectFunc( &zyppng::IODevice::sigReadyRead, [&](){
while( prog->stdoutDevice()->canReadLine() ) {
- MIL << "zypp-rpm stdout: " << prog->stdoutDevice()->readLine().asStringView() << std::endl;
+ L_DBG("zypp-rpm") << "<stdout> " << prog->stdoutDevice()->readLine().asStringView(); // no endl! - readLine does not trim
}
});
// read the stderr and forward it to our log
prog->stderrDevice()->connectFunc( &zyppng::IODevice::sigReadyRead, [&](){
while( prog->stderrDevice()->canReadLine() ) {
- MIL << "zypp-rpm stderr: " << prog->stderrDevice()->readLine().asStringView() << std::endl;
+ L_ERR("zypp-rpm") << "<stderr> " << prog->stderrDevice()->readLine().asStringView(); // no endl! - readLine does not trim
}
});
ERR << "Failed to parse " << m.messagetypename() << " message from zypp-rpm." << std::endl;
continue;
}
-
- sendRpmLineToReport( p.line() );
-
+ ( p.level() >= RPMLOG_ERR ? L_ERR("zypp-rpm")
+ : p.level() >= RPMLOG_WARNING ? L_WAR("zypp-rpm")
+ : L_DBG("zypp-rpm") ) << "[rpm " << p.level() << "> " << p.line(); // no endl! - readLine does not trim
+ report.sendLoglineRpm( p.line(), p.level() );
} else if ( mName == "zypp.proto.target.PackageBegin" ) {
finalizeCurrentReport();
} else if ( mName == "zypp.proto.target.ScriptFinished" ) {
// we just read the message, we do not act on it because a ScriptError is reported after ScriptFinished
- MIL << "Received" << mName << " from zypp-rpm" << std::endl;
} else if ( mName == "zypp.proto.target.ScriptError" ) {
#include <zypp/base/LogTools.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/Exception.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
#include <zypp/sat/Queue.h>
#include <zypp/sat/FileConflicts.h>
#include <zypp/base/LogTools.h>
#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
#include <zypp/AutoDispose.h>
#include <zypp/PathInfo.h>
return lst_r.set( headerget.val(), headerget.cnt(), headerget.type() );
default:
- INT << "RPM_TAG MISSMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
+ INT << "RPM_TAG MISMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
}
}
}
return lst_r.set( (char**)headerget.val(), headerget.cnt() );
default:
- INT << "RPM_TAG MISSMATCH: RPM_STRING_ARRAY_TYPE " << tag_r << " got type " << headerget.type() << endl;
+ INT << "RPM_TAG MISMATCH: RPM_STRING_ARRAY_TYPE " << tag_r << " got type " << headerget.type() << endl;
}
}
}
#endif
default:
- INT << "RPM_TAG MISSMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
+ INT << "RPM_TAG MISMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
}
}
}
return (char*)headerget.val();
default:
- INT << "RPM_TAG MISSMATCH: RPM_STRING_TYPE " << tag_r << " got type " << headerget.type() << endl;
+ INT << "RPM_TAG MISMATCH: RPM_STRING_TYPE " << tag_r << " got type " << headerget.type() << endl;
}
}
}
#include <zypp/base/String.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/LocaleGuard.h>
-#include <zypp/base/DtorReset.h>
+#include <zypp-core/base/DtorReset>
#include <zypp/Date.h>
#include <zypp/Pathname.h>
#include <zypp/PathInfo.h>
#include <zypp/PublicKey.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
#include <zypp/target/rpm/RpmDb.h>
#include <zypp/target/rpm/RpmCallbacks.h>
cmdout.set( "lineno", lineno );
// LEGACY: collect and forward additional rpm output in finish
- std::string rpmmsg; // TODO: immediately forward lines via Callback::report rather than collecting
+ std::string rpmmsg;
std::vector<std::string> configwarnings; // TODO: immediately process lines rather than collecting
while ( systemReadLine( line ) )
sstr << "rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
// TranslatorExplanation the colon is followed by an error message
- ZYPP_THROW(RpmSubprocessException(_("RPM failed: ") + (rpmmsg.empty() ? error_message : rpmmsg) ));
+ auto excpt { RpmSubprocessException(_("RPM failed: ") + error_message ) };
+ if ( not rpmmsg.empty() )
+ excpt.addHistory( rpmmsg );
+ ZYPP_THROW(std::move(excpt));
}
else if ( ! rpmmsg.empty() )
{
sstr << "Additional rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
- // report additional rpm output in finish
+ // report additional rpm output in finish (LEGACY! Lines are immediately reported as InstallResolvableReport::contentRpmout)
// TranslatorExplanation Text is followed by a ':' and the actual output.
report->finishInfo(str::form( "%s:\n%s\n", _("Additional rpm output"), rpmmsg.c_str() ));
}
// LEGACY: collect and forward additional rpm output in finish
- std::string rpmmsg; // TODO: immediately forward lines via Callback::report rather than collecting
+ std::string rpmmsg;
// got no progress from command, so we fake it:
// 5 - command started
sstr << "rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
// TranslatorExplanation the colon is followed by an error message
- ZYPP_THROW(RpmSubprocessException(_("RPM failed: ") + (rpmmsg.empty() ? error_message: rpmmsg) ));
+ auto excpt { RpmSubprocessException(_("RPM failed: ") + error_message ) };
+ if ( not rpmmsg.empty() )
+ excpt.addHistory( rpmmsg );
+ ZYPP_THROW(std::move(excpt));
}
else if ( ! rpmmsg.empty() )
{
sstr << "Additional rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
- // report additional rpm output in finish
+ // report additional rpm output in finish (LEGACY! Lines are immediately reported as RemoveResolvableReport::contentRpmout)
// TranslatorExplanation Text is followed by a ':' and the actual output.
report->finishInfo(str::form( "%s:\n%s\n", _("Additional rpm output"), rpmmsg.c_str() ));
}
SET( zyppng_media_SRCS
media/medianetwork.cc
media/medianetworkserver.cc
- media/network/downloader.cc
- media/network/downloadspec.cc
- media/network/mirrorcontrol.cc
- media/network/networkrequestdispatcher.cc
- media/network/networkrequesterror.cc
- media/network/request.cc
)
SET( zyppng_media_HEADERS
media/MediaNetwork
media/medianetwork.h
- media/network/AuthData
- media/network/authdata.h
- media/network/downloader.h
- media/network/downloadspec.h
- media/network/networkrequestdispatcher.h
- media/network/networkrequesterror.h
- media/network/request.h
- media/network/transfersettings.h
- media/network/TransferSettings
)
SET( zyppng_media_private_HEADERS
media/private/medianetworkserver_p.h
- media/network/private/downloader_p.h
- media/network/private/mediadebug_p.h
- media/network/private/mirrorcontrol_p.h
- media/network/private/networkrequestdispatcher_p.h
- media/network/private/networkrequesterror_p.h
- media/network/private/request_p.h
- media/network/private/downloaderstates/base_p.h
- media/network/private/downloaderstates/basicdownloader_p.h
- media/network/private/downloaderstates/detectmeta_p.h
- media/network/private/downloaderstates/final_p.h
- media/network/private/downloaderstates/initial_p.h
- media/network/private/downloaderstates/metalinkinfo_p.h
- media/network/private/downloaderstates/metalink_p.h
- media/network/private/downloaderstates/mirrorhandling_p.h
- media/network/private/downloaderstates/normal_p.h
- media/network/private/downloaderstates/preparemulti_p.h
- media/network/private/downloaderstates/rangedownloader_p.h
- media/network/private/downloaderstates/zck_p.h
)
SET( zyppng_media_private_SOURCES
- media/network/private/downloaderstates/basicdownloader_p.cc
- media/network/private/downloaderstates/detectmeta_p.cc
- media/network/private/downloaderstates/final_p.cc
- media/network/private/downloaderstates/initial_p.cc
- media/network/private/downloaderstates/metalinkinfo_p.cc
- media/network/private/downloaderstates/metalink_p.cc
- media/network/private/downloaderstates/mirrorhandling_p.cc
- media/network/private/downloaderstates/normal_p.cc
- media/network/private/downloaderstates/preparemulti_p.cc
- media/network/private/downloaderstates/rangedownloader_p.cc
- media/network/private/downloaderstates/zck_p.cc
)
SET( zyppng_appcode_HEADERS
#include "context.h"
#include <zypp-core/zyppng/base/EventLoop>
-#include <zypp/zyppng/media/network/private/mirrorcontrol_p.h>
+#include <zypp-curl/ng/network/private/mirrorcontrol_p.h>
namespace zyppng {
#include "medianetwork.h"
#include "private/medianetworkserver_p.h"
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
#include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
#include <zypp-core/zyppng/base/EventLoop>
#include <zypp-core/zyppng/base/AutoDisconnect>
#include <zypp-core/zyppng/io/SockAddr>
-#include <zypp/zyppng/media/network/downloadspec.h>
+#include <zypp-curl/ng/network/DownloadSpec>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/AuthData>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/NetworkRequestDispatcher>
+#include <zypp-curl/ng/network/NetworkRequestError>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
#include <zypp-core/zyppng/base/EventDispatcher>
#include <zypp-core/zyppng/base/AbstractEventSource>
#include <zypp-core/zyppng/rpc/rpc.h>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/MediaException.h>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-media/MediaException>
+#include <zypp-media/auth/CredentialManager>
#include <zypp/ZConfig.h>
#include <zypp/ZYppCallbacks.h>
#include <zypp/base/String.h>
#include <zypp/media/MediaNetworkCommonHandler.h>
#include <zypp-core/zyppng/core/Url>
-#include <zypp/zyppng/media/network/AuthData>
+#include <zypp-curl/ng/network/AuthData>
#include <zypp-proto/envelope.pb.h>
#include <zypp-proto/messages.pb.h>
#include <zypp-core/zyppng/io/private/iobuffer_p.h>
| |
----------------------------------------------------------------------*/
#include "private/medianetworkserver_p.h"
-#include <zypp/zyppng/media/network/downloader.h>
-#include <zypp/zyppng/media/network/downloadspec.h>
-#include <zypp/zyppng/media/network/private/mirrorcontrol_p.h>
+#include <zypp-curl/ng/network/Downloader>
+#include <zypp-curl/ng/network/DownloadSpec>
+#include <zypp-curl/ng/network/private/mirrorcontrol_p.h>
#include <zypp-core/zyppng/base/private/threaddata_p.h>
#include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
#include <zypp-core/zyppng/base/EventLoop>
#include <zypp-core/zyppng/base/SocketNotifier>
#include <zypp-core/zyppng/rpc/rpc.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
#include <zypp/PathInfo.h>
#include <zypp-proto/envelope.pb.h>
#include <zypp-proto/messages.pb.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp/Target.h>
+#include <zypp/ZConfig.h>
#include <algorithm>
#include <csignal>
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::MediaNetworkServer"
+namespace internal {
+ /**
+ * initialized only once, this gets the agent string
+ * which also includes the curl version
+ *
+ * Defined in MediaCurl.cc
+ */
+ const char * agentString();
+}
+
namespace zyppng {
using HeaderSizeType = zyppng::rpc::HeaderSizeType;
MediaNetworkServer::MediaNetworkServer( )
: _downloadManager( std::make_shared<Downloader>( MirrorControl::create() ) )
{
+ _downloadManager->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
+ auto dispatcher = _downloadManager->requestDispatcher();
+ if ( dispatcher ) {
+ dispatcher->setAgentString( ::internal::agentString() );
+ dispatcher->setHostSpecificHeader("download.opensuse.org", "X-ZYpp-AnonymousId", zypp::Target::anonymousUniqueId( zypp::Pathname()/*guess root*/ ) );
+ dispatcher->setHostSpecificHeader("download.opensuse.org", "X-ZYpp-DistributionFlavor", zypp::Target::distributionFlavor( zypp::Pathname()/*guess root*/ ) );
+ } else {
+ // this branch should never be executed
+ ERR << "Unable to initialize user agent string and zypp http headers." << std::endl;
+ }
}
void MediaNetworkServer::listen( const std::string &sockPath )