gradle-ospackage-plugin icon indicating copy to clipboard operation
gradle-ospackage-plugin copied to clipboard

addParentDirs assignment not working

Open jonpeterson opened this issue 8 years ago • 3 comments

CopySpecEnhancement.addParentDirs(...) works. CopySpecEnhancement. setAddParentDirs(...) does not work.

As of 4.4.0: Using:

from("${project.projectDir}/src") {
   into '/opt/test/abc'
   fileMode = 0400
}

rpm -qlp returns:

/opt/test
/opt/test/abc
/opt/test/abc/something.txt

CORRECT

Using:

from("${project.projectDir}/src") {
   into '/opt/test/abc'
   fileMode = 0400
   addParentDirs false
}

rpm -qlp returns:

/opt/test/abc/something.txt

CORRECT

Using:

from("${project.projectDir}/src") {
   into '/opt/test/abc'
   fileMode = 0400
   addParentDirs = false
}

rpm -qlp returns:

/opt/test
/opt/test/abc
/opt/test/abc/something.txt

INCORRECT

4.2.0 addParentDirs false FAIL addParentDirs = false FAIL

4.3.0 addParentDirs false PASS addParentDirs = false FAIL

4.4.0 addParentDirs false PASS addParentDirs = false FAIL

jonpeterson avatar May 26 '17 17:05 jonpeterson

To further narrow this down, I just noticed the above behavior is only happening in ospackage blocks, not in buildRpm blocks.

jonpeterson avatar May 26 '17 17:05 jonpeterson

I wonder if this is related to a problem I found today with ospackage and addParentDirs.

Setting addParentDirs within ospackage block is not respected within each RPM task. I have tried both approaches mentioned above.

ospackage {
    vendor = vendorName
    version = applicationVersion
    release = applicationRelease
    license = 'Commercial'

    url = vendorUrl
    packager = vendorPackager
    prefix "/opt/company/"

    os = "LINUX"
    user = "root"
    permissionGroup = "root"

    addParentDirs = false
}

task createJavaWebstartPackage(type: Rpm) {
    packageName = projectName + '-webstart'
    packageDescription = 'Java Web start files for ' + applicationName
    summary = applicationName + ' Webstart'

    into('/etc/apache2/conf.d') {
        from(buildDir.name + '/resources/main/deploy/webstart') {
            include '*.conf'
        }
    }
}

I have another RPM task, which is why I wanted common configuration within the ospackage block.

The RPM is created with directories for the entire path.

/etc/apache2
/etc/apache2/conf.d
/etc/apache2/conf.d/application.conf

For it to work I have to set addParentDirs within the createJavaWebstartPackage.

DJViking avatar Jun 12 '18 14:06 DJViking

Seems that this bug is coming from this line : https://github.com/nebula-plugins/gradle-ospackage-plugin/blob/main/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy#L70

        // Could come from extension
        mapping.map('fileType', { parentExten?.getFileType() })

       //  HERE : if  `ospackage.addParentDirs` is not set, or set to `false`, condition  parentExten?.getAddParentDirs()?  will return `false`, so mapping will be assigned to `true` ..
  => 
        mapping.map('addParentDirs', { parentExten?.getAddParentDirs()?:true })

mricciuti avatar Oct 25 '22 21:10 mricciuti