我有以下构建脚本,我需要强制目录权限并创建一个空目录。我在许多地方发现以下代码应该可以工作,但事实并非如此。任何提示出什么事了吗?

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)

经过更多调查后,这似乎是一个错误,我创建了一个issue in Nebula GitHub

最佳答案

我很确定directory()构造在ospackage闭包中不起作用。您必须添加Rpm类型闭包才能执行此操作。

参见Rpm section of the docsthis ticket

apply plugin: 'nebula.rpm'

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

如果您想要Debian软件包,则将其应用在block of type:Deb中。

关于gradle - 星云ospackage不遵守dirMode,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49069144/

10-11 00:14