|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.xbib.gradle.plugin
|
|
|
|
|
|
|
|
|
|
import groovy.util.logging.Log
|
|
|
|
|
import org.gradle.api.Project
|
|
|
|
|
import org.gradle.api.file.DuplicatesStrategy
|
|
|
|
|
import org.gradle.api.file.FileCopyDetails
|
|
|
|
@ -18,7 +19,10 @@ import org.xbib.rpm.payload.Directive
|
|
|
|
|
import java.nio.file.Files
|
|
|
|
|
import java.nio.file.Path
|
|
|
|
|
import java.nio.file.StandardOpenOption
|
|
|
|
|
import java.nio.file.attribute.PosixFileAttributeView
|
|
|
|
|
import java.nio.file.attribute.PosixFileAttributes
|
|
|
|
|
|
|
|
|
|
@Log
|
|
|
|
|
class RpmCopyAction implements CopyAction {
|
|
|
|
|
|
|
|
|
|
Project project
|
|
|
|
@ -105,8 +109,9 @@ class RpmCopyAction implements CopyAction {
|
|
|
|
|
builder.addProvides(provides.packageName, provides.flags, provides.version)
|
|
|
|
|
}
|
|
|
|
|
for (Directory directory : task.directories) {
|
|
|
|
|
String user = directory.user ? directory.user : task.user
|
|
|
|
|
String group = directory.group ? directory.group : task.group
|
|
|
|
|
String user = directory.user ?: task.user
|
|
|
|
|
String group = directory.group ?: task.group
|
|
|
|
|
log.info("dir = " + directory.path)
|
|
|
|
|
builder.addDirectory(directory.path, directory.permissions, null, user, group, directory.addParents)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -123,20 +128,29 @@ class RpmCopyAction implements CopyAction {
|
|
|
|
|
private class StreamAction implements CopyActionProcessingStreamAction {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
void processFile(FileCopyDetailsInternal fileCopyDetailsInternal) {
|
|
|
|
|
boolean addParents = task.addParentDirs != null ? task.addParentDirs : task.addParentDirs
|
|
|
|
|
Path path = extractPath(tempDir, fileCopyDetailsInternal)
|
|
|
|
|
String p = "/${fileCopyDetailsInternal.path}"
|
|
|
|
|
void processFile(FileCopyDetailsInternal details) {
|
|
|
|
|
boolean addParents = task.addParentDirs != null ? task.addParentDirs : false
|
|
|
|
|
Path path = extractPath(tempDir, details)
|
|
|
|
|
PosixFileAttributeView view = Files.getFileAttributeView(path, PosixFileAttributeView)
|
|
|
|
|
PosixFileAttributes attributes = view.readAttributes()
|
|
|
|
|
String user = task.user ?: attributes.owner().name
|
|
|
|
|
String group = task.group ?: attributes.group().name
|
|
|
|
|
String p = "/${details.path}"
|
|
|
|
|
if (Files.isSymbolicLink(path)) {
|
|
|
|
|
builder.addLink(p, Files.readSymbolicLink(path).toFile().path, -1)
|
|
|
|
|
} else if (!fileCopyDetailsInternal.isDirectory()) {
|
|
|
|
|
int mode = fileCopyDetailsInternal.mode
|
|
|
|
|
} else if (!details.isDirectory()) {
|
|
|
|
|
int mode = details.mode
|
|
|
|
|
if (task.setuid) {
|
|
|
|
|
mode |= 01000
|
|
|
|
|
} task.group
|
|
|
|
|
int dirmode = -1
|
|
|
|
|
if (task.setgid) {
|
|
|
|
|
dirmode |= 02000
|
|
|
|
|
}
|
|
|
|
|
EnumSet<Directive> directive = makeDirective(task.fileType)
|
|
|
|
|
String user = task.user ?: task.user
|
|
|
|
|
String group = task.group ?: task.group
|
|
|
|
|
builder.addFile(p, path, mode, dirmode, directive, user, group, addParents)
|
|
|
|
|
}
|
|
|
|
|
// we skip all directories
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|