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

requires containing '~=' result in broken spec file #183

Open
M0ses opened this issue Nov 16, 2023 · 4 comments · May be fixed by #184
Open

requires containing '~=' result in broken spec file #183

M0ses opened this issue Nov 16, 2023 · 4 comments · May be fixed by #184

Comments

@M0ses
Copy link
Contributor

M0ses commented Nov 16, 2023

In spec files ~= is not an valid operator to compare versions and I didn`t find anything about debian dsc-files

Here is a first draft how it could be fixed, but it would need more work

    for req in filtered_req_list:
        # Convert '~=' operator to something rpm understands
        # abc ~= 1.1.1 
        # should be converted into something like
        # python-abc >= 1.1.1, python-abc < 1.2
        # but not for build-requires 
        if req[1] == '~=':
            req[1]='>='
            v = req[2].split('.')
            v.pop()
            v[-1] = str(int(v[-1]) + 1)
            req.append(", %s < %s" % (req[0], ".".join(v)))
        out_list.append(req)

TODO:

  1. Distinguish build_requires/install_requires
  2. handle requirement output for dsc and spec different

I could help with the implementation.
I just wanted to start a discussion what the best way to handle it before starting the implementation.

@s-t-e-v-e-n-k
Copy link

Quoting https://www.debian.org/doc/debian-policy/ch-relationships.html:

The relations allowed are <<, <=, =, >= and >> for strictly earlier, earlier or equal, exactly equal, later or equal and strictly later, respectively. The exception is the Provides field, for which only = is allowed.

To answer your Debian .dsc files question

@M0ses
Copy link
Contributor Author

M0ses commented Nov 16, 2023

@s-t-e-v-e-n-k I already seen it.
Do you know if something like the following would work in dsc?

Depends: python-abc (>= 1.1.1, < 1.2)
or
Depends: python-abc (>= 1.1.1 < 1.2)

@s-t-e-v-e-n-k
Copy link

Neither:

Depends: python-abc (>= 1.1.1), python-abc (< 1.2)

@M0ses
Copy link
Contributor Author

M0ses commented Nov 17, 2023

@s-t-e-v-e-n-k
Thanks for clarification, this is how I implemented it in my first draft.
Just for the record:
I guess you meant
Depends: python-abc (>= 1.1.1), python-abc (<< 1.2)
(Sorry for my nitpicking)

M0ses added a commit to M0ses/py2pack that referenced this issue Nov 17, 2023
As described in openSUSE#183 '~=' is not a valid version specifier for rpm and
deb packages.

This patch converts the specifier to valid version specifiers for
rpm/deb.

Examples:

`abc ~= 1.1.1`

* in rpm:

```
BuildRequires: %{python_module abc >= 1.1.1} # Only for suse
Requires: python-abc >= 1.1.1, python-abc < 1.2
```

* in deb:

```
Depends: python-abc (>= 1.1.1), python-abc (<< 1.2)
```

FIXES: openSUSE#183
An schould also fix
FIXES: openSUSE#93
@M0ses M0ses linked a pull request Nov 17, 2023 that will close this issue
M0ses added a commit to M0ses/py2pack that referenced this issue Aug 8, 2024
As described in openSUSE#183 '~=' is not a valid version specifier for rpm and
deb packages.

This patch converts the specifier to valid version specifiers for
rpm/deb.

Examples:

`abc ~= 1.1.1`

* in rpm:

```
BuildRequires: %{python_module abc >= 1.1.1} # Only for suse
Requires: python-abc >= 1.1.1, python-abc < 1.2
```

* in deb:

```
Depends: python-abc (>= 1.1.1), python-abc (<< 1.2)
```

FIXES: openSUSE#183
An schould also fix
FIXES: openSUSE#93
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 a pull request may close this issue.

2 participants