@@ -17,10 +17,10 @@ class RpmPluginIntegrationTest extends BaseIntegrationTestKitSpec {
1717 @Issue (" https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/82" )
1818 def " rpm task is marked up-to-date when setting arch or os property" () {
1919
20- given :
21- File libDir = new File (projectDir, ' lib' )
22- libDir. mkdirs()
23- new File (libDir, ' a.java' ). text = " public class A { }"
20+ given :
21+ File libDir = new File (projectDir, ' lib' )
22+ libDir. mkdirs()
23+ new File (libDir, ' a.java' ). text = " public class A { }"
2424 buildFile << '''
2525plugins {
2626 id 'com.netflix.nebula.rpm'
@@ -167,7 +167,7 @@ task buildRpm(type: Rpm) {
167167 def scanFiles = Scanner . scan(file(' build/distributions/sample-1.0.0.noarch.rpm' )). files
168168
169169 [' ./usr/local/myproduct' , ' ./usr/local/myproduct/bin' , ' ./usr/local/myproduct/bin/apple' , ' ./usr/share/myproduct' , ' ./usr/share/myproduct/etc' , ' ./usr/share/myproduct/etc/banana' ] == scanFiles* . name
170- [ DIR , DIR , FILE , DIR , DIR , FILE ] == scanFiles* . type
170+ [DIR , DIR , FILE , DIR , DIR , FILE ] == scanFiles* . type
171171
172172 }
173173
@@ -200,10 +200,10 @@ task buildRpm(type: Rpm) {
200200
201201 then :
202202 def scan = Scanner . scan(file(' build/distributions/sample-1.0.0.noarch.rpm' ))
203- def scannerApple = scan. files. find { it. name == ' ./usr/local/myproduct/bin/apple' }
203+ def scannerApple = scan. files. find { it. name == ' ./usr/local/myproduct/bin/apple' }
204204 scannerApple. asString() == ' /usr/local/myproduct/apple'
205205 }
206-
206+
207207 def ' verifyCopySpecCanComeFromExtension' () {
208208 given :
209209 File srcDir = new File (projectDir, ' src' )
@@ -302,9 +302,9 @@ task buildRpm(type: Rpm) {
302302 given :
303303 File packageDir = directory(" package" )
304304 packageDir. mkdirs()
305- File target = new File (packageDir," my-script.sh" )
305+ File target = new File (packageDir, " my-script.sh" )
306306 target. createNewFile()
307- File file = new File (packageDir,' bin/my-symlink' )
307+ File file = new File (packageDir, ' bin/my-symlink' )
308308 FileUtils . forceMkdirParent(file)
309309 java.nio.file.Files . createSymbolicLink(file. toPath(), target. toPath())
310310 buildFile << """
@@ -320,7 +320,7 @@ task buildRpm(type: Rpm) {
320320"""
321321
322322 when :
323- runTasks(' buildRpm' , ' --warning-mode ' , ' none ' )
323+ runTasks(' buildRpm' )
324324
325325 then :
326326 def scan = Scanner . scan(this . file(' build/distributions/example-3.noarch.rpm' ))
@@ -333,9 +333,9 @@ task buildRpm(type: Rpm) {
333333 given :
334334 File packageDir = directory(" package" )
335335 packageDir. mkdirs()
336- File target = new File (packageDir," my-script.sh" )
336+ File target = new File (packageDir, " my-script.sh" )
337337 target. createNewFile()
338- File file = new File (packageDir,' bin/my-symlink' )
338+ File file = new File (packageDir, ' bin/my-symlink' )
339339 FileUtils . forceMkdirParent(file)
340340 java.nio.file.Files . createSymbolicLink(file. toPath(), target. toPath())
341341 buildFile << """
@@ -353,7 +353,7 @@ task buildRpm(type: Rpm) {
353353"""
354354
355355 when :
356- runTasks(' buildRpm' , ' --warning-mode ' , ' none ' )
356+ runTasks(' buildRpm' )
357357
358358 then :
359359 def scan = Scanner . scan(this . file(' build/distributions/example-4.noarch.rpm' ))
@@ -440,6 +440,94 @@ buildRpm {
440440 def scanFiles = Scanner . scan(file(' build/distributions/sample-1.0.0.noarch.rpm' )). files
441441
442442 [' ./usr/share/myproduct/etc/banana' ] == scanFiles* . name
443- [ FILE ] == scanFiles* . type
444- }
443+ [FILE ] == scanFiles* . type
444+ }
445+
446+ def ' setgid can be set in rpm and deb' () {
447+ given :
448+ File emptyFolder = new File (projectDir, ' test/someFolder/sub' )
449+ emptyFolder. mkdirs()
450+ buildFile << """
451+ plugins {
452+ id 'com.netflix.nebula.ospackage'
445453}
454+
455+ version = '1.0.0'
456+
457+ ospackage {
458+ addParentDirs false
459+ }
460+
461+ buildRpm {
462+ packageName = 'sample'
463+
464+ from(${ GradleUtils.quotedIfPresent(emptyFolder.parentFile.path)} ) {
465+ createDirectoryEntry = true
466+ setgid = ${ setgidValue}
467+ dirPermissions {
468+ unix(0644)
469+ }
470+ into '/usr/share/myproduct/etc/'
471+ }
472+ }
473+ """
474+ when :
475+ runTasks(' buildRpm' )
476+
477+ then :
478+ def scanFiles = Scanner . scan(file(' build/distributions/sample-1.0.0.noarch.rpm' )). files
479+
480+ [' ./usr/share/myproduct/etc/sub' ] == scanFiles* . name
481+ [DIR ] == scanFiles* . type
482+ [expectedPermissions] == scanFiles* . permissions
483+
484+ where :
485+ setgidValue | expectedPermissions
486+ true | 1444
487+ false | 0644
488+ }
489+
490+ def ' setgid in ospackage extension propagates to rpm and deb' () {
491+ given :
492+ File emptyFolder = new File (projectDir, ' test/someFolder/sub' )
493+ emptyFolder. mkdirs()
494+ buildFile << """
495+ plugins {
496+ id 'com.netflix.nebula.ospackage'
497+ }
498+
499+ version = '1.0.0'
500+
501+ ospackage {
502+ addParentDirs false
503+ setgid = ${ setgidValue}
504+ }
505+
506+ buildRpm {
507+ packageName = 'sample'
508+
509+ from(${ GradleUtils.quotedIfPresent(emptyFolder.parentFile.path)} ) {
510+ createDirectoryEntry = true
511+ dirPermissions {
512+ unix(0644)
513+ }
514+ into '/usr/share/myproduct/etc/'
515+ }
516+ }
517+ """
518+ when :
519+ runTasks(' buildRpm' , ' --warning-mode' , ' all' , ' --stacktrace' )
520+
521+ then :
522+ def scanFiles = Scanner . scan(file(' build/distributions/sample-1.0.0.noarch.rpm' )). files
523+
524+ [' ./usr/share/myproduct/etc/sub' ] == scanFiles* . name
525+ [DIR ] == scanFiles* . type
526+ [expectedPermissions] == scanFiles* . permissions
527+
528+ where :
529+ setgidValue | expectedPermissions
530+ true | 1444
531+ false | 0644
532+ }
533+ }
0 commit comments