Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileCopyDetails.setMode not respected - CopySpec fileMode overrides #427

Open
aldendaley opened this issue Jun 2, 2023 · 0 comments
Open

Comments

@aldendaley
Copy link

When configuring into-from CopySpec details for the ospackage/buildRpm, fileMode can be set for all files applicable to the the copy. There may be a need to set different file permissions on individual files. This can be accomplished through FileCopyDetails.setMode(), under a filesMatching(..) block. Gradle's native distribution plugin output from installDist respects the individually set modes, but the RPM doesn't.

ospackage {
	(..)
	into '/some/path/filePermissionTest'

	fileMode = 0664

	into('destDir1') {
		fileMode = 0644

		from ('srcDir1') {
			// srcDir1\file.txt
			// srcDir1\file.sh

			fileMode = 0640

			filesMatching('**/*.sh') {
				it.setMode(0700)
			}
		}
	}
}

installDist output and expected outcome - the .sh script is 0700

-rwx------. file.sh
-rw-r-----. file.txt

Installed RPM output - the .sh script gets the spec's fileMode 0640

-rw-r-----. file.sh
-rw-r-----. file.txt

https://github.com/nebula-plugins/gradle-ospackage-plugin/blob/ae9152c02ca066b0a3da99e6ccb7da46a083cb9d/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy#LL164C16-L164C16

The RpmCopyAction.visitFile looks like it will always apply the fileMode from the spec - would I be wrong in thinking visitFile(..) should not reference the spec's fileMode at all, and always rely on the fileDetails.mode?

int fileMode = lookup(specToLookAt, 'fileMode') ?: fileDetails.mode

becomes

int fileMode = fileDetails.mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant