Skip to content

Commit

Permalink
Merge pull request #435 from shivania2/queryformat
Browse files Browse the repository at this point in the history
Replace existing use of libxml2 library with expat library.
  • Loading branch information
oliverkurth authored Jun 29, 2023
2 parents a5415c9 + 84686c9 commit 619da78
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 231 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
find_package(PkgConfig REQUIRED)
pkg_check_modules(RPM REQUIRED rpm)
find_package(OpenSSL REQUIRED)
pkg_check_modules(LIBXML2 REQUIRED libxml-2.0)
pkg_check_modules(EXPAT REQUIRED expat)
pkg_check_modules(SQLITE3 sqlite3)
include_directories(${RPM_INCLUDE_DIRS})
include_directories(${LIBXML2_INCLUDE_DIRS})
include_directories(${EXPAT_INCLUDE_DIRS})

### External dependency: libsolv
find_package(LibSolv REQUIRED ext)
Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM fedora:34

RUN dnf -y upgrade
RUN dnf -y install gcc make cmake libcurl-devel rpm-devel rpm-build \
libsolv-devel popt-devel sed createrepo_c glib2-devel libxml2 \
libsolv-devel popt-devel sed createrepo_c glib2-devel expat \
findutils python3-pytest python3-requests python3-urllib3 \
python3-pyOpenSSL python3 python3-devel valgrind gpgme-devel \
libxml2-devel openssl-devel sqlite-devel rpm-sign which python3-pip \
expat-devel openssl-devel sqlite-devel rpm-sign which python3-pip \
shadow-utils sudo e2fsprogs util-linux

RUN pip3 install flake8
Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile.photon
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ RUN tdnf update -y
RUN tdnf remove -y toybox
RUN tdnf install -y --enablerepo=photon-debuginfo \
build-essential cmake curl-devel rpm-build \
libsolv-devel popt-devel sed createrepo_c glib libxml2 \
libsolv-devel popt-devel sed createrepo_c glib expat-libs \
findutils python3 python3-pip python3-setuptools \
python3-devel valgrind gpgme-devel glibc-debuginfo \
libxml2-devel openssl-devel zlib-devel sqlite-devel \
expat-devel openssl-devel zlib-devel sqlite-devel \
python3-requests python3-urllib3 python3-pyOpenSSL \
sudo shadow which e2fsprogs util-linux

Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile.photon-3.0
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ RUN tdnf update -y
RUN tdnf remove -y toybox
RUN tdnf install -y --enablerepo=photon-debuginfo \
build-essential cmake curl-devel rpm-build \
libsolv-devel popt-devel sed createrepo_c glib libxml2 \
libsolv-devel popt-devel sed createrepo_c glib expat-libs \
findutils python3 python3-setuptools python3-devel \
valgrind gpgme-devel glibc-debuginfo libxml2-devel \
valgrind gpgme-devel glibc-debuginfo expat-devel \
openssl-devel zlib-devel sqlite-devel python3-requests \
python3-urllib3 python3-pyOpenSSL python3-pip \
sudo shadow which e2fsprogs util-linux
Expand Down
13 changes: 13 additions & 0 deletions cmake/FindExpat.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# - Try to find expat
# Once done this will define
# EXPAT_INCLUDE_DIRS - The expat include directories
# EXPAT_LIBRARIES - The libraries needed to use expat-devel

find_path(EXPAT_INCLUDE_DIR expat.h)
find_library(EXPAT_LIBRARY NAMES libexpat.so)

find_package_handle_standard_args(expat DEFAULT_MSG
EXPAT_LIBRARY EXPAT_INCLUDE_DIR)

set(EXPAT_LIBRARIES ${EXPAT_LIBRARY})
set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
13 changes: 0 additions & 13 deletions cmake/FindLibxml2.cmake

This file was deleted.

6 changes: 3 additions & 3 deletions cmake/FindPackageHandleStandardArgs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
#
# Example for mode 1:
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Expat DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
# Expat is considered to be found, if both EXPAT_LIBRARY and
# EXPAT_INCLUDE_DIR are valid. Then also EXPAT_FOUND is set to TRUE.
# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
# independent whether QUIET was used or not.
# If it is found, success will be reported, including the content of <var1>.
Expand Down
2 changes: 1 addition & 1 deletion plugins/metalink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_library(${PROJECT_NAME} SHARED
)

target_link_libraries(${PROJECT_NAME}
${LIBXML2_LIBRARIES}
${EXPAT_LIBRARIES}
${LIB_TDNF}
)

Expand Down
2 changes: 1 addition & 1 deletion plugins/metalink/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <tdnfplugineventmap.h>
#include <tdnf-common-defines.h>

#include <libxml/parser.h>
#include <expat.h>

//libcurl
#include <curl/curl.h>
Expand Down
14 changes: 7 additions & 7 deletions plugins/metalink/metalink.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TDNFParseAndGetURLFromMetalink(
TDNF_ML_CTX *ml_ctx
)
{
int fd = -1;
FILE* file = NULL;
uint32_t dwError = 0;

if (!pTdnf ||
Expand All @@ -128,14 +128,14 @@ TDNFParseAndGetURLFromMetalink(
BAIL_ON_TDNF_ERROR(dwError);
}

fd = open(pszFile, O_RDONLY);
if (fd < 0)
file = fopen(pszFile, "r");
if (file == NULL)
{
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR_UNCOND(dwError);
}

dwError = TDNFMetalinkParseFile(ml_ctx, fd, TDNF_REPO_METADATA_FILE_NAME);
dwError = TDNFMetalinkParseFile(ml_ctx, file, TDNF_REPO_METADATA_FILE_NAME);
if (dwError)
{
pr_err("Unable to parse metalink, ERROR: code=%d\n", dwError);
Expand All @@ -146,9 +146,9 @@ TDNFParseAndGetURLFromMetalink(
TDNFSortListOnPreference(&ml_ctx->urls);

cleanup:
if (fd >= 0)
if (file != NULL)
{
close(fd);
fclose(file);
}
return dwError;
error:
Expand Down Expand Up @@ -442,4 +442,4 @@ TDNFMetalinkRepoMDDownloadEnd(
return dwError;
error:
goto cleanup;
}
}
44 changes: 31 additions & 13 deletions plugins/metalink/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
uint32_t
TDNFMetalinkParseFile(
TDNF_ML_CTX *ml_ctx,
int fd,
FILE *file,
const char *filename
);

Expand All @@ -23,31 +23,49 @@ TDNFMetalinkFree(
TDNF_ML_CTX *ml_ctx
);

uint32_t
char *
TDNFSearchTag(
const char **attr,
const char *type
);

void
TDNFXmlParseStartElement(
void *userData,
const char *name,
const char **attrs
);

void
TDNFXmlParseData(
TDNF_ML_CTX *ml_ctx,
xmlNode *node,
const char *filename
void *userData,
const char *val,
int len
);

void
TDNFXmlParseEndElement(
void *userData,
const char *name
);

uint32_t
TDNFParseFileTag(
TDNF_ML_CTX *ml_ctx,
xmlNode *node,
const char *filename
void *userData
);

uint32_t
TDNFParseHashTag(
TDNF_ML_CTX *ml_ctx,
xmlNode *node
void *userData,
const char *val,
int len
);


uint32_t
TDNFParseUrlTag(
TDNF_ML_CTX *ml_ctx,
xmlNode *node
void *userData,
const char *val,
int len
);

uint32_t
Expand Down
Loading

0 comments on commit 619da78

Please sign in to comment.