Navigation Menu

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

RPM can't be built if project version contains '-' character #49

Closed
sshcherbakov opened this issue Sep 5, 2014 · 17 comments
Closed

RPM can't be built if project version contains '-' character #49

sshcherbakov opened this issue Sep 5, 2014 · 17 comments

Comments

@sshcherbakov
Copy link

Hello all,

just run into as issue when building an RPM using plugin version 1.12.2 and Gradle 1.12.
My project has '.BUILD-SNAPSHOT' in the version.
The buildRpm task fails with the message in this case:

12:58:10.158 [ERROR] [org.gradle.BuildExceptionReporter] > version with value: '1.1.2.9.BUILD-SNAPSHOT' contains illegal character -
...
2:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException: version with value: '1.1.2.9.BUILD-SNAPSHOT' contains illegal character -
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter]    at org.freecompany.redline.Builder.checkVariableContainsIllegalChars(Builder.java:229)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter]    at org.freecompany.redline.Builder.setPackage(Builder.java:246)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter]    at com.netflix.gradle.plugins.rpm.RpmCopyAction.startVisit(RpmCopyAction.groovy:54)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter]    at com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction.execute(AbstractPackagingCopyAction.groovy:43)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)

Setting version explicitly to a value without '-' doesn't help:

ospackage {
version = '1.2.3'

Only if I change the main Gradle project version I get the RPM built.
Is this something that needs to be fixed?

@quidryan
Copy link
Contributor

quidryan commented Sep 5, 2014

IIRC, a dash is not legal in a RPM version number, and hence the check. So
that makes sense.

You should be able to set the version in the way you suggested though, so
if that's not working, that's a bug. Can you also try buildRpm.version =
'1.2.3'?

On Fri, Sep 5, 2014 at 4:06 AM, sshcherbakov notifications@github.com
wrote:

Hello all,

just run into as issue when building an RPM using plugin version 1.12.2
and Gradle 1.12.
My project has '.BUILD-SNAPSHOT' in the version.
The buildRpm task fails with the message in this case:

12:58:10.158 [ERROR] [org.gradle.BuildExceptionReporter] > version with value: '1.1.2.9.BUILD-SNAPSHOT' contains illegal character -
...
2:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException: version with value: '1.1.2.9.BUILD-SNAPSHOT' contains illegal character -
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] at org.freecompany.redline.Builder.checkVariableContainsIllegalChars(Builder.java:229)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] at org.freecompany.redline.Builder.setPackage(Builder.java:246)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] at com.netflix.gradle.plugins.rpm.RpmCopyAction.startVisit(RpmCopyAction.groovy:54)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] at com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction.execute(AbstractPackagingCopyAction.groovy:43)
12:58:10.164 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)

Setting version explicitly to a value without '-' doesn't help:

ospackage {
version = '1.2.3'

Only if I change the main Gradle project version I get the RPM built.
Is this something that needs to be fixed?


Reply to this email directly or view it on GitHub
#49.

@sshcherbakov
Copy link
Author

Tried

ospackage {
    buildRpm.version = "1.2.3"
    ...
}

and

buildRpm {
    version = "1.2.3"
    ...

Unfortunately, same result: "illegal character -" if the main project version contains a minus.

@ccampo133
Copy link

Try

ospackage {
    version = "1.2.3"
    ...
}

That worked for me. As stated earlier, hypen is an illegal RPM character so it should be stripped.

@sshcherbakov
Copy link
Author

Tried that as first attempt (please see initial description).
Tried as Java as well as Groovy String value.

It is fully OK, that dash is illegal character in RPM name. The problem is that the dash is a legal Gradle project version character. And I don't see why RPM version must be same as Gradle project version.

As far as I can tell, this wasn't a problem at times of TrigonicSolution plugin

The check that throws exception looks to be in the Redline library. The dash must not be passed to Redline, I guess. I'll try to find time a bit to dig in and find the reason for this behaviour.

@ccampo133
Copy link

That's strange that you're having that issue. If I specify the version property (i.e. version = "1.2.3") in either the ospackage or buildRpm task, it overrides the project version and works correctly. I'm using 1.12.2 and Gradle 1.12.

A quick workaround for you would be to change your version from "1.2.3-SNAPSHOT" to "1.2.3.SNAPSHOT". Both are valid Java version conventions so at least you're covered there.

@sshcherbakov
Copy link
Author

Sure, thanks. That's how I workaround this at the moment.

@bmuschko
Copy link
Contributor

@sshcherbakov Can you try the latest 2.2.x version of the plugin? We built in some validation for RPM versions.

@sshcherbakov
Copy link
Author

@bmuschko it looks like the 2.2.x version is not compatible with Gradle 1.12 that we are still on:

A problem occurred evaluating root project 'rti-t-gfxd'.
> org/codehaus/groovy/runtime/typehandling/ShortTypeHandling

It will take some time to migrate the build script to the Gradle 2.x

@bmuschko
Copy link
Contributor

@sshcherbakov That is correct. We won't continue putting fixes into the 1.12.x branch. You'll need to upgrade your project.

@bmuschko
Copy link
Contributor

bmuschko commented Jun 9, 2015

@sshcherbakov Did you have a chance to test out the latest version? I guess we'll close the issue if we don't hear back from you.

@shollander
Copy link

@bmuschko

I am having the same problem with trying to override the project version and rpm not "seeing" the new version. I have a multi-module gradle project. When I build an individual module it works without a problem, but when I build the entire project from the top (all modules) then rpm does not get the modified version.

@DALDEI
Copy link
Contributor

DALDEI commented Aug 20, 2015

I have logged a bug that may be related. It seems some combination of gradle and ospacakage are 'overly aggressive' at caching. If I make a build only or script only change it doesnt take without a clean.

As for versioning I run into confusion over the scope of properties, and trying to integrate the publishing with S3 , Ivy and Artifactory -- all have different naming conventions and rules for versions.
RPM must not have a '-' in the version or revision, its debatable if its a good idea to have a dash in the 'name', some references claim you shouldnt but I find lots of packages that do and it works.
This is whats working for me now. I found I needed to use different property names and explicitly prefix them in some places. Probably overkil but I cant figure out where the collisions are and from what modules so this works for me:

First ... for consistancy in the main project I define a Version class

class Version {
    //String originalVersion
    String version
    String originalRelease
    String release
    String revision
    String status
    Date buildTime
    String publishDir = 'dev'

    Version(  String versionValue , String releaseValue ) {
        buildTime = new Date()
        version = versionValue
        originalRelease = releaseValue

        if (releaseValue.endsWith('-SNAPSHOT')) {
            status = 'integration'
            publishDir = 'dev'
            release = releaseValue.substring(0, releaseValue.length() - '-SNAPSHOT'.length()) + '.' + getTimestamp()
        } else {
            status = 'release'
            release = releaseValue
           // publishDir = 'release'
        }
        // RPM format name-[ver-release].arch.ext
        revision = "${version}-${release}"

    }

    String getTimestamp() {
        // Convert local file timestamp to UTC
        def format = new SimpleDateFormat('yyyyMMddHHmmss')
        format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));
        return format.format(buildTime)
    }

    String toString() {
    }
}

