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

RFE: Convenient %version without tilde macro #1219

Closed
hroncok opened this issue May 13, 2020 · 10 comments
Closed

RFE: Convenient %version without tilde macro #1219

hroncok opened this issue May 13, 2020 · 10 comments

Comments

@hroncok
Copy link
Contributor

hroncok commented May 13, 2020

@ignatenkobrain has has created this in Fedora's rust-srpm-macros:

%version_no_tilde() %{lua:
    local sep = rpm.expand('%1')
    local ver = rpm.expand('%2')
\
    if sep == '%1' then
        sep = '-'
    end
\
    if ver == '%2' then
        ver = rpm.expand('%version')
    end
    ver = ver:gsub('~', sep)
\
    print(ver)
}

I'd like to have something like this part of the standard issued macros. However, I think the default should be empty separator for 2 reasons:

  • the name of this macro suggests there is no tilde, not that the tilde is replaced with anything
  • it seem incredibly hard to pass an empty string as a macro argument (I haven't figured out how to do that yet)

WDYT?

@pmatilai
Copy link
Member

pmatilai commented May 14, 2020

This was actually suggested here first (see #722) and rejected in this form with the notion that there might be something there however. So of the problem is figuring what that "something like" is.

Singling out tilde seems odd. I could imagine there being cases where you want these "rpm embellishments" stripped out, but that should then also cover caret (and any other such thing that might get added in the future), which calls for a more generic name. "Upstream version" was mentioned in the PR, but that doesn't sound right either because the tilde/caret parts typically are from upstream. Something like "bare version" (any phonetic resemblance to large four feet mammals is purely coincidental), but this all makes me think we're going backwards here, and that we should start by disassembling Version to its components at the "source" already.

There's this "main" or "bare" version which is typically something like [major[.minor[.micro[.nano]]]] and these can have pre- and post-modifiers that affect the sorting. Should spec have separate tags to declare these as individual components that rpm arranges into a Version as we know it? Or something...

As for passing passing empty strings (or strings with spaces etc) as a macro argument, use %{quote:}

@hroncok
Copy link
Contributor Author

hroncok commented May 14, 2020

I get your point. But before we come ou with a concept of native "pre/post tag", I think we should have a way to address this in a common way. I like %{bare_version} (not "ursine" please).

@hroncok
Copy link
Contributor Author

hroncok commented May 14, 2020

As for passing passing empty strings (or strings with spaces etc) as a macro argument, use %{quote:}

Thanks. Ugly, but works.

@ignatenkobrain
Copy link
Contributor

I think %{upstream_version} would be better. However, probably in this case, we should just define %{pypi_version}, %{semver_version} because those have different rules.

@pmatilai
Copy link
Member

As I noted above, the problem with "upstream version" is that the pre/post suffixes are upstream. So upstream version and the bare version are two different things.

@hroncok
Copy link
Contributor Author

hroncok commented May 14, 2020

technically, since we are at RPM level, I wouldn't mind having this syntax:

%{version/~/}

To remove whatever symbols I like.

@hroncok
Copy link
Contributor Author

hroncok commented Feb 8, 2021

What about this:

%{strip %{version} ~^}

Would that fly? Or should I include it in python-srpm-macros instead?

@hroncok
Copy link
Contributor Author

hroncok commented Aug 26, 2021

See also #1764

hroncok added a commit to hroncok/rpm that referenced this issue Aug 26, 2021
Examples:
  %{gsub 3.1~~dev1 ~} -> 3.1dev1
  %{gsub 2.3^post5 ^ -} -> 2.3-post5
  %{gsub foo_bar [^%%w]+ -} -> foo-bar
  %{gsub aaa a b 2} -> bba
  %{gsub dummy} -> dummy
  %{gsub} -> (empty string)

Related to rpm-software-management#1219
Related to https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/101
@dmnks dmnks self-assigned this Nov 2, 2023
@dmnks
Copy link
Contributor

dmnks commented Nov 7, 2023

I believe this is now fixed with #2181, closing.

@dmnks dmnks closed this as completed Nov 7, 2023
@dmnks
Copy link
Contributor

dmnks commented Nov 8, 2023

OK, "fixed" might be an overstatement, given that the original request was more about the ability to extract the plain version from a string containing a tilde (AIUI) than about adding primitives to be able to do that (which #2181 does). In any case, something similar is being discussed here: #2715.

@dmnks dmnks removed their assignment Nov 8, 2023
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

No branches or pull requests

4 participants