From 08db51cf11f51c62b1c263121105a0e62d75990b Mon Sep 17 00:00:00 2001 From: Ingmar Schwarz Date: Mon, 29 Jan 2024 11:38:05 +0100 Subject: [PATCH] Add user and group to symlinks in rpm Adds possibility to add user and permissionGroup to symlinks in rpm, defaults to task settings. * Resolves #320. --- .../com/netflix/gradle/plugins/packaging/Link.groovy | 2 ++ .../packaging/SystemPackagingExtension.groovy | 12 +++++++++++- .../netflix/gradle/plugins/rpm/RpmCopyAction.groovy | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/Link.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/Link.groovy index c1a060cc..0fcf9a85 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/Link.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/Link.groovy @@ -23,4 +23,6 @@ class Link implements Serializable { String path String target int permissions = -1 + String user = null + String permissionGroup = null } 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 37d225c3..1564928c 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingExtension.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingExtension.groovy @@ -777,14 +777,24 @@ class SystemPackagingExtension { Link link(String path, String target) { - link(path, target, -1) + link(path, target, -1, null, null) } Link link(String path, String target, int permissions) { + link(path, target, permissions, null, null) + } + + Link link(String path, String target, String user, String permissionGroup) { + link(path, target, -1, user, permissionGroup) + } + + Link link(String path, String target, int permissions, String user, String permissionGroup) { Link link = new Link() link.path = path link.target = target link.permissions = permissions + link.user = user + link.permissionGroup = permissionGroup links.add(link) link } 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 83d62d48..bddc3b9d 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy @@ -196,7 +196,9 @@ class RpmCopyAction extends AbstractPackagingCopyAction { @Override protected void addLink(Link link) { - builder.addLink link.path, link.target, link.permissions + def user = link.user ?: task.user + def permissionGroup = link.permissionGroup ?: task.permissionGroup + builder.addLink(link.path, link.target, link.permissions, user, permissionGroup) } @Override