Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix support for lookahead regex in conda #506

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ OPTION (ENABLE_APPDATA "Build with AppStream appdata support?" OFF)

OPTION (MULTI_SEMANTICS "Build with support for multiple distribution types?" OFF)

OPTION (ENABLE_PCRE2 "Build with PCRE2 as the regex engine" OFF)
OPTION (ENABLE_LZMA_COMPRESSION "Build with lzma/xz compression support?" OFF)
OPTION (ENABLE_BZIP2_COMPRESSION "Build with bzip2 compression support?" OFF)
OPTION (ENABLE_ZSTD_COMPRESSION "Build with zstd compression support?" OFF)
@@ -203,6 +204,13 @@ IF (MULTI_SEMANTICS)
MESSAGE (STATUS "Enabling multi dist support")
ENDIF (MULTI_SEMANTICS)

IF (ENABLE_PCRE2)
MESSAGE (STATUS "Enabling PCRE2 regex engine")
FIND_PACKAGE (PkgConfig REQUIRED)
PKG_CHECK_MODULES (PCRE2 REQUIRED libpcre2-posix)
INCLUDE_DIRECTORIES (${PCRE2_INCLUDE_DIRS})
ENDIF (ENABLE_PCRE2)

IF (ENABLE_RPMDB)
SET (ENABLE_RPMPKG ON)
ENDIF (ENABLE_RPMDB)
@@ -313,7 +321,7 @@ FOREACH (VAR
ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
ENABLE_ZLIB_COMPRESSION ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION
ENABLE_ZSTD_COMPRESSION ENABLE_ZCHUNK_COMPRESSION ENABLE_PGPVRFY ENABLE_APPDATA
WITH_SYSTEM_ZCHUNK)
WITH_SYSTEM_ZCHUNK ENABLE_PCRE2)
IF(${VAR})
ADD_DEFINITIONS (-D${VAR}=1)
SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
@@ -411,6 +419,9 @@ SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${EXPAT_LIBRARY})
ENDIF (WITH_LIBXML2 )

ENDIF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
IF (ENABLE_PCRE2)
SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${PCRE2_LIBRARIES})
ENDIF (ENABLE_PCRE2)
IF (ENABLE_ZLIB_COMPRESSION)
SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${ZLIB_LIBRARY})
ENDIF (ENABLE_ZLIB_COMPRESSION)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ IF (DISABLE_SHARED)
ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
ELSE (DISABLE_SHARED)
ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS})
TARGET_LINK_LIBRARIES(libsolv ${SYSTEM_LIBRARIES})
ENDIF (DISABLE_SHARED)

IF (WIN32)
13 changes: 10 additions & 3 deletions src/conda.c
Original file line number Diff line number Diff line change
@@ -17,7 +17,14 @@
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#ifdef ENABLE_PCRE2
#include <pcre2posix.h>
#define regcomp pcre2_regcomp
#define regexec pcre2_regexec
#define regfree pcre2_regfree
#else
#include <regex.h>
#endif

#include "pool.h"
#include "repo.h"
@@ -574,7 +581,7 @@ pool_conda_matchspec(Pool *pool, const char *name)
int haveglob = 0;

/* ignore channel and namespace for now */
if ((p2 = strrchr(name, ':')))
if ((p2 = strrchr(name, ':')) && (p2 < strchr(name, ' ')))
name = p2 + 1;
name2 = solv_strdup(name);
/* find end of name */
@@ -619,10 +626,10 @@ pool_conda_matchspec(Pool *pool, const char *name)
if (p <= version + 1 || (p[-1] != ' ' && p[-1] != '='))
break; /* no build */
/* check char before delimiter */
if (p[-2] == '=' || p[-2] == '!' || p[-2] == '|' || p[-2] == ',' || p[-2] == '<' || p[-2] == '>' || p[-2] == '~')
if (p[-2] == '=' || p[-2] == '!' || p[-2] == '|' || p[-2] == ',' || p[-2] == '<' || p[-2] == '>' || p[-2] == '~' || p[-2] == '?')
{
/* illegal combination */
if (p[-1] == ' ')
if (p[-1] == ' ' || (p[-1] == '=' && p[-2] == '?'))
{
p--;
continue; /* special case space: it may be in the build */
7 changes: 7 additions & 0 deletions src/repodata.c
Original file line number Diff line number Diff line change
@@ -22,7 +22,14 @@
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#ifdef ENABLE_PCRE2
#include <pcre2posix.h>
#define regcomp pcre2_regcomp
#define regexec pcre2_regexec
#define regfree pcre2_regfree
#else
#include <regex.h>
#endif

#include "repo.h"
#include "pool.h"
1 change: 1 addition & 0 deletions src/solvversion.h.in
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ extern const char solv_toolversion[];
#cmakedefine LIBSOLV_FEATURE_MULTI_SEMANTICS
#cmakedefine LIBSOLV_FEATURE_CONDA

#cmakedefine LIBSOLVEXT_FEATURE_PCRE2
#cmakedefine LIBSOLVEXT_FEATURE_RPMPKG
#cmakedefine LIBSOLVEXT_FEATURE_RPMDB
#cmakedefine LIBSOLVEXT_FEATURE_RPMDB_BYRPMHEADER