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

prjconf Release: breaks debs’ debian revision #695

Open
drmuey opened this issue Jun 1, 2021 · 4 comments
Open

prjconf Release: breaks debs’ debian revision #695

drmuey opened this issue Jun 1, 2021 · 4 comments

Comments

@drmuey
Copy link

drmuey commented Jun 1, 2021

TL;DR:

Doing the classic Release: %%{?release_prefix}.<CI_CNT>.<B_CNT> in prjconf breaks debian revision.

  1. set OBS-DCH-RELEASE: 1:
    • 🟢 deb is VERSION+release_prefix.<CI_CNT>.<B_CNT>
    • 🔴 rpm is VERSION-release_prefix
  2. add Release: %%{?release_prefix}.<CI_CNT>.<B_CNT> in prjconf
    • 🔴 deb is VERSION+release_prefix.
    • 🟢 rpm is VERSION-release_prefix.<CI_CNT>.<B_CNT>

Details:

Oultined here ➜ https://forums.opensuse.org/showthread.php/554631

Cause?

I believe is caused by this line being too greedy and clearing Release completely:

DEB_RELEASE=`sed 's/%.*$//' <<< $RELEASE`

Using this regexp (properly escaped of course) would demonstrate if that belief was justified or not: s/%+\{[^}]+}\.?// (should allow the classic example to work but is a bit naive still)

There is probably a better regexp or logic to “remove rpm macros” as the comment above that line says its intent.

something like this for example: s/(\.)?%+\{[^}]+}(\.)?/$1 && $2 ? $2 : ""/eg would cover multiples

In addition to multiples they can be nested too of course

@ColMelvin
Copy link

ColMelvin commented Jun 1, 2021

To handle macros with macros embedded in them, e.g. %{expand: %%{mymacro}%%{mysuffix}}, there will need to be a more complicated regex. An example (in Perl) might be:

s/
    (?(DEFINE)
        (?<MACRO> %\{ (?&EXPANSION) \} | %(?&VARIABLE) | %\*\* | %[*#%] )
        (?<EXPANSION> [^%]+ | [^%]* (?: (?&MACRO) [^%]* )+ )
        (?<VARIABLE> \w+ )
    )
    (?&MACRO)\.?
//xg;

I don't think this solution will work well with parameterized macro calls (e.g %mymacro 5), so further iteration may be required.

@drmuey
Copy link
Author

drmuey commented Jun 1, 2021

@ColMelvin and I were able to verify that this is indeed the problem 👍

We get it to work w/ a simplified regex that will only work on the classic prjconf Release: %%{?release_prefix}.<CI_CNT>.<B_CNT> (lots of escape issues and special character oddness leyt along complexities of macro format).

First, thi sgot us the correct DEB_RELEASE:

--- build-recipe-dsc.orig	2021-06-01 12:49:32.606955951 -0500
+++ build-recipe-dsc	2021-06-01 14:42:17.490308842 -0500
@@ -49,7 +49,10 @@
     done
     # remove rpm macros (everything after "%")
     # they are not evaluated by the Debian build process
-    DEB_RELEASE=`sed 's/%.*$//' <<< $RELEASE`
+    DEB_RELEASE=`sed 's/%..release_prefix..//' <<< $RELEASE`
     OBS_DCH_RELEASE=""
 
     if test -n "$DEB_TRANSFORM" ; then 
     ```
     
Some debuggery showed that `DEB_RELEASE` correctly had `%{?release_prefix}.` removed but we still had an error like `version '1.0-53+%{?release_prefix}.53.2.cpanel' is invalid: version number`.

That seemed to indicate something was using `RELEASE` when it should be using `DEB_RELEASE` (a second bug maybe?) so we tried this patch:

--- build-recipe-dsc.orig 2021-06-01 12:49:32.606955951 -0500
+++ build-recipe-dsc 2021-06-01 14:56:04.743476406 -0500
@@ -49,7 +49,11 @@
done
# remove rpm macros (everything after "%")
# they are not evaluated by the Debian build process

  • DEB_RELEASE=sed 's/%.*$//' <<< $RELEASE
  • RELEASE=sed 's/%..release_prefix..//' <<< $RELEASE
  • DEB_RELEASE=$RELEASE
  • OBS_DCH_RELEASE=""
    if test -n "$DEB_TRANSFORM" ; then
and it worked!

by “worked” I mean:

* version is 1.0, `release_prefix` is 53 (in debian/ by virtue of the changelog)
* projconf had `Release: %%{?release_prefix}.<CI_CNT>.<B_CNT>`
* `.dsc` had `OBS-DCH-RELEASE: 1`
   * this will also fix it for anyone using `DEB_TRANSFORM` and not `OBS-DCH-RELEASE`
* when they built:
    * 🟢 RPM was v1.0-53.53.4
    * 🟢 deb was v1.0-53+53.2

HTH, thanks!

@drmuey
Copy link
Author

drmuey commented Jun 1, 2021

Perhaps Iteration 1 is: support the standard Release: %%{?release_prefix}.<CI_CNT>.<B_CNT> for debs

Then Iteration 2: make the regexp smarter

If that sounds like a good plan I’d be happy to do a pull request (NTS ¿backport to 2.10 so no maintaining patch locally?)

@drmuey
Copy link
Author

drmuey commented Jun 9, 2021

PR #698

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

2 participants