Use the functionality for converting PEP440 compatible python versions
to rpm compatible versions. Given the following example .spec:
%define component heat
Version: 5.0.0.0b2.dev261
%setup -q -n %{component}-%{version}
Will be transformed to something like:
%define component heat
%define version_unconverted 5.0.0.0b2.dev261
Version: 5.0.0.0~b2~dev261
%setup -q -n %{component}-%{version_unconverted}
This is the next needed addition to handle python package versions which
are PEP440 compatible. While using the converted (PEP440 compatible)
version in the 'Version' tag, for the '%setup' section, the unconverted
version needs to be used. The new function can be used to replace the
'%{version}' in the '%setup' section.
This function will be used to set the tarball version in a .spec
file. This is needed for PEP440 compatible versions for python
packages. Imagine the detected python version by 'set_version' is
'5.0.0.0a1.dev13'. The converted version will be '5.0.0.0~a1~dev13' (so
5.0.0.0 > 5.0.0.0~a1~dev13 is valid).
In the .spec file, the 'Version' tag will be set to '5.0.0.0~a1~dev13'
but we still need the unconverted version '5.0.0.0a1.dev13' because this
is the version which will be use in the '%setup' section to enter the
correct directory during the setup step. So the setup section should
then look like '%setup -q -n %{component}-%{unconverted_version}'
In addition to the current tests running with zypper, also test that the
generated versions are compatible with dpkg.
Also improve the assertion output in case of a test failure.
Python's PEP440 compatible versions can look like "1.1alpha" which means
in the pip world (pip is python's package manager), that "1.1 >
1.1alpha". Comparing the same version with rpm, the result is
"1.1alpha > 1.1". This commit adds code to convert PEP440 versions to
rpm versions without loosing the correct version compare semantics.
Currently only test tarballs with empty directories can be created. This
commit also allows to add empty files to the test tarball. This is
needed for package type detection tests.
For the following reasons:
- integration of https://github.com/openSUSE/\
obs-service-set_version_pysemver simpler
- testsuite is in python
- try "import this" to get more reasons :)
When we are searching for the version number we want to visit the least
recently modified file first. Therefore we shall sort the readdir result
based on the modification timestamp.
Signed-off-by: Jan Blunck <jblunck@infradead.org>
For Debian builds the primary location of the package version number is the
changelog file. In some cases where set_version is used in combination with
tar_scm's versionformat parameter it might be required to amend the
Debian changelog as well. Later during the build debtransform will assemble
the correct format of the sources.
Signed-off-by: Jan Blunck <jblunck@infradead.org>
We need to check for an empty @files array before we start filtering. We
shall not reset the @files array when filtering the list.
Signed-off-by: Jan Blunck <jblunck@infradead.org>