From 0aa8a3d563bde26baf2db4b87b1e9bf13f09972b Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 5 Nov 2019 14:39:49 -0500 Subject: [PATCH] import librepo-1.10.3-3.el8 --- .gitignore | 1 + .librepo.metadata | 1 + ...-support-ranges-when-downloading-zck.patch | 124 +++++++ ...only-with-zchunk-RhBug17261411719830.patch | 28 ++ ...ification-of-checksum-from-file-attr.patch | 45 +++ SPECS/librepo.spec | 323 ++++++++++++++++++ 6 files changed, 522 insertions(+) create mode 100644 .gitignore create mode 100644 .librepo.metadata create mode 100644 SOURCES/0001-Handle-webservers-that-dont-support-ranges-when-downloading-zck.patch create mode 100644 SOURCES/0002-Define-LRO_SUPPORTS_CACHEDIR-only-with-zchunk-RhBug17261411719830.patch create mode 100644 SOURCES/0003-Fix-Verification-of-checksum-from-file-attr.patch create mode 100644 SPECS/librepo.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..920eefa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/librepo-1.10.3.tar.gz diff --git a/.librepo.metadata b/.librepo.metadata new file mode 100644 index 0000000..62ec408 --- /dev/null +++ b/.librepo.metadata @@ -0,0 +1 @@ +0f55637ac71b2f72f9ecd243ee3c220f6402f4af SOURCES/librepo-1.10.3.tar.gz diff --git a/SOURCES/0001-Handle-webservers-that-dont-support-ranges-when-downloading-zck.patch b/SOURCES/0001-Handle-webservers-that-dont-support-ranges-when-downloading-zck.patch new file mode 100644 index 0000000..f528c6b --- /dev/null +++ b/SOURCES/0001-Handle-webservers-that-dont-support-ranges-when-downloading-zck.patch @@ -0,0 +1,124 @@ +From 614d7874bfa82cb19b328278590af0f99e1ec682 Mon Sep 17 00:00:00 2001 +From: Jonathan Dieter +Date: Fri, 14 Jun 2019 23:13:30 +0100 +Subject: [PATCH] Handle webservers that don't support ranges when downloading zck + +Make sure we fall back to downloading full zchunk file if a webserver +doesn't support ranges. + +Signed-off-by: Jonathan Dieter +--- + librepo/downloader.c | 37 ++++++++++++++++++++++++++----------- + librepo/downloadtarget.c | 1 + + librepo/downloadtarget.h | 4 ++++ + 3 files changed, 31 insertions(+), 11 deletions(-) + +diff --git a/librepo/downloader.c b/librepo/downloader.c +index 6189681..53161f7 100644 +--- a/librepo/downloader.c ++++ b/librepo/downloader.c +@@ -473,7 +473,7 @@ lr_headercb(void *ptr, size_t size, size_t nmemb, void *userdata) + } + + #ifdef WITH_ZCHUNK +- if(lrtarget->target->is_zchunk) ++ if(lrtarget->target->is_zchunk && lrtarget->mirror->max_ranges > 0) + return lr_zckheadercb(ptr, size, nmemb, userdata); + #endif /* WITH_ZCHUNK */ + +@@ -586,7 +586,7 @@ lr_writecb(char *ptr, size_t size, size_t nmemb, void *userdata) + size_t cur_written; + LrTarget *target = (LrTarget *) userdata; + #ifdef WITH_ZCHUNK +- if(target->target->is_zchunk) ++ if(target->target->is_zchunk && target->mirror->max_ranges > 0) + return lr_zck_writecb(ptr, size, nmemb, userdata); + #endif /* WITH_ZCHUNK */ + +@@ -1240,6 +1240,12 @@ check_zck(LrTarget *target, GError **err) + assert(!err || *err == NULL); + assert(target && target->f && target->target); + ++ if(target->mirror->max_ranges == 0) { ++ target->zck_state = LR_ZCK_DL_BODY; ++ target->target->expectedsize = target->target->origsize; ++ return TRUE; ++ } ++ + if(target->target->zck_dl == NULL) { + target->target->zck_dl = zck_dl_init(NULL); + if(target->target->zck_dl == NULL) { +@@ -2166,25 +2172,34 @@ check_transfer_statuses(LrDownload *dd, GError **err) + if (target->target->is_zchunk) { + zckCtx *zck = NULL; + if (target->zck_state == LR_ZCK_DL_HEADER) { +- if(!lr_zck_valid_header(target->target, target->target->path, ++ if(target->mirror->max_ranges > 0 && ++ !lr_zck_valid_header(target->target, target->target->path, + fd, &transfer_err)) + goto transfer_error; + } else if(target->zck_state == LR_ZCK_DL_BODY) { +- zckCtx *zck = zck_dl_get_zck(target->target->zck_dl); +- if(zck == NULL) { +- g_set_error(&transfer_err, LR_DOWNLOADER_ERROR, LRE_ZCK, +- "Unable to get zchunk file from download context"); +- goto transfer_error; ++ if(target->mirror->max_ranges > 0) { ++ zckCtx *zck = zck_dl_get_zck(target->target->zck_dl); ++ if(zck == NULL) { ++ g_set_error(&transfer_err, LR_DOWNLOADER_ERROR, LRE_ZCK, ++ "Unable to get zchunk file from download context"); ++ goto transfer_error; ++ } ++ if(zck_failed_chunks(zck) == 0 && zck_missing_chunks(zck) == 0) ++ target->zck_state = LR_ZCK_DL_FINISHED; ++ } else { ++ if(target->range_fail) { ++ target->range_fail = FALSE; ++ } else { ++ target->zck_state = LR_ZCK_DL_FINISHED; ++ } + } +- if(zck_failed_chunks(zck) == 0 && zck_missing_chunks(zck) == 0) +- target->zck_state = LR_ZCK_DL_FINISHED; + } + if(target->zck_state == LR_ZCK_DL_FINISHED) { + zck = lr_zck_init_read(target->target, target->target->path, fd, + &transfer_err); + if(!zck) + goto transfer_error; +- if(!zck_validate_checksums(zck)) { ++ if(zck_validate_checksums(zck) < 1) { + zck_free(&zck); + g_set_error(&transfer_err, LR_DOWNLOADER_ERROR, LRE_BADCHECKSUM, + "At least one of the zchunk checksums doesn't match in %s", +diff --git a/librepo/downloadtarget.c b/librepo/downloadtarget.c +index d20aa44..40c10f3 100644 +--- a/librepo/downloadtarget.c ++++ b/librepo/downloadtarget.c +@@ -100,6 +100,7 @@ lr_downloadtarget_new(LrHandle *handle, + target->fn = lr_string_chunk_insert(target->chunk, fn); + target->checksums = possiblechecksums; + target->expectedsize = expectedsize; ++ target->origsize = expectedsize; + target->resume = resume; + target->progresscb = progresscb; + target->cbdata = cbdata; +diff --git a/librepo/downloadtarget.h b/librepo/downloadtarget.h +index f4c1f26..c935219 100644 +--- a/librepo/downloadtarget.h ++++ b/librepo/downloadtarget.h +@@ -88,6 +88,10 @@ typedef struct { + gint64 expectedsize; /*!< + Expected size of the target */ + ++ gint64 origsize; /*!< ++ Original expected size of the target. Sometimes expectedsize will ++ change, especially if zchunk is in use, but this will never change */ ++ + gboolean resume; /*!< + Resume: + 0 - no resume, download whole file, +-- +libgit2 0.28.2 + diff --git a/SOURCES/0002-Define-LRO_SUPPORTS_CACHEDIR-only-with-zchunk-RhBug17261411719830.patch b/SOURCES/0002-Define-LRO_SUPPORTS_CACHEDIR-only-with-zchunk-RhBug17261411719830.patch new file mode 100644 index 0000000..97b933d --- /dev/null +++ b/SOURCES/0002-Define-LRO_SUPPORTS_CACHEDIR-only-with-zchunk-RhBug17261411719830.patch @@ -0,0 +1,28 @@ +From ab99b7c51f18eb5e11b4350024f05f9c5b3795e6 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek +Date: Tue, 2 Jul 2019 18:32:38 +0200 +Subject: [PATCH] Define LRO_SUPPORTS_CACHEDIR only with zchunk (RhBug:1726141,1719830) + +--- + librepo/handle.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/librepo/handle.h b/librepo/handle.h +index 48fdac6..96ac027 100644 +--- a/librepo/handle.h ++++ b/librepo/handle.h +@@ -37,9 +37,11 @@ G_BEGIN_DECLS + */ + typedef struct _LrHandle LrHandle; + ++#ifdef WITH_ZCHUNK + /** Define LRO_SUPPORTS_CACHEDIR so clients can check for this feature at build + * time */ + #define LRO_SUPPORTS_CACHEDIR ++#endif /* WITH_ZCHUNK */ + + /** LRO_FASTESTMIRRORMAXAGE default value */ + #define LRO_FASTESTMIRRORMAXAGE_DEFAULT 2592000L // 30 days +-- +libgit2 0.27.8 + diff --git a/SOURCES/0003-Fix-Verification-of-checksum-from-file-attr.patch b/SOURCES/0003-Fix-Verification-of-checksum-from-file-attr.patch new file mode 100644 index 0000000..fb9fefa --- /dev/null +++ b/SOURCES/0003-Fix-Verification-of-checksum-from-file-attr.patch @@ -0,0 +1,45 @@ +From 54e905450e53ed9b21a4737a41a4550958570067 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Thu, 5 Sep 2019 13:36:41 +0200 +Subject: [PATCH] Fix: Verification of checksum from file attr + +Related to https://bugzilla.redhat.com/show_bug.cgi?id=1700341 + +File copy could result in change in file attributes where +null-terminators are stripped out. The new code does not relly on it. +--- + librepo/checksum.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/librepo/checksum.c b/librepo/checksum.c +index 006a7fc..5d164eb 100644 +--- a/librepo/checksum.c ++++ b/librepo/checksum.c +@@ -221,18 +221,20 @@ lr_checksum_fd_compare(LrChecksumType type, + // Load cached checksum if enabled and used + struct stat st; + if (fstat(fd, &st) == 0) { +- ssize_t attr_ret; + _cleanup_free_ gchar *key = NULL; + char buf[256]; + + key = g_strdup_printf("user.Zif.MdChecksum[%llu]", + (unsigned long long) st.st_mtime); +- attr_ret = fgetxattr(fd, key, &buf, 256); +- if (attr_ret != -1) { ++ ssize_t attr_size = fgetxattr(fd, key, &buf, sizeof(buf)); ++ if (attr_size != -1) { + // Cached checksum found + g_debug("%s: Using checksum cached in xattr: [%s] %s", + __func__, key, buf); +- *matches = strcmp(expected, buf) ? FALSE : TRUE; ++ size_t expected_len = strlen(expected); ++ // xattr may contain null terminator (+1 byte) ++ *matches = (attr_size == expected_len || attr_size == expected_len + 1) && ++ memcmp(expected, buf, attr_size) == 0; + return TRUE; + } + } +-- +2.21.0 + diff --git a/SPECS/librepo.spec b/SPECS/librepo.spec new file mode 100644 index 0000000..c8a789d --- /dev/null +++ b/SPECS/librepo.spec @@ -0,0 +1,323 @@ +%global libcurl_version 7.28.0 + +%if 0%{?rhel} && 0%{?rhel} <= 7 +# Do not build bindings for python3 for RHEL <= 7 +%bcond_with python3 +# python-flask is not in RHEL7 +%bcond_with pythontests +%else +%bcond_without python3 +%bcond_without pythontests +%endif + +%if 0%{?rhel} > 7 || 0%{?fedora} > 29 +# Do not build bindings for python2 for RHEL > 7 and Fedora > 29 +%bcond_with python2 +%else +%bcond_without python2 +%endif + +%if 0%{?rhel} +%bcond_with zchunk +%else +%bcond_without zchunk +%endif + +%global dnf_conflict 2.8.8 + +Name: librepo +Version: 1.10.3 +Release: 3%{?dist} +Summary: Repodata downloading library + +License: LGPLv2+ +URL: https://github.com/rpm-software-management/librepo +Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Handle-webservers-that-dont-support-ranges-when-downloading-zck.patch +Patch1: 0002-Define-LRO_SUPPORTS_CACHEDIR-only-with-zchunk-RhBug17261411719830.patch +Patch2: 0003-Fix-Verification-of-checksum-from-file-attr.patch + +BuildRequires: cmake +BuildRequires: gcc +BuildRequires: check-devel +BuildRequires: doxygen +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: gpgme-devel +BuildRequires: libattr-devel +BuildRequires: libcurl-devel >= %{libcurl_version} +BuildRequires: pkgconfig(libxml-2.0) +BuildRequires: pkgconfig(libcrypto) +BuildRequires: pkgconfig(openssl) +%if %{with zchunk} +BuildRequires: pkgconfig(zck) >= 0.9.11 +%endif +Requires: libcurl%{?_isa} >= %{libcurl_version} + +%description +A library providing C and Python (libcURL like) API to downloading repository +metadata. + +%package devel +Summary: Repodata downloading library +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +Development files for librepo. + +%if %{with python2} +%package -n python2-%{name} +Summary: Python bindings for the librepo library +%{?python_provide:%python_provide python2-%{name}} +%if 0%{?rhel} && 0%{?rhel} <= 7 +BuildRequires: python-sphinx +%else +BuildRequires: python2-sphinx +%endif +BuildRequires: python2-devel +%if %{with pythontests} +BuildRequires: python2-flask +BuildRequires: python2-nose +BuildRequires: python2-requests +%if (0%{?rhel} && 0%{?rhel} <= 7) +BuildRequires: pyxattr +BuildRequires: pygpgme +%else +BuildRequires: python2-pyxattr +BuildRequires: python2-gpg +%endif +%endif # with pythontests +Requires: %{name}%{?_isa} = %{version}-%{release} +Conflicts: python2-dnf < %{dnf_conflict} + +%description -n python2-%{name} +Python 2 bindings for the librepo library. +%endif + +%if %{with python3} +%package -n python3-%{name} +Summary: Python 3 bindings for the librepo library +%{?python_provide:%python_provide python3-%{name}} +BuildRequires: python3-devel +%if %{with pythontests} +BuildRequires: python3-gpg +BuildRequires: python3-flask +BuildRequires: python3-nose +BuildRequires: python3-pyxattr +BuildRequires: python3-requests +%endif +BuildRequires: python3-sphinx +Requires: %{name}%{?_isa} = %{version}-%{release} +# Obsoletes Fedora 27 package +Obsoletes: platform-python-%{name} < %{version}-%{release} +Conflicts: python3-dnf < %{dnf_conflict} + +%description -n python3-%{name} +Python 3 bindings for the librepo library. +%endif + +%prep +%autosetup -p1 + +mkdir build-py2 +mkdir build-py3 + +%build +%if %{with python2} +pushd build-py2 + %cmake -DPYTHON_DESIRED:FILEPATH=%{__python2} %{!?with_zchunk:-DWITH_ZCHUNK=OFF} -DENABLE_PYTHON_TESTS=%{?with_pythontests:ON}%{!?with_pythontests:OFF} .. + %make_build +popd +%endif + +%if %{with python3} +pushd build-py3 + %cmake -DPYTHON_DESIRED:FILEPATH=%{__python3} %{!?with_zchunk:-DWITH_ZCHUNK=OFF} -DENABLE_PYTHON_TESTS=%{?with_pythontests:ON}%{!?with_pythontests:OFF} .. + %make_build +popd +%endif + +%check +%if %{with python2} +pushd build-py2 + #ctest -VV + make ARGS="-V" test +popd +%endif + +%if %{with python3} +pushd build-py3 + #ctest -VV + make ARGS="-V" test +popd +%endif + +%install +%if %{with python2} +pushd build-py2 + %make_install +popd +%endif + +%if %{with python3} +pushd build-py3 + %make_install +popd +%endif + +%if 0%{?rhel} && 0%{?rhel} <= 7 +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig +%else +%ldconfig_scriptlets +%endif + +%files +%license COPYING +%doc README.md +%{_libdir}/%{name}.so.* + +%files devel +%{_libdir}/%{name}.so +%{_libdir}/pkgconfig/%{name}.pc +%{_includedir}/%{name}/ + +%if %{with python2} +%files -n python2-%{name} +%{python2_sitearch}/%{name}/ +%endif + +%if %{with python3} +%files -n python3-%{name} +%{python3_sitearch}/%{name}/ +%endif + +%changelog +* Fri Sep 06 2019 Marek Blaha - 1.10.3-3 +- Backport patch: Fix: Verification of checksum from file attr + +* Wed Jul 31 2019 Pavla Kratochvilova - 1.10.3-2 +- Backport patch: Define LRO_SUPPORTS_CACHEDIR only with zchunk (RhBug:1726141,1719830) + +* Tue Jun 11 2019 Pavla Kratochvilova - 1.10.3-1 +- Update to 1.10.3 +- Exit gpg-agent after repokey import (RhBug:1650266) + +* Mon May 13 2019 Pavla Kratochvilova - 1.10.1-1 +- Update to 1.10.1 +- Reduce download delays +- Add an option to preserve timestamps of the downloaded files (RhBug:1688537) +- Append the '?' part of repo URL after the path +- Fix memory leaks + +* Tue Sep 25 2018 Jaroslav Mracek - 1.9.2-1 +- Update to 1.9.2 +- Bug 1626495 - major performance regression with libcurl-7.61.1 + +* Mon Aug 13 2018 Daniel Mach - 1.9.1-1 +- Update to 1.9.1 + +* Fri Jul 13 2018 Fedora Release Engineering - 1.9.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Jun 29 2018 Jaroslav Mracek - 1.9.0-3 +- Rebuilt for Python 3.7 + +* Tue Jun 26 2018 Igor Gnatenko - 1.9.0-2 +- Fix ldconfig_scriptlets once more + +* Tue Jun 26 2018 Jaroslav Mracek - 1.9.0-1 +- Update to 1.9.0 + +* Mon Jun 18 2018 Miro Hrončok - 1.8.1-9 +- Rebuilt for Python 3.7 + +* Fri Jun 15 2018 Miro Hrončok - 1.8.1-8 +- Bootstrap for Python 3.7 + +* Thu Feb 08 2018 Igor Gnatenko - 1.8.1-7 +- Add if conditionals around pyxattr + +* Wed Feb 07 2018 Iryna Shcherbina - 1.8.1-6 +- Update Python 2 dependency declarations to new packaging standards + (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) + +* Wed Jan 31 2018 Igor Gnatenko - 1.8.1-5 +- Switch to %%ldconfig_scriptlets + +* Tue Nov 07 2017 Igor Gnatenko - 1.8.1-4 +- Use better Obsoletes for platform-python + +* Sat Nov 04 2017 Igor Gnatenko - 1.8.1-3 +- Fix typo in Obsoletes + +* Fri Nov 03 2017 Igor Gnatenko - 1.8.1-2 +- Remove platform-python subpackage + +* Fri Sep 15 2017 Igor Gnatenko - 1.8.1-1 +- Update to 1.8.1 + +* Fri Sep 01 2017 Igor Gnatenko - 1.8.0-2 +- Disable platform python on old releases + +* Wed Aug 23 2017 Igor Gnatenko - 1.8.0-1 +- Update to 1.8.0 + +* Fri Aug 18 2017 Tomas Orsava - 1.7.20-9 +- Added Patch 0 to fix a tearDown failure in the test suite + +* Thu Aug 10 2017 Petr Viktorin - 1.7.20-8 +- Add subpackage for platform-python (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack) + +* Thu Aug 03 2017 Fedora Release Engineering - 1.7.20-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.7.20-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.7.20-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue Dec 13 2016 Charalampos Stratakis - 1.7.20-4 +- Enable tests + +* Tue Dec 13 2016 Charalampos Stratakis - 1.7.20-3 +- Rebuild for Python 3.6 +- Disable tests for now + +* Sat Dec 10 2016 Igor Gnatenko - 1.7.20-2 +- Rebuild for gpgme 1.18 + +* Thu Aug 25 2016 Tomas Mlcoch - 1.7.20-1 +- Tests: Disable test_download_packages_with_resume_02 test +- Update build utils to match new fedora spec schema + +* Wed Aug 24 2016 Tomas Mlcoch - 1.7.19-1 +- Add yumrecord substitution mechanism (mluscon) +- Fix a memory leak in signature verification (cwalters) + +* Tue Aug 09 2016 Igor Gnatenko - 1.7.18-4 +- Add %%{?system_python_abi} +- Trim ton of changelog + +* Tue Jul 19 2016 Fedora Release Engineering - 1.7.18-3 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Thu Apr 07 2016 Igor Gnatenko - 1.7.18-2 +- Adopt to new packaging guidelines +- Cleanups in spec file + +* Fri Mar 4 2016 Tomas Mlcoch - 1.7.18-1 +- Add new option LRO_FTPUSEEPSV +- Update AUTHORS +- downloader prepare_next_transfer(): simplify long line +- downloader prepare_next_transfer(): add missing error check +- downloader prepare_next_transfer(): cleanup error path +- downloader prepare_next_transfer() - fix memory leak on error path (Alan Jenkins) +- handle: Don't use proxy cache for downloads of metalink/mirrorlist +- handle: Don't set CURLOPT_HTTPHEADER into curl handle immediately when specified +- downloader: Implement logic for no_cache param in LrDownloadTarget (RhBug: 1297762) +- Add no_cache param to LrDownloadTarget and lr_downloadtarget_new() +- New test: always try to download from the fastest mirror (Alexander Todorov) +- Doc: Fixed minor doc typo (Philippe Ombredanne) +- Doc: Other updates +- Doc: Update default values in doc to reflect reality