Skip to content

Conversation

@rnc
Copy link
Collaborator

@rnc rnc commented Apr 17, 2025

The reason for this enhancement is that if we have a typical RH version e.g. 1.1.0.redhat-00001 then that utilises illegal characters in the version string - so this PR allows for an optional set of user-defined replacements for such characters.

<version>1.0.1.redhat-00001</version>
<packaging>jar</packaging>

<name>Test Package #20</name>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be Test 21, not 20.

Comment on lines 7 to 9
String text = log()
return text.contains("Version : 1.0.1.redhat_00001") &&
text.contains("Source RPM : test21-modifyversion-1.0.1.redhat_00001-1.src.rpm")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works OK, but you could pull out just the text you need to make the comparison a little easier with

 Process proc = ['rpm', '-q', '--queryformat', '"%{VERSION} %{SOURCERPM}"' ]

then check

text == "1.0.1.redhat_00001 test21-modifyversion-1.0.1.redhat_00001-1.src.rpm"

version = version.replaceAll(versionSubstitution.search, versionSubstitution.replace);
}
}
return new RpmVersion(this.epoch, version, this.release);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the version is invalid, it could eventually be detected here. Technically, the output filename doesn't have to be a valid RpmVersion, which means we would have to change RpmFileNameProvider to use String instead of RpmVersion, or it would fail at that point with using the non-transformed version (since makeVersion called with false there).

Copy link
Collaborator Author

@rnc rnc May 14, 2025

Choose a reason for hiding this comment

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

I didn't want to change the output file name as that is what is used in maven storage (and is legal). I'm guessing you're referring to eclipse/packager#76 which would break rpm-builder here if an invalid version is used ; I'm beginning to think the validation might actually cause more problems that it solves. Note also RpmFileNameProvider uses the RpmVersion to extract the release as well as the version.

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.

2 participants