我有以下构建脚本,我需要强制目录权限并创建一个空目录。我在很多地方发现以下代码应该可以工作,但事实并非如此。有什么提示有什么不对吗?
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。
答案 0 :(得分:1)
我非常确定directory()
构造在ospackage
闭包中不起作用。您必须添加Rpm
类型的闭包才能执行此操作。
请参阅Rpm section of the docs和this ticket。
apply plugin: 'nebula.rpm'
task fooRpm(type: Rpm) {
directory('/opt/myapp/aaa', 0750)
}
如果您需要Debian软件包,请将其应用于block of type:Deb。