Commit Graph

15056 Commits

Author SHA1 Message Date
Panu Matilainen cf967331d3 Remove support for beecrypt
Beecrypt whose upstream is dead for more than ten years now, was deprecated
in rpm 4.16 (in commit 0910e6aa9e).
2020-05-29 08:54:56 +03:00
Panu Matilainen 3ca518876f Bump version to mark beginning of a new development cycle 2020-05-29 08:54:56 +03:00
Igor Raits a9199f17be macros: Drop internal macros which are not used in RPM and Fedora
The special note requires remsh which is used internally, under
different name (with one underscore instead of two).

Those macros are not used anywhere in RPM, neither in Fedora as of
today.

References: https://github.com/rpm-software-management/rpm/issues/1211
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
2020-05-28 13:57:56 +03:00
Panu Matilainen 6f7ae5116c Bump CI Fedora version from 31 to 32 aka latest stable 2020-05-28 10:53:36 +02:00
Panu Matilainen 145b5f8740 Support rpm version comparison in expressions
Adds rpm version as a new expression value type, denoted by v"" (similar
to Python u"", b"" etc), which are compared using rpm version comparison
algorithm rather than regular string comparison.

For example in specs:

    %if v"%{python_version}" < v"3.9"
    %endif

...but also command lines, arbitrary macros etc:

    rpm --eval '%[v"1:1.2" < v"2.0"]'

