From 45b1636d35a0cd89f9c33fa35656515c1e984007 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jun 06 2016 07:01:33 +0000 Subject: Allow specifying owner and group for installed files --- diff --git a/rpmfluff.py b/rpmfluff.py index cbc3ee6..8d571c0 100755 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -1015,7 +1015,9 @@ class SimpleRpmBuild(RpmBuild): subpackageSuffix=None, isConfig=False, isDoc=False, - isGhost=False): + isGhost=False, + owner=None, + group=None): """Add a simple source file to the sources, and set it up to be copied up directly at %install, potentially with certain permissions""" sourceId = self.add_source(sourceFile) @@ -1027,6 +1029,8 @@ class SimpleRpmBuild(RpmBuild): sub = self.get_subpackage(subpackageSuffix) tag="" + if owner or group: + tag += '%%attr(-,%s,%s) ' % (owner or '-', group or '-') if isConfig: tag+="%config " if isDoc: @@ -1729,6 +1733,17 @@ class TestSimpleRpmBuild(unittest.TestCase): isGhost=True) self.rpmbuild.make() + def test_add_file_with_owner_and_group(self): + self.rpmbuild.add_installed_file('/var/www/html/index.html', + SourceFile('index.html', '

Hello

'), + owner='apache', group='apache') + self.rpmbuild.make() + hdr = self.rpmbuild.get_built_rpm_header(expectedArch) + files = rpm.files(hdr) + self.assertEqual('/var/www/html/index.html', files[0].name) + self.assertEqual('apache', files[0].user) + self.assertEqual('apache', files[0].group) + def test_specfile_encoding_utf8(self): self.rpmbuild.section_changelog = u"* Fri Mar 30 2001 Trond Eivind Glomsr\u00F8d \nDo something" self.rpmbuild.make()