From b3377f0e402c3f04c97258d35ba42072c18858af Mon Sep 17 00:00:00 2001 From: Pradeep Bansal Date: Tue, 30 Apr 2019 15:30:40 -0700 Subject: [PATCH] added support for osname property --- .../plugins/packaging/SystemPackagingExtension.groovy | 5 ++++- .../gradle/plugins/packaging/SystemPackagingTask.groovy | 6 +++++- .../groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy | 1 + .../com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy | 9 +++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingExtension.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingExtension.groovy index 4971a4d3..0d40defe 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingExtension.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingExtension.groovy @@ -114,7 +114,10 @@ class SystemPackagingExtension { @Input @Optional Os os - + + @Input @Optional + String osName + @Input @Optional RpmType type diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy index 7d8270b6..dea05e24 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy @@ -226,6 +226,10 @@ public abstract class SystemPackagingTask extends AbstractArchiveTask { public String getArchString() { return getArchStr()?.toLowerCase(); } + + public String getOsString() { + return osName ? osName.toLowerCase() : (os?.toString()?.toLowerCase() ?: ''); + } @Override public AbstractCopyTask from(Object sourcePath, Closure c) { @@ -234,7 +238,7 @@ public abstract class SystemPackagingTask extends AbstractArchiveTask { } return this } - + @Override public AbstractArchiveTask into(Object destPath, Closure configureClosure) { use(CopySpecEnhancement) { diff --git a/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy b/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy index 144bece1..547cc977 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy @@ -62,6 +62,7 @@ class Rpm extends SystemPackagingTask { parentExten?.getArchStr()?:Architecture.NOARCH.name() }) mapping.map('os', { parentExten?.getOs()?:Os.UNKNOWN}) + mapping.map('osName', { parentExten?.getOsName()?: ''}) mapping.map('type', { parentExten?.getType()?:RpmType.BINARY }) // NOTE: Believe parentExten is always null diff --git a/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy b/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy index d07852d3..383f5445 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy @@ -61,7 +61,12 @@ class RpmCopyAction extends AbstractPackagingCopyAction { builder = new Builder() builder.setPackage task.packageName, task.version, task.release, task.epoch builder.setType task.type - builder.setPlatform Architecture.valueOf(task.archStr.toUpperCase()), task.os + if (task.osName) { + builder.setPlatform Architecture.valueOf(task.archStr.toUpperCase()), task.osName + } else { + builder.setPlatform Architecture.valueOf(task.archStr.toUpperCase()), task.os + } + builder.setGroup task.packageGroup builder.setBuildHost task.buildHost builder.setSummary task.summary @@ -182,7 +187,7 @@ class RpmCopyAction extends AbstractPackagingCopyAction { includeStandardDefines ? String.format(" RPM_ARCH=%s \n RPM_OS=%s \n RPM_PACKAGE_NAME=%s \n RPM_PACKAGE_VERSION=%s \n RPM_PACKAGE_RELEASE=%s \n\n", task.getArchString(), - task.os?.toString()?.toLowerCase() ?: '', + task.getOsString(), task.getPackageName(), task.getVersion(), task.getRelease()) : null