1

I have the following buildscript and I need to force directory permissions and create an empty directory. I found on many places that the following code should work, but it does not. Any hints whats wrong?

buildscript {
    dependencies {
        classpath 'com.netflix.nebula:gradle-ospackage-plugin:4.8.0'
    }
    repositories {
        jcenter()
    }
}
apply plugin: 'nebula.ospackage'

ospackage {
    def userName = 'myapp'
    def userRoot = 'root'
    preInstall "id -u ${userName} &>/dev/null || useradd ${userName}"

    packageName = "myapp"
    version = project.version
    release = '40'
    arch = NOARCH
    os = LINUX

    user = userRoot
    permissionGroup = userName

    directory('/opt/myapp/aaa', 0750) //directory not created
    from("src/config") {
        into('/opt/myapp/etc')
        dirMode 0750 // directory in RPM has drwxr-xr-x
    }

    requires("shadow-utils", "4.1.5.1", 0x04|0x08)
}

build.dependsOn(buildRpm)

After some more investigation this seems to be a bug, I have created an issue in Nebula GitHub.

malejpavouk
  • 4,297
  • 6
  • 41
  • 67

1 Answers1

1

I'm pretty sure that the directory() construct does not work in the ospackage closure. You'll have to add an Rpm type closure to do this.

See the Rpm section of the docs and this ticket.

apply plugin: 'nebula.rpm'

task fooRpm(type: Rpm) {
    directory('/opt/myapp/aaa', 0750)
}

If you want a Debian package, apply the same but in a block of type:Deb.

Jolta
  • 2,620
  • 1
  • 29
  • 42