def test_fix_pkg_config(self): pc_file = os.path.join(self.tempdir, 'granite.pc') with open(pc_file, 'w') as f: f.write('prefix=/usr\n') f.write('exec_prefix=${prefix}\n') f.write('libdir=${prefix}/lib\n') f.write('includedir=${prefix}/include\n') f.write('\n') f.write('Name: granite\n') f.write('Description: elementary\'s Application Framework\n') f.write('Version: 0.4\n') f.write('Libs: -L${libdir} -lgranite\n') f.write('Cflags: -I${includedir}/granite\n') f.write('Requires: cairo gee-0.8 glib-2.0 gio-unix-2.0 ' 'gobject-2.0\n') repo._fix_artifacts(debdir=self.tempdir) with open(pc_file) as f: pc_file_content = f.read() expected_pc_file_content = """prefix={}/usr exec_prefix=${{prefix}} libdir=${{prefix}}/lib includedir=${{prefix}}/include Name: granite Description: elementary's Application Framework Version: 0.4 Libs: -L${{libdir}} -lgranite Cflags: -I${{includedir}}/granite Requires: cairo gee-0.8 glib-2.0 gio-unix-2.0 gobject-2.0 """.format(self.tempdir) self.assertEqual(pc_file_content, expected_pc_file_content)
def test_fix_suid(self): file = os.path.join(self.tempdir, self.key) open(file, mode='w').close() os.chmod(file, self.test_mod) repo._fix_artifacts(debdir=self.tempdir) self.assertEqual(stat.S_IMODE(os.stat(file).st_mode), self.expected_mod)
def test_fix_suid(self): file = os.path.join(self.tempdir, self.key) open(file, mode='w').close() os.chmod(file, self.test_mod) repo._fix_artifacts(debdir=self.tempdir) self.assertEqual( stat.S_IMODE(os.stat(file).st_mode), self.expected_mod)
def test_fix_suid(self): files = { 'suid_file': (0o4765, 0o0765), 'guid_file': (0o2777, 0o0777), 'suid_guid_file': (0o6744, 0o0744), 'suid_guid_sticky_file': (0o7744, 0o1744), } for key in files: with self.subTest(key=key): file = os.path.join(self.tempdir, key) open(file, mode='w').close() os.chmod(file, files[key][0]) repo._fix_artifacts(debdir=self.tempdir) self.assertEqual(stat.S_IMODE(os.stat(file).st_mode), files[key][1])
def test_fix_symlinks(self): os.makedirs(self.tempdir + '/a') open(self.tempdir + '/1', mode='w').close() os.symlink('a', self.tempdir + '/rel-to-a') os.symlink('/a', self.tempdir + '/abs-to-a') os.symlink('/b', self.tempdir + '/abs-to-b') os.symlink('1', self.tempdir + '/rel-to-1') os.symlink('/1', self.tempdir + '/abs-to-1') repo._fix_artifacts(debdir=self.tempdir) self.assertEqual(os.readlink(self.tempdir + '/rel-to-a'), 'a') self.assertEqual(os.readlink(self.tempdir + '/abs-to-a'), 'a') self.assertEqual(os.readlink(self.tempdir + '/abs-to-b'), '/b') self.assertEqual(os.readlink(self.tempdir + '/rel-to-1'), '1') self.assertEqual(os.readlink(self.tempdir + '/abs-to-1'), '1')
def test_fix_suid(self): files = { 'suid_file': (0o4765, 0o0765), 'guid_file': (0o2777, 0o0777), 'suid_guid_file': (0o6744, 0o0744), 'suid_guid_sticky_file': (0o7744, 0o1744), } for key in files: with self.subTest(key=key): file = os.path.join(self.tempdir, key) open(file, mode='w').close() os.chmod(file, files[key][0]) repo._fix_artifacts(debdir=self.tempdir) self.assertEqual( stat.S_IMODE(os.stat(file).st_mode), files[key][1])