solver_addbestrules: recalculate pointer to current rule after adding a new rule
The code adds new rules in a FOR_RULELITERALS loop. The iterator needs
to access elements of the rule it iterates over, so if we add a new
rule in the loop body, we have to make sure that the pointer to the
current rule stays valid.
repo_autopattern: support creation of obsoletes for product packages
This adds support for provides of the type "product-obsoletes(name)".
We translate this to "Obsoletes: product:<name>" in the generated
product pseudo package.
We need this because people used "Obsoletes: product:name" in the
"release" package, but this is no longer allowed in newer rpm versions.
Besides, the obsoletes is kind of wrong in the "release" package
anyway, it belongs in the generated "product:" package.
Implement color filtering when adding update targets
The old code created update jobs spanning multiple architectures
even if "implicitobsoleteusescolors" was set.
Also add color filtering in replaces_installed_package, where it
seems to be also missing
Petr Písař [Tue, 4 Mar 2025 08:02:22 +0000 (09:02 +0100)]
Increase CMake version to 3.5
CMake 4.0.0 removed a support for CMake scripts older than 3.5 and a build
with CMake 4.0.0-rc2 fails like this:
$ /usr/bin/cmake -S . -B redhat-linux-build
CMake Warning (dev) at CMakeLists.txt:1 (PROJECT):
cmake_minimum_required() should be called prior to this top-level project()
call. Please see the cmake-commands(7) manual for usage documentation of
both commands.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:3 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 3.5 has been removed from CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
-- Configuring incomplete, errors occurred!
There seems to be no way of making the script working with all
versions. CMake 3.5 was relased in 2016.
This patch increases the minimal version to 3.5 and moves it to the top
of the script as it needs to be the very first thing of a script as
recommeded by cmake:
CMake Warning (dev) at CMakeLists.txt:1 (PROJECT):
cmake_minimum_required() should be called prior to this top-level project()
call. Please see the cmake-commands(7) manual for usage documentation of
both commands.
I did not set a supported upper version of CMake since I guess
we do not want to update it with every new minor CMake release.
Other printed CMake warnings are not news are not addressed with
this patch.
Petr Písař [Fri, 7 Feb 2025 14:21:16 +0000 (15:21 +0100)]
Fix building in ISO C23
ISO C23 added bool type as a keyword. It is the standard GCC 15 uses by default and
compilation of bindings/perl/solv_perl.c fails then:
bindings/perl/solv_perl.c:1641:13: error: ‘bool’ cannot be defined via ‘typedef’
1641 | typedef int bool;
| ^~~~
/home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:13: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
/home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:1: warning: useless type name in empty declaration
1641 | typedef int bool;
| ^~~~~~~
The typedef comes from bindings/solv.i which attemps to supply it in case Swig
undefines it.
This patch fixes it by not defining it in case ISO C23 or newer is in
use. Keywords cannot be checked by a preprocessor, neither undefined
(by Swig).
Make POOL_FLAG_ADDFILEPROVIDESFILTERED behaviour more standard
Turning on POOL_FLAG_ADDFILEPROVIDESFILTERED made the lookup of
all file dependencies lazy, not only the ones required by some
dependency. This changes the way searching works and may also
slow down some use cases.
We now changed addfileprovides() to record the needed non-standard
file dependencies and only make those lazy in createwhatprovides().
Petr Písař [Wed, 10 Jul 2024 14:54:56 +0000 (16:54 +0200)]
Fix a possible format overflow in dump_genid()
GCC 14 called with CFLAGS='-O2 -Wformat-overflow' complains:
/tmp/libsolv/ext/testcase.c: In function ‘dump_genid’:
/tmp/libsolv/ext/testcase.c:1275:33: warning: ‘: genid ’ directive writing 8 bytes into a region of size between 3 and 12 [-Wformat-overflow=]
1275 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~
/tmp/libsolv/ext/testcase.c:1275:7: note: ‘sprintf’ output between 17 and 26 bytes into a destination of size 20
1275 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/libsolv/ext/testcase.c:1270:33: warning: ‘: genid ’ directive writing 8 bytes into a region of size between 3 and 12 [-Wformat-overflow=]
1270 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~
/tmp/libsolv/ext/testcase.c:1270:7: note: ‘sprintf’ output between 17 and 26 bytes into a destination of size 20
1270 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That's indeed a bug: sprintf() writes into a 20-byte array cntbuf. cnt
is int, 32-bit long integer on x86_64 Linux platform. dump_genid()
starts with cnt = 1 and increases. It can go up to 2147483647 decimal
value, then wrap to -2147483648 decimal value. That's up to 11 bytes
of the integer, plus 14 bytes of a static string, plus 1 byte of
a trailing '\0'. 26 bytes in total.
While it's improbable that cnt would amount that long number in real
life, it's better to be prepared for the worst. Also a benefit is that
static analyzers will be be content.
This patch increases cntbuf[] size to accomodate common 32-bit
ints. (Generic, albeit illegible, expression would be:
First resolve the given jobs, then the dependencies of the
resulting packages ignoreing the ones provided by currently
installed packages. After that resolve all already installed
packages. This is similar to SOLVER_FLAG_FOCUS_BEST but less
aggressive in updating packages.
This commit implements the file tree work needed
for the "plaindir" format. Like with the "find" command,
we do not follow symlinks to directories in recursive
mode.