def testSetupWorkdir(self): with make_rpm.Tempdir() as outer: dummy = os.sep.join([outer, 'rpmbuild']) WriteFile(dummy, 'dummy rpmbuild') os.chmod(dummy, 0o777) with PrependPath([outer]): # Create the builder and exercise it. builder = make_rpm.RpmBuilder('test', '1.0', '0', 'x86', False) # Create spec_file, test files. WriteFile('test.spec', 'Name: test', 'Version: 0.1', 'Summary: test data') WriteFile('file1.txt', 'Hello') WriteFile('file2.txt', 'Goodbye') builder.AddFiles(['file1.txt', 'file2.txt']) with make_rpm.Tempdir(): # Call RpmBuilder. builder.SetupWorkdir('test.spec', outer) # Make sure files exist. self.assertTrue(DirExists('SOURCES')) self.assertTrue(DirExists('BUILD')) self.assertTrue(DirExists('TMP')) self.assertTrue(FileExists('test.spec')) self.assertCountEqual( ['Name: test', 'Version: 1.0', 'Summary: test data'], FileContents('test.spec')) self.assertTrue(FileExists('BUILD/file1.txt')) self.assertCountEqual(['Hello'], FileContents('BUILD/file1.txt')) self.assertTrue(FileExists('BUILD/file2.txt')) self.assertCountEqual(['Goodbye'], FileContents('BUILD/file2.txt'))
def testBuild(self): with make_rpm.Tempdir() as outer: dummy = os.sep.join([outer, 'rpmbuild']) WriteFile( dummy, '#!/bin/sh', 'mkdir -p RPMS', 'touch RPMS/test.rpm', 'echo "Wrote: $PWD/RPMS/test.rpm"', ) os.chmod(dummy, 0o777) with PrependPath([outer]): # Create the builder and exercise it. builder = make_rpm.RpmBuilder('test', '1.0', '0', 'x86', False, None) # Create spec_file, test files. WriteFile('test.spec', 'Name: test', 'Version: 0.1', 'Summary: test data') # Call RpmBuilder. builder.Build('test.spec', 'test.rpm') # Make sure files exist. self.assertTrue(FileExists('test.rpm'))
def testSetupWorkdir(self): builder = make_rpm.RpmBuilder('test', '1.0', 'x86') with make_rpm.Tempdir() as outer: # Create spec_file, test files. WriteFile('test.spec', 'Name: test', 'Version: 0.1', 'Summary: test data') WriteFile('file1.txt', 'Hello') WriteFile('file2.txt', 'Goodbye') builder.AddFiles(['file1.txt', 'file2.txt']) with make_rpm.Tempdir(): # Call RpmBuilder. builder.SetupWorkdir('test.spec', outer) # Make sure files exist. self.assertTrue(DirExists('SOURCES')) self.assertTrue(DirExists('BUILD')) self.assertTrue(DirExists('TMP')) self.assertTrue(FileExists('test.spec')) self.assertCountEqual( ['Name: test', 'Version: 1.0', 'Summary: test data'], FileContents('test.spec')) self.assertTrue(FileExists('BUILD/file1.txt')) self.assertCountEqual(['Hello'], FileContents('BUILD/file1.txt')) self.assertTrue(FileExists('BUILD/file2.txt')) self.assertCountEqual(['Goodbye'], FileContents('BUILD/file2.txt'))