Fixes: #1217
2020-05-27 14:42:50 +02:00
Panu Matilainen 7af054a1b7 Handle expression value reset centrally
Less redundancy and makes adding new types nicer.
2020-05-27 14:42:50 +02:00
Panu Matilainen 00fa4f3734 Refactor expression parser comparisons to use common logic for all types
It's less code, less redundancy and makes adding new types nicer.
2020-05-27 14:42:50 +02:00
Panu Matilainen 4f7a500c75 Support EVR strings to Python labelCompare()
Use the newly added version converter function for parsing labelCompare()
arguments, gaining automatic access to all formats that we support
in rpm.ver() constructor. Currently this means (E,V,R) tuples which
labelCompare() always used, plus plain old strings. In future, might
be something more.
2020-05-27 14:14:00 +02:00
Panu Matilainen a837ec978d Add Python bindings for the new version API 2020-05-27 14:14:00 +02:00
Panu Matilainen a1d2722c4a Fix Lua rpm.vercmp() to compare actual EVRs instead of segments (#897)
The low-level rpmvercmp() was always the wrong thing to export to Lua,
but its what people have used because it's there and its used for
comparing full versions. So rather than add a separate API for the higher
level comparison, lets just change rpm.vercmp() do the right thing instead.

Fixes: #897
2020-05-27 14:14:00 +02:00
Panu Matilainen 74dd240d00 Refactor python labelCompare() to use the new version API, add more tests 2020-05-27 14:14:00 +02:00
Panu Matilainen d88b929998 Refactor rpmdsCompare() to use the new version API 2020-05-27 14:14:00 +02:00
Panu Matilainen be0c4b5dce Add (beginnings of) a rpm version API (parsing, comparison)
It's more than a little hysterical that rpm hasn't had a meaningful
public API for parsing and comparing version strings. The API may seem
kinda overkill for some things but then this does give us a place to
check for invalid version strings, which is a thing we never had before
(although the current code doesn't do much in the way of checking)

Fixes: #561
2020-05-27 14:14:00 +02:00
Panu Matilainen 6800e0a4df Axe --nopromote and most of the related infrastructure
Epoch promotion was a thing around and before the turn of the millenium,
we really shouldn't be carrying that cruft around anymore.

Remove all traces that we can without too much guilt about breaking
ABI/API and not bumping soname which we dont want to do for this
stupid old thing: all the symbols are left in place, they just don't
work anymore. Nobody should notice as nobody can have been using this
stuff in the last 15+ years.
2020-05-27 14:14:00 +02:00
Panu Matilainen f1e721ccfc Consolidate our Lua-bindings to librpmio now that we can
No functional changes, just lose extra baggage that was needed to append
initialize and append rpm.vercmp() from librpm side when the rest is in
librpmio. We might need to bring it back some day, but given the history
here it doesn't seem all that likely.
2020-05-27 14:14:00 +02:00
Panu Matilainen 501fb4ef62 Move rpmvercmp() to librpmio
Adding a new header just for this seems a bit much but we'll be adding
stuff there shortly.

No functional changes as such, this is prerequisite for supporting
version comparison in expressions.
2020-05-27 14:14:00 +02:00
Panu Matilainen 290537375d Move rpmVersionCompare() to headerutil.c for better layer match
No functional change, but we'll need this in the next step.
2020-05-27 14:14:00 +02:00
Tomas Orsava c958b02a0f scripts/pythondistdeps: Modify handling of dev versions 2020-05-27 08:55:07 +03:00
Tomas Orsava 753173b744 scripts/pythondistdeps: Version handling exception with better information 2020-05-27 08:55:07 +03:00
Tomas Orsava 470c367284 scripts/pythondistdeps: Do anything only when called as a main script
Note that the code is completely unchanged except for the indentation
under the new if __name__ == "__main__":

Note that this change is necessary, but not sufficient to use the
RpmVersion class.
The init of the RpmVersion class will fail when called from an outside
script, because the `parse_version()` function is lazily imported from
the code outside the class.  However, adding the import of
parse_version() to RpmVersion class is not done right now, because while
we would import it from `pkg_resources`, other scripts might want to
rely instead of the lightweight `packaging` module for the import. Thus
I'm leaving this conondrum to be addressed in the future.
2020-05-27 08:55:07 +03:00
Tomas Orsava 08dbbfe960 scripts/pythondistdeps: Implement --normalized-name-* options
--normalized-names-format FORMAT
    FORMAT of normalized names can be `pep503` [default] or `legacy-dots` (dots allowed)

--normalized-names-provide-both
    Provede both `pep503` and `legacy-dots` format of normalized names (useful for a transition period)
2020-05-27 08:55:07 +03:00
Tomas Orsava c97e631d6e scripts/pythondistdeps: Add option to generate major-version provides only for specified Python versions 2020-05-27 08:55:07 +03:00
Tomas Orsava 4ff70411be scripts/pythondistdeps: Sort generated provides/requires
So that they can be compared with expected results in tests
2020-05-27 08:55:07 +03:00
Tomas Orsava fbe6d2d043 scripts/pythondistdeps: Notes from an attempted rewrite to importlib.metadata
Notes from an attempted rewrite from pkg_resources to importlib.metadata in 2020:
1. While pkg_resources can open a metadata on a specified path
   (Distribution.from_location()), importlib provides access only to
   "installed package metadata", i.e. the the dist-info or egg-info directory
   must be "discoverable", i.e. on the sys.path.
   - Thankfully only the dist/egg-info directory must exist, the
     corresponding Python module does not have to be present.
   - The problems this causes:
     (a) You have to manipulate the sys.path to add the specific location of
         the site-packages directory inside the buildroot
     (b) If you have package "foo" in this newly added directory on sys.path
         and there is some problem and its dist/egg-info metadata are not found,
         importlib.metadata continues searching the sys.path and may discover a
         package with the same name (possibly same version) outside the
         buildroot.
         To get around this, you can manipulate the sys.path to remove all
         other "site-packages" directories. But you have to leave the
         standard library there, because importlib may import other modules
         (in my testing: base64, quopri, random, socket, calendar, uu)
     (c) I have not tested how well it works if you're ispecting metadata of
         different Python versions than the one you run the script with
         (especially Python 2 vs Python 3). This might also cause problems with
         dependency specifiers (i.e. python_version != "3.4")
2. Handling of dependencies (requires) is problematic in importlib.metadata
   - pkg_resources provides a way to separately list standard requires and a
     requires for each "extras" category. importlib does not provide this, it
     only spits out a list of strings, each string in the format:
     - 'packaging>=14',
     - 'towncrier>=18.5.0; extra == "docs"', or
     - 'psutil<6,>=5.6.1; (python_version != "3.4") and extra == "testing"
     you can either parse these with a regex (fragile) or use the external
     `packaging` Python module. `packaging`, however, also doesn't have a great
     support for figuring out extra dependencies, it provides the marker api:
     - <Marker(\'python_version != "3.4" and extra == "testing"\')>
     you can use Marker api to evaluate the condition, but not to parse.
     For parsing you can access the private api Marker._markers:
     - marker._markers=[[(<Variable('python_version')>, <Op('!=')>, \
           <Value('3.4')>)], 'and', (<Variable('extra')>, <Op('==')>, \
           <Value('testing')>)]
     which beyond the problem of being private is also not very useful for
     parsing due to its structure.
   - pkg_resources also provides version parsing, which importlib does not
     and `packaging` needs to be used
   - importlib is part of the standard library, but packaging and its
     2 runtime dependencies (pyparsing and six) are not, and therefore we
     would go from 1 dependency to 3
3. A few minor issues, more in the next section about equivalents.

importlib.metadata.distribution equivalents of pkg_resources.Distribution attributes:
- pkg_resources: dist.py_version
  importlib: # not implemented (but can be guessed from the /usr/lib/pythonXX.YY/ path)
- pkg_resources: dist.project_name
  importlib: dist.metadata['name']
- pkg_resources: dist.key
  importlib: # not implemented
- pkg_resources: dist.version
  importlib: dist.version
- pkg_resources: dist.requires()
  importlib: dist.requires  # but returns strings with almost no parsing done, and also lists extras
- pkg_resources: dist.requires(extras=dist.extras)
  importlib: # not implemented, has to be parsed from dist.requires
- pkg_resources: dist.get_entry_map('console_scripts')
  importlib: [ep for ep in importlib.metadata.entry_points()['console_scripts'] if ep.name == pkg][0]
             # I have not found a better way to get the console_scripts
- pkg_resources: dist.get_entry_map('gui_scripts')
  importlib: # Presumably same as console_scripts, but untested
2020-05-27 08:55:07 +03:00
Tomas Orsava 28c292ae29 scripts/pythondistdeps: "Fix" support of environment markers
Upstreaming from Fedora
2020-05-27 08:55:07 +03:00
Tomas Orsava 4c0ed11a30 scripts/pythondistdeps: Also provide pythonXdist() with PEP 503 normalized names
Upstreaming from Fedora (BZ#1791530)

That is, we add new provides that replace dots with a dash.

Package that used to provide python3dist(zope.component) and python3.8dist(zope.component)
now also provides python3dist(zope-component) and python3.8dist(zope-component).

Package that used to provide python3dist(a.-.-.-.a) now provides python3dist(a-a) as well.

This is consistent with pip behavior, `pip install zope-component` installs zope.component.

Historically, we have always used dist.key (safe_name) from setuptools,
but that is a non-standardized convention -- whether or not it replaces dots
with dashes is not even documented.
We say we use "canonical name" or "normalized name" everywhere, yet we didn't.

We really need to follow the standard (PEP 503):

https://www.python.org/dev/peps/pep-0503/#normalized-names

The proper function here would be packaging.utils.canonicalize_name
https://packaging.pypa.io/en/latest/utils/#packaging.utils.canonicalize_name
-- we reimplement it here to avoid an external dependency.

This is the first required step needed if we want to change our requirements later.
If we decide we don't, for whatever reason, this doesn't break anything.
2020-05-27 08:55:07 +03:00
Michael Schroeder 8734c1b97e Support ed25519 signatures in digest_libgcrypt.c 2020-05-26 17:03:11 +03:00
Michael Schroeder e3a78f6077 Support ed25519 signatures in digest_openssl.c 2020-05-26 17:03:11 +03:00
Michael Schroeder 92c87b9713 Support the EdDSA public key algorithm
The algorithm identifier and encoding format are taken from the
not yet accepted update to rfc4480:

https://datatracker.ietf.org/doc/draft-ietf-openpgp-rfc4880bis/

Gnupg supports EdDSA since version 2.1.0 (released in 2014).
2020-05-26 17:03:11 +03:00
Panu Matilainen 95df3dcb9d Add license to Python distutils module description
Fixes: #1236
2020-05-26 12:08:43 +03:00
Jes Sorensen f34030816d rpmfiArchiveRead() use signed return value to handle -1 on error
size_t is unsigned, so returning -1 is not going to have the expected
behavior. Fix it to return ssize_t.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-05-13 11:07:49 +03:00
Miro Hrončok 022b48d210 Don't define global Lua variables from Python generator 2020-04-28 16:25:10 +03:00
Thierry Vignaud 9a30bcdacc describe all rpmdeps options 2020-04-27 12:45:58 +03:00
Panu Matilainen ead227f2da Kick out leftover development-time assert checks from rpmal 2020-04-22 15:38:35 +03:00
Panu Matilainen a4afbb62c9 Don't look into source package provides in depsolving
Fixes regressions from commit 75ec16e660e784d7897b37cac1a2b9b135825f25:
the newly added provides of to-be-built packages were being used for
dependency resolution, such as spec satifying its own buildrequires,
and matched against conflicts in installed packages.

Source packages cannot obsolete anything or provide capabilities or files
to transactions, don't add them to rpmal at all. Explicitly skip checks
against source provides, similarly to what we already did with obsoletes.

Fixes: #1189
2020-04-22 15:36:29 +03:00
Igor Raits 5d8c6e537f Convert debuginfo generator to a parametric generator
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
2020-04-21 14:49:19 +03:00
Igor Raits 232cb6fee6 Convert desktop generator to a parametric generator
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
2020-04-21 14:49:19 +03:00
Igor Raits 9464926456 Convert metainfo generator to a parametric generator
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
2020-04-21 14:49:19 +03:00
Michal Domonkos 6f6f5e70f1
build: prioritize large packages
Binary packages come in different sizes and so their build time can vary
greatly.  Dynamic scheduling, which we currently use for parallel
building, is a good strategy to combat such differences and load-balance
the available CPU cores.

That said, knowing that the build time of a package is proportional to
its size, we can reduce the overall time even further by cleverly
ordering the task queue.

As an example, consider a set of 5 packages, 4 of which take 1 unit of
time to build and one takes 4 units.  If we were to build these on a
dual-core system, one possible unit distribution would look like this:

            TIME --->
CPU 1       * * * * * *         # package 1, 3 and 5
CPU 2       * *                 # package 2 and 4

Now, compare that to a different distribution where the largest package
5 gets built early on:

            TIME --->
CPU 1       * * * *             # package 5
CPU 2       * * * *             # package 1, 2, 3 and 4

It's obvious that processing the largest packages first gives better
results when dealing with such a mix of small and large packages
(typically a regular package and its debuginfo counterpart,
respectively).

Now, with dynamic scheduling in OpenMP, we cannot directly control the
task queue; we can only generate the tasks and let the runtime system do
its work.  What we can do, however, is to provide a hint to the runtime
system for the desired ordering, using the "priority" clause.

So, in this commit, we use the clause to assign a priority value to each
build task based on the respective package size (the bigger the size,
the higher the priority), to help achieve an optimal execution order.

Indeed, in my testing, the priorities were followed to the letter (but
remember, that's not guaranteed by the specification).  Interestingly,
even without the use of priorities, simply generating the tasks in the
desired order resulted in the same execution order for me, but that's,
again, just an implementation detail.

Also note that OpenMP is allowed to stop the thread generating the tasks
at any time, and make it execute some of the tasks instead.  If the
chosen task happens to be a long-duration one, we might hit a starvation
scenario where the other threads have exhausted the task queue and
there's nobody to generate new tasks.  To counter that, this commit also
adds the "untied" clause which allows other threads to pick up where the
generating thread left off, and continue generating new tasks.

Resolves #1045.
2020-04-21 12:38:25 +03:00
Panu Matilainen 701736a18a Warn on undefined components in buildtree macros
Issue a warning if buildtree macros (%_sourcedir etc) contain undefined
macro(s) after expansion, such as things only defined during spec parse.
This always was a murky case that doesn't work in all scenarios, so
a warning seems appropriate. Actual behavior doesn't change here though.
2020-04-20 13:25:56 +03:00
Gordon Messmer d3470947a5 Handle all-zero versions without crashing. 2020-04-20 11:12:59 +02:00
Steve Kowalik 25a8dfae1a scripts/pythondistdeps: Deal with some flake8 warnings
flake8 is mostly unhappy with pythondistdeps.py, so clean up most of
them, which is whitespace changes.
2020-04-17 11:31:10 +03:00
Steve Kowalik 3f7b03af43 scripts/pythondistdeps: Switch to argparse
Stop using getopt, and switch to a modern solution for parsing
arguments.
2020-04-17 11:31:10 +03:00
Miro Hrončok 224c08a5e8 Adjust %__python_path
- sync with Fedora
 - only match direct Python sitedir, no /opt/.../lib/python3.7 stuff
 - prep for multiple digits Python major releases (e.g. 12.1)
 - use the value of %_prefix

See also:

8eef42cbaa
https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.org/thread/UFKUM5UKCTNGIT3KJVYEI5VXPI23QMBN/
https://github.com/rpm-software-management/rpm/pull/1153#discussion_r407997958
2020-04-17 11:26:08 +03:00
Neal Gompa 0b9efb93fb Deprecate NSS support
The NSS library often changes in ways that somehow breaks rpm,
and these days upstream does not care about consumers of NSS other
than itself. This inflicts untold amounts of suffering on users
of rpm in distributions where rpm is linked to NSS.

Now that we have a couple of good, well-supported options, there is
no reason to keep supporting NSS as an option.

So now, we are deprecating it for later removal.
2020-04-16 15:53:18 +03:00
Neal Gompa 0910e6aa9e Add a warning when beecrypt is selected for the crypto library
Let's make it absolutely clear that selecting beecrypt is deprecated
and those continuing to use it should be aware that the option will
go away soon.
2020-04-16 15:53:18 +03:00
Panu Matilainen c77df4cd1d Handle manually specified debuginfo package more gracefully
In todays' "look ma what crawled from under the bed" episode, we have
encounter a subpackage whose name is not derived from the main package
name, and a manually specified debuginfo package on that. This particular
combo manages to evade all our checks for duplicate package names, and
in the right phase of the moon actually creates corrupt packages due to
two threads end up writing to the same output file simultaneously. Which
is what happened in https://pagure.io/fedora-infrastructure/issue/8816

Catch the case and use the spec-defined variant (because getting rid
of it would be harder) but issue a warning because most likely this
is not what they really wanted.
2020-04-14 13:25:09 +03:00
Michael Schroeder de3f36acc9 Add an index sync call at the end of a database rebuild
This is normally unneeded because an index sync is already done
after each package is added to the database. But rebuilding an
empty database lead to no index sync being done and a mismatch
between the generation count. This in turn will trigger a
index regeneration.

Found by using ndb when running the test suite.
2020-04-14 13:22:12 +03:00
Michael Schroeder 6511823c97 ndb: make rpmxdbWriteHeader a void function
It's a static function and nobody tests the return code. It just
writes into mapped memory like rpmxdbUpdateSlot, which is also void.
2020-04-14 13:22:12 +03:00
Michael Schroeder 1187cf005a ndb: unmap xdb's header when closing the xdb database
Somehow I was under the impression that mapped regions are unmapped when
the corresponding file descriptor is closed, but that's not the case
for POSIX systems.
2020-04-14 13:22:12 +03:00