Newer versions of dpkg-buildpackages are more strict in checking that
the Debian package format is consistent.
Always appending a -0 to the version causes a native package, which
must not have a - in the version, to fail to build.
Append -0 conditionally on a simple check: if the original version
has a - character then it's non-native and it's safe to add -0.
In order to do this check a new version detection static method is
added, to parse the .dsc file for the Version tag.
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}'
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.
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>
If a tarball doesn't include a version number in it's filename, it is
worth checking it's contents. If the tarball has a root-directory, it is
usually named $BASENAME-$VERSION.