pcre2-compat.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 3541f496..a2ec792c 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -33,6 +33,7 @@ OPTION (ENABLE_APPDATA "Build with AppStream appdata support?" OFF)
  6. OPTION (MULTI_SEMANTICS "Build with support for multiple distribution types?" OFF)
  7. +OPTION (ENABLE_PCRE2 "Build with PCRE2 as the regex engine" OFF)
  8. OPTION (ENABLE_LZMA_COMPRESSION "Build with lzma/xz compression support?" OFF)
  9. OPTION (ENABLE_BZIP2_COMPRESSION "Build with bzip2 compression support?" OFF)
  10. OPTION (ENABLE_ZSTD_COMPRESSION "Build with zstd compression support?" OFF)
  11. @@ -203,6 +204,13 @@ IF (MULTI_SEMANTICS)
  12. MESSAGE (STATUS "Enabling multi dist support")
  13. ENDIF (MULTI_SEMANTICS)
  14. +IF (ENABLE_PCRE2)
  15. + MESSAGE (STATUS "Enabling PCRE2 regex engine")
  16. + FIND_PACKAGE (PkgConfig REQUIRED)
  17. + PKG_CHECK_MODULES (PCRE2 REQUIRED libpcre2-posix)
  18. + INCLUDE_DIRECTORIES (${PCRE2_INCLUDE_DIRS})
  19. +ENDIF (ENABLE_PCRE2)
  20. +
  21. IF (ENABLE_RPMDB)
  22. SET (ENABLE_RPMPKG ON)
  23. ENDIF (ENABLE_RPMDB)
  24. @@ -313,7 +321,7 @@ FOREACH (VAR
  25. ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
  26. ENABLE_ZLIB_COMPRESSION ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION
  27. ENABLE_ZSTD_COMPRESSION ENABLE_ZCHUNK_COMPRESSION ENABLE_PGPVRFY ENABLE_APPDATA
  28. - WITH_SYSTEM_ZCHUNK)
  29. + WITH_SYSTEM_ZCHUNK ENABLE_PCRE2)
  30. IF(${VAR})
  31. ADD_DEFINITIONS (-D${VAR}=1)
  32. SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
  33. @@ -411,6 +419,9 @@ SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${EXPAT_LIBRARY})
  34. ENDIF (WITH_LIBXML2 )
  35. ENDIF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
  36. +IF (ENABLE_PCRE2)
  37. + SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${PCRE2_LINK_LIBRARIES})
  38. +ENDIF (ENABLE_PCRE2)
  39. IF (ENABLE_ZLIB_COMPRESSION)
  40. SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${ZLIB_LIBRARY})
  41. ENDIF (ENABLE_ZLIB_COMPRESSION)
  42. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  43. index bbf30bac..9a429fe4 100644
  44. --- a/src/CMakeLists.txt
  45. +++ b/src/CMakeLists.txt
  46. @@ -49,8 +49,10 @@ ENDIF (HAVE_LINKER_VERSION_SCRIPT)
  47. IF (DISABLE_SHARED)
  48. ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
  49. + TARGET_LINK_LIBRARIES(libsolv ${SYSTEM_LIBRARIES})
  50. ELSE (DISABLE_SHARED)
  51. ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS})
  52. + TARGET_LINK_LIBRARIES(libsolv ${SYSTEM_LIBRARIES})
  53. ENDIF (DISABLE_SHARED)
  54. IF (WIN32)
  55. diff --git a/src/conda.c b/src/conda.c
  56. index 6f6a65a6..ff91e13a 100644
  57. --- a/src/conda.c
  58. +++ b/src/conda.c
  59. @@ -17,7 +17,14 @@
  60. #include <unistd.h>
  61. #include <string.h>
  62. #include <sys/types.h>
  63. +#ifdef ENABLE_PCRE2
  64. +#include <pcre2posix.h>
  65. +#define regcomp pcre2_regcomp
  66. +#define regexec pcre2_regexec
  67. +#define regfree pcre2_regfree
  68. +#else
  69. #include <regex.h>
  70. +#endif
  71. #include "pool.h"
  72. #include "repo.h"
  73. @@ -574,7 +581,7 @@ pool_conda_matchspec(Pool *pool, const char *name)
  74. int haveglob = 0;
  75. /* ignore channel and namespace for now */
  76. - if ((p2 = strrchr(name, ':')))
  77. + if ((p2 = strrchr(name, ':')) && (p2 < strchr(name, ' ')))
  78. name = p2 + 1;
  79. name2 = solv_strdup(name);
  80. /* find end of name */
  81. @@ -619,10 +626,10 @@ pool_conda_matchspec(Pool *pool, const char *name)
  82. if (p <= version + 1 || (p[-1] != ' ' && p[-1] != '='))
  83. break; /* no build */
  84. /* check char before delimiter */
  85. - if (p[-2] == '=' || p[-2] == '!' || p[-2] == '|' || p[-2] == ',' || p[-2] == '<' || p[-2] == '>' || p[-2] == '~')
  86. + if (p[-2] == '=' || p[-2] == '!' || p[-2] == '|' || p[-2] == ',' || p[-2] == '<' || p[-2] == '>' || p[-2] == '~' || p[-2] == '?')
  87. {
  88. /* illegal combination */
  89. - if (p[-1] == ' ')
  90. + if (p[-1] == ' ' || (p[-1] == '=' && p[-2] == '?'))
  91. {
  92. p--;
  93. continue; /* special case space: it may be in the build */
  94. diff --git a/src/repodata.c b/src/repodata.c
  95. index 72f03d48..24167170 100644
  96. --- a/src/repodata.c
  97. +++ b/src/repodata.c
  98. @@ -22,7 +22,14 @@
  99. #include <stdlib.h>
  100. #include <unistd.h>
  101. #include <assert.h>
  102. +#ifdef ENABLE_PCRE2
  103. +#include <pcre2posix.h>
  104. +#define regcomp pcre2_regcomp
  105. +#define regexec pcre2_regexec
  106. +#define regfree pcre2_regfree
  107. +#else
  108. #include <regex.h>
  109. +#endif
  110. #include "repo.h"
  111. #include "pool.h"
  112. diff --git a/src/solvversion.h.in b/src/solvversion.h.in
  113. index da0ad743..35d33b92 100644
  114. --- a/src/solvversion.h.in
  115. +++ b/src/solvversion.h.in
  116. @@ -30,6 +30,7 @@ extern const char solv_toolversion[];
  117. #cmakedefine LIBSOLV_FEATURE_MULTI_SEMANTICS
  118. #cmakedefine LIBSOLV_FEATURE_CONDA
  119. +#cmakedefine LIBSOLVEXT_FEATURE_PCRE2
  120. #cmakedefine LIBSOLVEXT_FEATURE_RPMPKG
  121. #cmakedefine LIBSOLVEXT_FEATURE_RPMDB
  122. #cmakedefine LIBSOLVEXT_FEATURE_RPMDB_BYRPMHEADER