Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove code which corrupts versions #388

Closed
wants to merge 1 commit into from
Closed

Remove code which corrupts versions #388

wants to merge 1 commit into from

Conversation

olafhering
Copy link
Contributor

A _service file which intends to use @PARENT_TAG@ for the package
version, and which uses versionrewrite-pattern to process the tag
further, will be unable to process the full tag name to extract the
desired parts of it via versionrewrite-replacement. The reason is the
forced removal of all hyphens.

It is up to the author of the _service file how the final package
version is assembled. versionrewrite-pattern and
versionrewrite-replacement give control how this needs to be done.

Remove all of the offending code, which should have been removed along
with the changes that introduced versionrewrite in commit
960d0ce.

Fixes issue #367

Signed-off-by: Olaf Hering [email protected]

@olafhering olafhering requested review from M0ses and darix January 13, 2021 09:05
"""Automatic detection of version number for checked-out repository."""

version = self.scm_object.detect_version(self.args.__dict__).strip()
version = self.scm_object.detect_version(self.args.__dict__, truncate_at_hyphen).strip()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (96 > 79 characters)

A _service file which intends to use @PARENT_TAG@ for the package
version, and which uses versionrewrite-pattern to process the tag
further, will be unable to process the full tag name to extract the
desired parts of it via versionrewrite-replacement. The reason is the
forced removal of all hyphens.

It is up to the author of the _service file how the final package
version is assembled. versionrewrite-pattern and
versionrewrite-replacement give control how this needs to be done.

Adjust detect_version to keep hyphens if the _service file uses
versionrewrite-pattern, which should have been done along with the
changes that introduced versionrewrite in commit
960d0ce.

Fixes issue #367

Signed-off-by: Olaf Hering <[email protected]>
@hramrach
Copy link
Contributor

Any progress here?

The failing test is python2 based. Is it even maintained? The failure looks like test setup problem.

@olafhering
Copy link
Contributor Author

I can probably fix this by passing the property not as argument, but stuffing it somewhere else so that the actual consumers can grab it.

Any idea what place that would be?

@M0ses
Copy link
Collaborator

M0ses commented Jan 25, 2021

The failing test is python2 based. Is it even maintained?

short answer: yes.
obs-service-tar_scm has to run (at least) on all maintained versions *SUSE versions (because of buildtime services).

The failure looks like test setup problem.

Why? Because of pyhton2 support?

@M0ses
Copy link
Collaborator

M0ses commented Jan 25, 2021

I can probably fix this by passing the property not as argument, but stuffing it somewhere else so that the actual consumers can grab it.

Any idea what place that would be?

I`m wondering if this should be something which the user should be able to configure, in this case a new parameter would be needed. @adrianschroeter : What do you think.

BTW: test cases would be useful to understand the problem better.

@hramrach
Copy link
Contributor

hramrach commented Jan 25, 2021

Also it does not work. I applied the patch and I get version with a hyphen:

Index: mlxbf-bootctl.obsinfo
===================================================================
--- mlxbf-bootctl.obsinfo (revision 338286a3367c7b644f23bce59dabeff9)
+++ mlxbf-bootctl.obsinfo (working copy)
@@ -1,5 +1,5 @@
name: mlxbf-bootctl
-version: 1.16.11
+version: mlxbf-bootctl-1.1-6.11
mtime: 1601841854
commit: b6dd3501668c45020f1e81690cd53aa6e21289b0

Index: mlxbf-bootctl.spec
===================================================================
--- mlxbf-bootctl.spec (revision 338286a3367c7b644f23bce59dabeff9)
+++ mlxbf-bootctl.spec (working copy)
@@ -18,7 +18,7 @@


Name: mlxbf-bootctl
-Version: 1.16.11
+Version: mlxbf-bootctl-1.1-6.11
Release: 0
Summary: User-space driver for Mellanox BlueField SoC
License: BSD-2-Clause

@hramrach
Copy link
Contributor

hramrach commented Jan 25, 2021

Also it breaks vesionrewrite-pattern

<!-- See https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService -->
<!-- for more details on the syntax -->

<services>
        <service name="obs_scm" mode="disabled">
                <param name="scm">git</param>
                <param name="url">https://github.com/Mellanox/mlxbf-bootctl.git</param>
                <param name="filename">mlxbf-bootctl</param>
                <param name="versionrewrite-pattern">mlxbfbootctl(.*)</param>
                <param name="versionformat">@PARENT_TAG@.@TAG_OFFSET@</param>
        </service>
        <service mode="disabled" name="set_version" />
        <service name="tar" mode="buildtime"/>
</services>

@olafhering
Copy link
Contributor Author

What does it break? What is the input, what is the expected output?

The goal is to pass the tag verbatim into versionrewrite-pattern.

@hramrach
Copy link
Contributor

Nevermind, the tag was previously butchered by removing hyphens and now it is not so the pattern must be amended to also contain the hyphens.

@olafhering
Copy link
Contributor Author

I`m wondering if this should be something which the user should be able to configure, in this case a new parameter would be needed. @adrianschroeter : What do you think.

