import librepo-1.14.0-6.el9

This commit is contained in:
CentOS Sources 2021-11-03 23:54:42 -04:00 committed by Stepan Oksanichenko
commit 27509ccdd5
7 changed files with 3648 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/librepo-1.14.0.tar.gz

1
.librepo.metadata Normal file
View File

@ -0,0 +1 @@
b09cf9ac3751e3c513e1c30a527d1a5e460853b7 SOURCES/librepo-1.14.0.tar.gz

View File

@ -0,0 +1,551 @@
From 8bba792da37142028f6b6e61137ec2988b5578ee Mon Sep 17 00:00:00 2001
From: Pavla Kratochvilova <pkratoch@redhat.com>
Date: Mon, 26 Apr 2021 09:42:15 +0200
Subject: [PATCH] Replace python3-flask with http.server in python tests
---
README.md | 1 -
librepo.spec | 1 -
tests/README.rst | 36 ++++++++++--------------------------
tests/python/tests/base.py | 24 ++++--------------------
tests/python/tests/servermock/server.py | 31 +++++++++----------------------
tests/python/tests/servermock/yum_mock/yum_mock.py | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------
tests/python/tests/test_yum_package_downloading.py | 9 +++------
tests/python/tests/test_yum_repo_downloading.py | 5 ++---
8 files changed, 175 insertions(+), 211 deletions(-)
diff --git a/README.md b/README.md
index ad6bc23..d9fb062 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,6 @@ Fedora/Ubuntu name
* openssl (http://www.openssl.org/) - openssl-devel/libssl-dev
* python (http://python.org/) - python3-devel/libpython3-dev
* **Test requires:** pygpgme (https://pypi.python.org/pypi/pygpgme/0.1) - python3-pygpgme/python3-gpgme
-* **Test requires:** python3-flask (http://flask.pocoo.org/) - python-flask/python-flask
* **Test requires:** python3-pyxattr (https://github.com/xattr/xattr) - python3-pyxattr/python3-pyxattr
### Build from your checkout dir:
diff --git a/librepo.spec b/librepo.spec
index 6db1fc2..ed90a84 100644
--- a/librepo.spec
+++ b/librepo.spec
@@ -51,7 +51,6 @@ Summary: Python 3 bindings for the librepo library
%{?python_provide:%python_provide python3-%{name}}
BuildRequires: python3-devel
BuildRequires: python3-gpg
-BuildRequires: python3-flask
BuildRequires: python3-pyxattr
BuildRequires: python3-requests
BuildRequires: python3-sphinx
diff --git a/tests/README.rst b/tests/README.rst
index ea55c87..f7e6d03 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -33,15 +33,13 @@ Files of C tests
* Test suites
-Python tests with Flask
-=======================
+Python tests http.server
+========================
-Some python tests use **Flask** python framework (http://flask.pocoo.org/)
+Some python tests use **http.server** python standard library
to simulate web server. The server is started automatically during that tests.
-*TestCases with Flask inherit from TestCaseWithApp class.*
-
-The Flask is then set as the app to the test case by 'application' class attribute.
+*TestCases with http.server inherit from TestCaseWithServer class.*
If you want to start server manually::
@@ -57,27 +55,13 @@ http://127.0.0.1:5000/yum/badgpg/static/01/repodata/repomd.xml.asc
etc..
-Modularity of tests with Flask
-------------------------------
-
-Flask tests are intended to be modular.
-
-Modularity is provided by use of http://flask.pocoo.org/docs/blueprints/
-Currently there is only one module (blueprint) for yum repo mocking
-in servermock/yum_mock.
-
-Repos for test with Flask
--------------------------
-
-Currently each module (blueprint) uses its own data (repositories,
-packages, ..).
+Repos for test with http.server
+-------------------------------
-E.g. for yum mocking module: servermock/yum_mock/static/
+All data (repositories, packages, ..) are in servermock/yum_mock/static/
-Configuration and globals for tests with Flask
-----------------------------------------------
+Configuration and globals for tests with http.server
+----------------------------------------------------
-Each module (blueprint) has its own configuration and globals which uses
-and provides to tests which use the module.
+Configuration and globals used by these tests are in servermock/yum_mock/config.py
-E.g. for yum mocking module: servermock/yum_mock/config.py
diff --git a/tests/python/tests/base.py b/tests/python/tests/base.py
index 1d01c9d..ecabbb5 100644
--- a/tests/python/tests/base.py
+++ b/tests/python/tests/base.py
@@ -5,7 +5,7 @@ import ctypes
import os.path
import requests
from multiprocessing import Process, Value
-from tests.servermock.server import app
+from tests.servermock.server import start_server
try:
import unittest2 as unittest
except ImportError:
@@ -53,39 +53,23 @@ class TestCase(unittest.TestCase):
pass
-class TestCaseWithApp(TestCase):
- application = NotImplemented
-
- @classmethod
- def setUpClass(cls):
- cls.server = Process(target=cls.application.run)
- cls.server.start()
- time.sleep(0.5)
-
- @classmethod
- def tearDownClass(cls):
- cls.server.terminate()
- cls.server.join()
-
-
def application(port):
"""Sometimes, the port is used, in that case, use different port"""
while True:
try:
port_val = port.value
- app._librepo_port = port_val # Store used port into Flask app
- app.run(port=port_val)
- except socket.error as e:
+ start_server(port=port_val)
+ except OSError as e:
if e.errno == 98:
# Address already in use
port.value += 1
continue
raise
break
-class TestCaseWithFlask(TestCase):
+class TestCaseWithServer(TestCase):
_TS_PORT = Value(ctypes.c_int, 5000)
MOCKURL = None
PORT = -1
diff --git a/tests/python/tests/servermock/server.py b/tests/python/tests/servermock/server.py
index 6d17a0a..37ddb64 100644
--- a/tests/python/tests/servermock/server.py
+++ b/tests/python/tests/servermock/server.py
@@ -1,42 +1,29 @@
-from flask import Flask
+from http.server import BaseHTTPRequestHandler, HTTPServer
from optparse import OptionParser
try:
- from yum_mock.yum_mock import yum_mock
+ from yum_mock.yum_mock import yum_mock_handler
except (ValueError, ImportError):
- from .yum_mock.yum_mock import yum_mock
+ from .yum_mock.yum_mock import yum_mock_handler
-app = Flask(__name__)
-#app.register_blueprint(working_repo)
-app.register_blueprint(yum_mock, url_prefix='/yum')
+def start_server(port, host="127.0.0.1", handler=None):
+ if handler is None:
+ handler = yum_mock_handler(port)
+ with HTTPServer((host, port), handler) as server:
+ server.serve_forever()
if __name__ == '__main__':
parser = OptionParser("%prog [options]")
parser.add_option(
- "-d", "--debug",
- action="store_true",
- )
- parser.add_option(
"-p", "--port",
default=5000,
type="int",
)
parser.add_option(
"-n", "--host",
default="127.0.0.1",
)
- parser.add_option(
- "--passthrough_errors",
- action="store_true",
- )
options, args = parser.parse_args()
- kwargs = {
- "threaded": True,
- "debug": options.debug,
- "port": options.port,
- "host": options.host,
- "passthrough_errors": options.passthrough_errors,
- }
+ start_server(options.port, options.host)
- app.run(**kwargs)
diff --git a/tests/python/tests/servermock/yum_mock/yum_mock.py b/tests/python/tests/servermock/yum_mock/yum_mock.py
index 826f7c8..dd5bda6 100644
--- a/tests/python/tests/servermock/yum_mock/yum_mock.py
+++ b/tests/python/tests/servermock/yum_mock/yum_mock.py
@@ -1,137 +1,152 @@
+import base64
+from http.server import BaseHTTPRequestHandler, HTTPServer
import os
-from flask import Blueprint, render_template, abort, send_file, request, Response
-from flask import current_app
-from functools import wraps
+import sys
from .config import AUTH_USER, AUTH_PASS
-yum_mock = Blueprint('yum_mock', __name__,
- template_folder='templates',
- static_folder='static')
-
-@yum_mock.route('/static/mirrorlist/<path:path>')
-def serve_mirrorlists_with_right_port(path):
- try:
- with yum_mock.open_resource('static/mirrorlist/'+path) as f:
- data = f.read()
- data = data.decode('utf-8')
- data = data.replace(":{PORT_PLACEHOLDER}", ":%d" % current_app._librepo_port)
- return data
- except IOError:
- # File probably doesn't exist or we can't read it
- abort(404)
-
-@yum_mock.route('/static/metalink/<path:path>')
-def serve_metalinks_with_right_port(path):
- try:
- with yum_mock.open_resource('static/metalink/'+path) as f:
- data = f.read()
- data = data.decode('utf-8')
- data = data.replace(":{PORT_PLACEHOLDER}", ":%d" % current_app._librepo_port)
- return data
- except IOError:
- # File probably doesn't exist or we can't read it
- abort(404)
-
-@yum_mock.route('/harm_checksum/<keyword>/<path:path>')
-def harm_checksum(keyword, path):
- """Append two newlines to content of a file (from the static dir) with
- specified keyword in the filename. If the filename doesn't contain
- the keyword, content of the file is returnen unchanged."""
-
- if "static/" not in path:
- # Support changing only files from static directory
- abort(400)
- path = path[path.find("static/"):]
-
- try:
- with yum_mock.open_resource(path) as f:
- data = f.read()
- if keyword in os.path.basename(path):
- return "%s\n\n" %data
- return data
- except IOError:
- # File probably doesn't exist or we can't read it
- abort(404)
-
-@yum_mock.route("/not_found/<keyword>/<path:path>")
-def not_found(keyword, path):
- """For each file containing keyword in the filename, http status
- code 404 will be returned"""
-
- if "static/" not in path:
- abort(400)
- path = path[path.find("static/"):]
-
- try:
- with yum_mock.open_resource(path) as f:
- data = f.read()
- if keyword in os.path.basename(path):
- abort(404)
- return data
- except IOError:
- # File probably doesn't exist or we can't read it
- abort(404)
-
-@yum_mock.route("/badurl/<path:path>")
-def badurl(path):
- """Just return 404 for each url with this prefix"""
- abort(404)
-
-@yum_mock.route("/badgpg/<path:path>")
-def badgpg(path):
- """Instead of <path>/repomd.xml.asc returns
- content of <path>/repomd.xml.asc.bad"""
- if "static/" not in path:
- abort(400)
- path = path[path.find("static/"):]
- if path.endswith("repomd.xml.asc"):
- path = path + ".bad"
-
- try:
- with yum_mock.open_resource(path) as f:
- return f.read()
- except IOError:
- # File probably doesn't exist or we can't read it
- abort(404)
-
-# Basic Auth
-
-def check_auth(username, password):
- """This function is called to check if a username /
- password combination is valid.
- """
- return username == AUTH_USER and password == AUTH_PASS
-
-def authenticate():
- """Sends a 401 response that enables basic auth"""
- return Response(
- 'Could not verify your access level for that URL.\n'
- 'You have to login with proper credentials', 401,
- {'WWW-Authenticate': 'Basic realm="Login Required"'})
-
-def requires_auth(f):
- @wraps(f)
- def decorated(*args, **kwargs):
- auth = request.authorization
- if not auth or not check_auth(auth.username, auth.password):
- return authenticate()
- return f(*args, **kwargs)
- return decorated
-
-@yum_mock.route("/auth_basic/<path:path>")
-@requires_auth
-def secret_repo_basic_auth(path):
- """Page secured with basic HTTP auth
- User: admin Password: secret"""
- if "static/" not in path:
- abort(400)
- path = path[path.find("static/"):]
-
- try:
- with yum_mock.open_resource(path) as f:
- data = f.read()
- return data
- except IOError:
- abort(404)
+
+def file_path(path):
+ return(os.path.join(os.path.dirname(os.path.abspath(__file__)), path))
+
+
+def yum_mock_handler(port):
+
+ class YumMockHandler(BaseHTTPRequestHandler):
+ _port = port
+
+ def return_bad_request(self):
+ self.send_response(400)
+ self.end_headers()
+
+ def return_not_found(self):
+ self.send_response(404)
+ self.end_headers()
+
+ def return_ok_with_message(self, message, content_type='text/html'):
+ if content_type == 'text/html':
+ message = bytes(message, 'utf8')
+ self.send_response(200)
+ self.send_header('Content-type', content_type)
+ self.send_header('Content-Length', str(len(message)))
+ self.end_headers()
+ self.wfile.write(message)
+
+ def parse_path(self, test_prefix='', keyword_expected=False):
+ path = self.path[len(test_prefix):]
+ if keyword_expected:
+ keyword, path = path.split('/', 1)
+ # Strip arguments
+ if '?' in path:
+ path = path[:path.find('?')]
+ if keyword_expected:
+ return keyword, path
+ return path
+
+ def serve_file(self, path, harm_keyword=None):
+ if "static/" not in path:
+ # Support changing only files from static directory
+ return self.return_bad_request()
+ path = path[path.find("static/"):]
+ try:
+ with open(file_path(path), 'rb') as f:
+ data = f.read()
+ if harm_keyword is not None and harm_keyword in os.path.basename(file_path(path)):
+ data += b"\n\n"
+ return self.return_ok_with_message(data, 'application/octet-stream')
+ except IOError:
+ # File probably doesn't exist or we can't read it
+ return self.return_not_found()
+
+ def authenticate(self):
+ """Sends a 401 response that enables basic auth"""
+ self.send_response(401)
+ self.send_header('Content-type', 'text/html')
+ self.send_header('WWW-Authenticate', 'Basic realm="Login Required')
+ self.end_headers()
+ message = (
+ 'Could not verify your access level for that URL.\n'
+ 'You have to login with proper credentials'
+ )
+ self.wfile.write(bytes(message, "utf8"))
+
+ def check_auth(self):
+ if self.headers.get('Authorization') is None:
+ return False
+ expected_authorization = 'Basic {}'.format(
+ base64.b64encode('{}:{}'.format(AUTH_USER, AUTH_PASS).encode()).decode()
+ )
+ if self.headers.get('Authorization') != expected_authorization:
+ return False
+ return True
+
+ def serve_mirrorlist_or_metalink_with_right_port(self):
+ path = self.parse_path()
+ if "static/" not in path:
+ return self.return_bad_request()
+ path = path[path.find("static/"):]
+ try:
+ with open(file_path(path), 'r') as f:
+ data = f.read()
+ data = data.replace(":{PORT_PLACEHOLDER}", ":%d" % self._port)
+ return self.return_ok_with_message(data)
+ except IOError:
+ # File probably doesn't exist or we can't read it
+ return self.return_not_found()
+
+ def serve_harm_checksum(self):
+ """Append two newlines to content of a file (from the static dir) with
+ specified keyword in the filename. If the filename doesn't contain
+ the keyword, content of the file is returnen unchanged."""
+ keyword, path = self.parse_path('/yum/harm_checksum/', keyword_expected=True)
+ self.serve_file(path, harm_keyword=keyword)
+
+ def serve_not_found(self):
+ """For each file containing keyword in the filename, http status
+ code 404 will be returned"""
+ keyword, path = self.parse_path('/yum/not_found/', keyword_expected=True)
+ if keyword in os.path.basename(file_path(path)):
+ return self.return_not_found()
+ self.serve_file(path)
+
+ def serve_badurl(self):
+ """Just return 404 for each url with this prefix"""
+ return self.return_not_found()
+
+ def serve_badgpg(self):
+ """Instead of <path>/repomd.xml.asc returns content of <path>/repomd.xml.asc.bad"""
+ path = self.parse_path('/yum/badgpg/')
+ if path.endswith("repomd.xml.asc"):
+ path += ".bad"
+ self.serve_file(path)
+
+ def serve_auth_basic(self):
+ """Page secured with basic HTTP auth; User: admin Password: secret"""
+ if not self.check_auth():
+ return self.authenticate()
+ path = self.parse_path('/yum/auth_basic/')
+ self.serve_file(path)
+
+ def serve_static(self):
+ path = self.parse_path()
+ self.serve_file(path)
+
+ def do_GET(self):
+ if self.path.startswith('/yum/static/mirrorlist/'):
+ return self.serve_mirrorlist_or_metalink_with_right_port()
+ if self.path.startswith('/yum/static/metalink/'):
+ return self.serve_mirrorlist_or_metalink_with_right_port()
+ if self.path.startswith('/yum/harm_checksum/'):
+ return self.serve_harm_checksum()
+ if self.path.startswith('/yum/not_found/'):
+ return self.serve_not_found()
+ if self.path.startswith('/badurl/'):
+ return self.serve_badurl()
+ if self.path.startswith('/yum/badgpg/'):
+ return self.serve_badgpg()
+ if self.path.startswith('/yum/auth_basic/'):
+ return self.serve_auth_basic()
+ return self.serve_static()
+
+ return YumMockHandler
diff --git a/tests/python/tests/test_yum_package_downloading.py b/tests/python/tests/test_yum_package_downloading.py
index 577a8ce..0364be0 100644
--- a/tests/python/tests/test_yum_package_downloading.py
+++ b/tests/python/tests/test_yum_package_downloading.py
@@ -9,11 +9,10 @@ import xattr
import tests.servermock.yum_mock.config as config
-from tests.base import TestCaseWithFlask
-from tests.servermock.server import app
+from tests.base import TestCaseWithServer
-class TestCaseYumPackageDownloading(TestCaseWithFlask):
+class TestCaseYumPackageDownloading(TestCaseWithServer):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix="librepotest-", dir="./")
@@ -163,9 +162,7 @@ class TestCaseYumPackageDownloading(TestCaseWithFlask):
pkg = os.path.join(self.tmpdir, config.PACKAGE_01_01)
self.assertTrue(os.path.isfile(pkg))
-class TestCaseYumPackagesDownloading(TestCaseWithFlask):
- application = app
-
+class TestCaseYumPackagesDownloading(TestCaseWithServer):
# @classmethod
# def setUpClass(cls):
# super(TestCaseYumPackageDownloading, cls).setUpClass()
diff --git a/tests/python/tests/test_yum_repo_downloading.py b/tests/python/tests/test_yum_repo_downloading.py
index 76b067c..4d56d1c 100644
--- a/tests/python/tests/test_yum_repo_downloading.py
+++ b/tests/python/tests/test_yum_repo_downloading.py
@@ -7,13 +7,12 @@ import unittest
import librepo
-from tests.base import Context, TestCaseWithFlask, TEST_DATA
-from tests.servermock.server import app
+from tests.base import Context, TestCaseWithServer, TEST_DATA
import tests.servermock.yum_mock.config as config
PUB_KEY = TEST_DATA+"/key.pub"
-class TestCaseYumRepoDownloading(TestCaseWithFlask):
+class TestCaseYumRepoDownloading(TestCaseWithServer):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix="librepotest-")
--
libgit2 1.0.1

View File

@ -0,0 +1,44 @@
From 33be80700bc594f34818ce697493c17e70430390 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 17 May 2021 08:50:25 +0200
Subject: [PATCH] Recover from fsync fail on read-only filesystem
(RhBug:1956361)
When `fsync` fails due to the file not supporting synchronization just log
the problem instead of failing the whole dnf run. This happens for
example with filesystems mounted read-only in which case there is no
point to `fsync` anyway.
Currently we also ignore return values from `FSETXATTR` which also fails
on read-only filesystem (so no checksum cache is set). This is fine however
since the checksum is recomputed when needed, dnf is just a bit slower.
https://bugzilla.redhat.com/show_bug.cgi?id=1956361
---
librepo/checksum.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/librepo/checksum.c b/librepo/checksum.c
index db37040..6bba53c 100644
--- a/librepo/checksum.c
+++ b/librepo/checksum.c
@@ -266,9 +266,13 @@ lr_checksum_fd_compare(LrChecksumType type,
*matches = (strcmp(expected, checksum)) ? FALSE : TRUE;
if (fsync(fd) != 0) {
- g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
- "fsync failed: %s", strerror(errno));
- return FALSE;
+ if (errno == EROFS || errno == EINVAL) {
+ g_debug("fsync failed: %s", strerror(errno));
+ } else {
+ g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
+ "fsync failed: %s", strerror(errno));
+ return FALSE;
+ }
}
if (caching && *matches && timestamp != -1) {
--
2.31.1

View File

@ -0,0 +1,268 @@
From fd9d39cf19084dd4244943a3b27ee0a33805f76d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 21 Jun 2021 15:04:51 +0200
Subject: [PATCH 1/2] Fix important covscan warnings
- covscan thinks we are leaking storage from `g_strndup` so be more
explicit that `g_strstrip` is in place.
---
librepo/downloader.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/librepo/downloader.c b/librepo/downloader.c
index c5278fbc..f4e8ba2a 100644
--- a/librepo/downloader.c
+++ b/librepo/downloader.c
@@ -494,7 +494,10 @@ lr_headercb(void *ptr, size_t size, size_t nmemb, void *userdata)
return lr_zckheadercb(ptr, size, nmemb, userdata);
#endif /* WITH_ZCHUNK */
- char *header = g_strstrip(g_strndup(ptr, size*nmemb));
+ char *header = g_strndup(ptr, size*nmemb);
+ // strips in place
+ g_strstrip(header);
+
gint64 expected = lrtarget->target->expectedsize;
if (state == LR_HCS_DEFAULT) {
From 5a9e9e99c64e2dc1d181fa14cf348c7f51611a7a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 21 Jun 2021 15:05:13 +0200
Subject: [PATCH 2/2] Fix covscan warnings
- remove unused code
- missing return value checks
- use mkstemp just like other tests
---
librepo/handle.c | 12 +++++++++---
tests/test_downloader.c | 40 ++++++++++++++++++++--------------------
tests/test_repoconf.c | 22 +++-------------------
3 files changed, 32 insertions(+), 42 deletions(-)
diff --git a/librepo/handle.c b/librepo/handle.c
index 8ac7234c..2c23ed09 100644
--- a/librepo/handle.c
+++ b/librepo/handle.c
@@ -628,7 +628,7 @@ lr_handle_setopt(LrHandle *handle,
"Value of LRO_LOWSPEEDTIME is too low.");
ret = FALSE;
} else {
- curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_TIME, val_long);
+ c_rc = curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_TIME, val_long);
handle->lowspeedtime = val_long;
}
@@ -648,7 +648,7 @@ lr_handle_setopt(LrHandle *handle,
val_long, handle->maxspeed);
ret = FALSE;
} else {
- curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_LIMIT, val_long);
+ c_rc = curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_LIMIT, val_long);
handle->lowspeedlimit = val_long;
}
@@ -885,7 +885,13 @@ lr_yum_download_url_retry(int attempts, LrHandle *lr_handle, const char *url,
g_debug("%s: Attempt #%d to download %s failed: %s",
__func__, i, url, (*err)->message);
- ftruncate(fd, 0);
+
+ if (ftruncate(fd, 0) < 0) {
+ g_set_error(err, LR_DOWNLOADER_ERROR, LRE_IO,
+ "ftruncate() failed: %s", g_strerror(errno));
+ return FALSE;
+ }
+
g_clear_error (err);
}
}
diff --git a/tests/test_downloader.c b/tests/test_downloader.c
index 3a1c60f4..e6155105 100644
--- a/tests/test_downloader.c
+++ b/tests/test_downloader.c
@@ -46,7 +46,7 @@ START_TEST(test_downloader_single_file)
fail_if(handle == NULL);
char *urls[] = {"http://www.google.com", NULL};
- lr_handle_setopt(handle, NULL, LRO_URLS, urls);
+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls));
lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err);
fail_if(tmp_err);
@@ -55,8 +55,7 @@ START_TEST(test_downloader_single_file)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_XXXXXX", NULL);
- mktemp(tmpfn1);
- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fd1 = mkstemp(tmpfn1);
lr_free(tmpfn1);
fail_if(fd1 < 0);
@@ -86,6 +85,7 @@ START_TEST(test_downloader_single_file)
}
g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free);
+ close(fd1);
}
END_TEST
@@ -102,8 +102,7 @@ START_TEST(test_downloader_single_file_2)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL);
- mktemp(tmpfn1);
- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fd1 = mkstemp(tmpfn1);
lr_free(tmpfn1);
fail_if(fd1 < 0);
@@ -131,6 +130,7 @@ START_TEST(test_downloader_single_file_2)
}
g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free);
+ close(fd1);
}
END_TEST
@@ -151,7 +151,7 @@ START_TEST(test_downloader_two_files)
fail_if(handle == NULL);
char *urls[] = {"http://www.google.com", NULL};
- lr_handle_setopt(handle, NULL, LRO_URLS, urls);
+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls));
lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err);
fail_if(tmp_err);
@@ -160,10 +160,8 @@ START_TEST(test_downloader_two_files)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_1_XXXXXX", NULL);
tmpfn2 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL);
- mktemp(tmpfn1);
- mktemp(tmpfn2);
- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666);
- fd2 = open(tmpfn2, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fd1 = mkstemp(tmpfn1);
+ fd2 = mkstemp(tmpfn2);
lr_free(tmpfn1);
lr_free(tmpfn2);
fail_if(fd1 < 0);
@@ -200,6 +198,8 @@ START_TEST(test_downloader_two_files)
}
g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free);
+ close(fd1);
+ close(fd2);
}
END_TEST
@@ -220,7 +220,7 @@ START_TEST(test_downloader_three_files_with_error)
fail_if(handle == NULL);
char *urls[] = {"http://www.google.com", NULL};
- lr_handle_setopt(handle, NULL, LRO_URLS, urls);
+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls));
lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err);
fail_if(tmp_err);
@@ -230,12 +230,9 @@ START_TEST(test_downloader_three_files_with_error)
tmpfn2 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL);
tmpfn3 = lr_pathconcat(test_globals.tmpdir, "single_file_3_XXXXXX", NULL);
- mktemp(tmpfn1);
- mktemp(tmpfn2);
- mktemp(tmpfn3);
- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666);
- fd2 = open(tmpfn2, O_RDWR|O_CREAT|O_TRUNC, 0666);
- fd3 = open(tmpfn3, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fd1 = mkstemp(tmpfn1);
+ fd2 = mkstemp(tmpfn2);
+ fd3 = mkstemp(tmpfn3);
lr_free(tmpfn1);
lr_free(tmpfn2);
lr_free(tmpfn3);
@@ -290,6 +287,9 @@ START_TEST(test_downloader_three_files_with_error)
}
g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free);
+ close(fd1);
+ close(fd2);
+ close(fd3);
}
END_TEST
@@ -331,7 +331,7 @@ START_TEST(test_downloader_checksum)
fail_if(handle == NULL);
char *urls[] = {"file:///", NULL};
- lr_handle_setopt(handle, NULL, LRO_URLS, urls);
+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls));
lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err);
fail_if(tmp_err);
@@ -340,8 +340,7 @@ START_TEST(test_downloader_checksum)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_XXXXXX", NULL);
- mktemp(tmpfn1);
- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fd1 = mkstemp(tmpfn1);
lr_free(tmpfn1);
fail_if(fd1 < 0);
@@ -382,6 +381,7 @@ START_TEST(test_downloader_checksum)
}
g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free);
+ close(fd1);
}
}
END_TEST
diff --git a/tests/test_repoconf.c b/tests/test_repoconf.c
index 8a56b666..5c85047e 100644
--- a/tests/test_repoconf.c
+++ b/tests/test_repoconf.c
@@ -33,22 +33,6 @@ repoconf_assert_true(LrYumRepoConf *repoconf,
#define conf_assert_true(option) \
repoconf_assert_true(conf, (option))
-static void
-repoconf_assert_false(LrYumRepoConf *repoconf,
- LrYumRepoConfOption option)
-{
- ck_assert(1);
- long val = 1L;
- _cleanup_error_free_ GError *tmp_err = NULL;
- gboolean ret = lr_yum_repoconf_getinfo(repoconf, &tmp_err, option, &val);
- ck_assert(!tmp_err);
- ck_assert(ret);
- ck_assert_msg(!val, "Not a 0 (False) value (Option %d)", option);
-}
-
-#define conf_assert_false(option) \
- repoconf_assert_false(conf, (option))
-
static void
repoconf_assert_na(LrYumRepoConf *repoconf,
LrYumRepoConfOption option)
@@ -509,7 +493,7 @@ END_TEST
START_TEST(test_write_repoconf)
{
- _cleanup_fd_close_ int rc = -1;
+ _cleanup_fd_close_ int fd = -1;
gboolean ret;
LrYumRepoConfs *confs;
LrYumRepoConf * conf;
@@ -519,8 +503,8 @@ START_TEST(test_write_repoconf)
_cleanup_error_free_ GError *tmp_err = NULL;
// Create a temporary file
- rc = mkstemp(tmpfn);
- fail_if(rc == -1);
+ fd = mkstemp(tmpfn);
+ fail_if(fd == -1);
// Create reconfs with one repoconf with one id (one section)
confs = lr_yum_repoconfs_init();

File diff suppressed because it is too large Load Diff

357
SPECS/librepo.spec Normal file
View File

@ -0,0 +1,357 @@
%global libcurl_version 7.52.0
%undefine __cmake_in_source_build
%if 0%{?rhel}
%bcond_with zchunk
%else
%bcond_without zchunk
%endif
%global dnf_conflict 2.8.8
Name: librepo
Version: 1.14.0
Release: 6%{?dist}
Summary: Repodata downloading library
License: LGPLv2+
URL: https://github.com/rpm-software-management/librepo
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch1: 0001-Replace-python3-flask-with-httpserver-in-python-tests.patch
Patch2: 0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch
Patch3: 0003-Covscan-warnings-and-fail_if-deprication.patch
Patch4: 0004-fail_if-and-fail_unless-are-deprecated.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.
%package -n python3-%{name}
Summary: Python 3 bindings for the librepo library
%{?python_provide:%python_provide python3-%{name}}
BuildRequires: python3-devel
BuildRequires: python3-gpg
BuildRequires: python3-pyxattr
BuildRequires: python3-requests
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.
%prep
%autosetup -p1
%build
%cmake %{!?with_zchunk:-DWITH_ZCHUNK=OFF}
%cmake_build
%check
%ctest
%install
%cmake_install
%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}/
%files -n python3-%{name}
%{python3_sitearch}/%{name}/
%changelog
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.14.0-6
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Tue Jul 27 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 1.14.0-5
- Fix issues detected by static analyzers
* Tue Jul 13 2021 Marek Blaha <mblaha@redhat.com> - 1.14.0-4
- Recover from fsync fail on read-only filesystem (RhBug:1981194)
* Wed Jun 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.14.0-3
- Rebuilt for RHEL 9 BETA for openssl 3.0
Related: rhbz#1971065
* Fri Apr 30 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 1.14.0-2
- Remove build dependency on python3-flask
* Mon Apr 26 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 1.14.0-1
- Update to 1.14.0
- Reposync does not re-download unchanged packages (RhBug:1931904)
- Return "calculated" checksum if requested w/caching
- Fixed memory leaks and segfault
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.13.0-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Mon Mar 01 2021 Nicola Sella <nsella@redhat.com> - 1.13.0-1
- Update to 1.13.0
- Add support for working with certificates used with proxy
- Drop Python 2 support
- Fix: lr_perform() - Avoid 100% CPU usage
- Add support for pkcs11 certificate and key for repository authorization
- Fix default value for LRO_SSLVERIFYSTATUS
- Don't use max_ranges to determine if we expect zchunk callback
- Prefer HTTP over FTP mirrors when zchunk is enabled
- Fixed mem leaks and typos
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.12.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Oct 07 2020 Nicola Sella <nsella@redhat.com> - 1.12.1-1
* Update to 1.12.1
- Validate path read from repomd.xml (RhBug:1868639)
* Fri Aug 07 2020 Nicola Sella <nsella@redhat.com> - 1.12.0-4
spec: Fix building with new cmake macros
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.12.0-3
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.12.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jun 02 2020 Nicola Sella <nsella@redhat.com> - 1.12.0-1
- Update to 1.12.0
- Decode package URL when using for local filename (RhBug:1817130)
- Fix memory leak in lr_download_metadata() and lr_yum_download_remote()
- Download sources work when at least one of specified is working (RhBug:1775184)
- Enable building on OSX
* Mon May 25 2020 Miro Hrončok <mhroncok@redhat.com> - 1.11.3-3
- Rebuilt for Python 3.9
* Fri May 22 2020 Miro Hrončok <mhroncok@redhat.com> - 1.11.3-2
- Bootstrap for Python 3.9
* Wed Apr 01 2020 Ales Matej <amatej@fedoraproject.org> - 1.11.3-1
- Update to 1.11.3
- Prefer mirrorlist/metalink over baseurl (RhBug:1775184)
* Mon Feb 10 2020 Ales Matej <amatej@fedoraproject.org> - 1.11.1-4
- Fix calling Python API without holding GIL (RhBug:1788918)
* Wed Feb 05 2020 Lukas Slebodnik <lslebodn@fedoraproject.org> - 1.11.1-3
- Do not unref LrErr_Exception on exit (RhBug:1778854)
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.11.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Dec 09 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.11.1-1
- Update to 1.11.1
- Create a directory for gpg sockets in /run/user/ (RhBug:1769831,1771012)
* Wed Nov 06 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.11.0-1
- Update to 1.11.0
- Retry mirrorlist/metalink downloads several times (RhBug:1741931)
- Improve variable substitutions in URLs and add ${variable} support
* Tue Oct 01 2019 Ales Matej <amatej@redhat.com> - 1.10.6-1
- Update to 1.10.6
- Imporove handling of xattr to re-download damadged files (RhBug:1690894)
- Rephrase repository GPG check error message (RhBug:1741442)
- Add sleep before next try when all mirrors were tried (RhBug:1741931)
- Raise logging level of error messages (RhBug:1737709)
* Sun Aug 18 2019 Miro Hrončok <mhroncok@redhat.com> - 1.10.5-2
- Rebuilt for Python 3.8
* Mon Jul 29 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.10.5-1
- Update to 1.10.5
- Exit gpg-agent after repokey import (RhBug:1650266)
- Handle webservers that don't support ranges when downloading zck
- Define LRO_SUPPORTS_CACHEDIR only with zchunk (RhBug:1726141)
- Allow to use mirrors multiple times for a target (RhBug:1678588)
- Allow to try baseurl multiple times (RhBug:1678588)
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.10.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu May 23 2019 Jonathan Dieter <jdieter@gmail.com> - 1.10.2-2
- Add upstream patch to make sure to check next transfer if current zck
transfer already exists
* Mon May 20 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.10.2-1
- Update to 1.10.2
- Add an option to preserve timestamps of the downloaded files (RhBug:1688537)
- librepo: append the '?' part of repo URL after the path
- Fix librepo isn't able to load zchunk files from next server on failure
* Tue Apr 02 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.9.6-2
- Backport patch to fix segfault when using zchunk metadata
* Wed Mar 27 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.9.6-1
- Update to 1.9.6
- Fix memory leaks
- Fix CPU usage when downloading packages (RhBug:1691856)
* Mon Mar 11 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.9.5-1
- Update to 1.9.5
- Reduce download delays
* Wed Feb 13 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 1.9.4-1
- Update to 1.9.4-1
- Add zchunk support
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Jan 28 2019 Miro Hrončok <mhroncok@redhat.com> - 1.9.2-2
- Subpackage python2-librepo has been removed
See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal
* Tue Sep 25 2018 Jaroslav Mracek <jmracek@redhat.com> - 1.9.2-1
- Update to 1.9.2
- Fix major performance regression with libcurl-7.61.1
* Mon Aug 13 2018 Daniel Mach <dmach@redhat.com> - 1.9.1-1
- Update to 1.9.1
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Fri Jun 29 2018 Jaroslav Mracek <jmracek@redhat.com> - 1.9.0-3
- Rebuilt for Python 3.7
* Tue Jun 26 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.9.0-2
- Fix ldconfig_scriptlets once more
* Tue Jun 26 2018 Jaroslav Mracek <jmracek@redhat.com> - 1.9.0-1
- Update to 1.9.0
* Mon Jun 18 2018 Miro Hrončok <mhroncok@redhat.com> - 1.8.1-9
- Rebuilt for Python 3.7
* Fri Jun 15 2018 Miro Hrončok <mhroncok@redhat.com> - 1.8.1-8
- Bootstrap for Python 3.7
* Thu Feb 08 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.8.1-7
- Add if conditionals around pyxattr
* Wed Feb 07 2018 Iryna Shcherbina <ishcherb@redhat.com> - 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 <ignatenkobrain@fedoraproject.org> - 1.8.1-5
- Switch to %%ldconfig_scriptlets
* Tue Nov 07 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.8.1-4
- Use better Obsoletes for platform-python
* Sat Nov 04 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.8.1-3
- Fix typo in Obsoletes
* Fri Nov 03 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.8.1-2
- Remove platform-python subpackage
* Fri Sep 15 2017 Igor Gnatenko <ignatenko@redhat.com> - 1.8.1-1
- Update to 1.8.1
* Fri Sep 01 2017 Igor Gnatenko <ignatenko@redhat.com> - 1.8.0-2
- Disable platform python on old releases
* Wed Aug 23 2017 Igor Gnatenko <ignatenko@redhat.com> - 1.8.0-1
- Update to 1.8.0
* Fri Aug 18 2017 Tomas Orsava <torsava@redhat.com> - 1.7.20-9
- Added Patch 0 to fix a tearDown failure in the test suite
* Thu Aug 10 2017 Petr Viktorin <pviktori@redhat.com> - 1.7.20-8
- Add subpackage for platform-python (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack)
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.20-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.20-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.20-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Tue Dec 13 2016 Charalampos Stratakis <cstratak@redhat.com> - 1.7.20-4
- Enable tests
* Tue Dec 13 2016 Charalampos Stratakis <cstratak@redhat.com> - 1.7.20-3
- Rebuild for Python 3.6
- Disable tests for now
* Sat Dec 10 2016 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 1.7.20-2
- Rebuild for gpgme 1.18
* Thu Aug 25 2016 Tomas Mlcoch <tmlcoch@redhat.com> - 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 <tmlcoch@redhat.com> - 1.7.19-1
- Add yumrecord substitution mechanism (mluscon)
- Fix a memory leak in signature verification (cwalters)
* Tue Aug 09 2016 Igor Gnatenko <ignatenko@redhat.com> - 1.7.18-4
- Add %%{?system_python_abi}
- Trim ton of changelog
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7.18-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Thu Apr 07 2016 Igor Gnatenko <ignatenko@redhat.com> - 1.7.18-2
- Adopt to new packaging guidelines
- Cleanups in spec file
* Fri Mar 4 2016 Tomas Mlcoch <tmlcoch@redhat.com> - 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