Then in allProjects I create an ext property

allprojects {
   apply plugin: 'net.saliman.properties'
   apply plugin: 'eclipse'
   apply plugin: 'com.jfrog.artifactory'
   group = 'com.me.com'
   ext {
      version = new Version( "${project.version}" , "${project.release}" )
      rpmVersion = version.version
      rpmRelease = version.release
      module  = project.name 
      rpmPackage = 'nexstra-' + module
   }

   status = ext.version.status
   version = ext.version;
}

then I apply subprojects a generic buildRpm task

task buildRpm(type: Rpm) {
    packageName project.ext.rpmPackage 
    version  project.ext.rpmVersion
    release  project.ext.rpmRelease
    arch NOARCH
    os LINUX
    user 'root'
    permissionGroup 'root'
    createDirectoryEntry false
    addParentDirs false
    duplicatesStrategy DuplicatesStrategy.WARN
...
}

In the child project all I do is add the copyspecs
In subproject 'fop'

buildRpm {
  requires 'jdk'
  fileMode 0550
  user 'root'
  group 'root'

  into('/'){
    into('usr/local/'){
      from ( tarTree(resources.gzip('dist/fop-0.94.tar.gz'))  )
    }
    from ('install.d/' ) 
  }
  link( '/usr/local/fop' , '/usr/local/fop-0.94' )
}

@shollander
Copy link

As mentioned earlier, I had been experiencing this issue. I discovered that by using the ospackage dsl to define the version and release instead of doing it in the Rpm task fixed the problem. Seems to me that this would still be a bug that should be fixed, but at least I have a workaround.

@ajeets1978
Copy link

I am using the latest version 3.2.1, still see the same issue. Rather more than that nebula-release plugin generates -SNAPSHOTs, which is what i am trying to use for nebula-ospackage as well the same version for my RPMs. It throws an error ~ is an illegal character. Its replacing - with ~ signs :(

@farrukhnajmi
Copy link

I am using version 4.2.2 and still seeing this problem. BTW, AFAIK '-' is a valid rpm version character and I see it used in a whole bunch of rpms on my Fedora system when I do a "rpm -qa | less" command. I would be grateful for a high priority fix for this issue as it is a blocker for me. I do not have option to use workaround as versionNames are set by the customer product and I have no say in the conventions used. TIA.

@leoneves
Copy link

I'm using version 4.1.0 and has same issue.
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':buildRpm'.

version with value: '1.3.14~SNAPSHOT' contains illegal character ~

@sghill
Copy link
Contributor

sghill commented Dec 27, 2016

rpm.org's docs state - is not valid for a version or release:

The only restriction placed on the version is that it cannot contain a dash "-".

The release can be thought of as the package's version. [...] Like the version number, the only restriction is that dashes are not allowed.

In addition to the workarounds proposed above in this thread, it's also possible to replace all the illegal characters in an auto-calculated version:

def sanitizedVersion = version.toString().replaceAll('(~|-)', '') // or an allowable character like ':' or '+' 

ospackage {
    version sanitizedVersion
    // ...
}

The ~ issue mentioned in recent comments is being tracked by #213.

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

10 participants