You mean a I really mean it knob? Usage of versionrewrite-pattern and versionrewrite-replacement is already a clear instruction what is expected to happen.

@M0ses
Copy link
Collaborator

M0ses commented Jan 25, 2021

I`m wondering if this should be something which the user should be able to configure, in this case a new parameter would be needed. @adrianschroeter : What do you think.

You mean a I really mean it knob? Usage of versionrewrite-pattern and versionrewrite-replacement is already a clear instruction what is expected to happen.

Could you please explain the input and the expected output, in best case by a test case? I think I didn`t get the point of your commit.

@olafhering
Copy link
Contributor Author

It must be possible to extract the individual parts of the verbatim tag. It is not up to tar_scm to decide if a hyphen is bad or not. That is entirely the responsibility of the _service file author, and a task of versionrewrite-pattern and versionrewrite-replacement.

@hramrach
Copy link
Contributor

Indeed, it works with this service file:

<!-- See https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService -->
<!-- for more details on the syntax -->

<services>
        <service name="obs_scm" mode="disabled">
                <param name="scm">git</param>
                <param name="url">https://github.com/Mellanox/mlxbf-bootctl.git</param>
                <param name="filename">mlxbf-bootctl</param>
                <param name="versionrewrite-pattern">mlxbf-bootctl-(.*)-(.*)</param>
                <param name="versionrewrite-replacement">\1.\2</param>
                <param name="versionformat">@PARENT_TAG@.@TAG_OFFSET@</param>
        </service>
        <service mode="disabled" name="set_version" />
        <service name="tar" mode="buildtime"/>
</services>

Nonetheless, removing hyphens was done to prevent invalid version, and it does not happen automatically anymore. This could be seen as a regression. Maybe an error should be reported when the resulting version contains a hyphen?

@olafhering
Copy link
Contributor Author

rpm will report an error on bogus input.

@hramrach
Copy link
Contributor

I`m wondering if this should be something which the user should be able to configure, in this case a new parameter would be needed. @adrianschroeter : What do you think.

You mean a I really mean it knob? Usage of versionrewrite-pattern and versionrewrite-replacement is already a clear instruction what is expected to happen.

Could you please explain the input and the expected output, in best case by a test case? I think I didn`t get the point of your commit.

The problem is that upstream uses Debian style release tags such as 1.1-6 but does not adhere to the Debian policy to include only packaging changes in release (-n) and general changes in version (1.1). Hence the -n is significant. tar_scm further slaps the number of commits since the tag at the end 1.1-6.11 (as requested) and silently removes hyphens without any user control -> 1.16.11. This is clearly bogus. Trivially replacing the hyphen with dot gives valid version 1.1.6.11 but there is no way to achieve that with tar_scm.

@hramrach
Copy link
Contributor

rpm will report an error on bogus input.
Clearly there was an attempt to mitigate this in the service itself before that happens.

@M0ses
Copy link
Collaborator

M0ses commented Feb 2, 2021

I opened another PR how I would solve the problem without the risk of tons of broken packages

#390

comments are welcome

@M0ses
Copy link
Collaborator

M0ses commented Feb 10, 2021

superseded by 2fdf897

@M0ses M0ses closed this Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants