diff --git a/rpmlint/pkg.py b/rpmlint/pkg.py index 0825245df..948c75762 100644 --- a/rpmlint/pkg.py +++ b/rpmlint/pkg.py @@ -450,6 +450,22 @@ def _gather_dep_info(self): return (_requires, _prereq, _provides, _conflicts, _obsoletes, _recommends, _suggests, _enhances, _supplements) + def scriptprog(self, which): + """ + Get the specified script interpreter as a string. + Depending on rpm-python version, the string may or may not include + interpreter arguments, if any. + """ + if which is None: + return '' + prog = self[which] + if prog is None: + prog = '' + elif isinstance(prog, (list, tuple)): + # http://rpm.org/ticket/847#comment:2 + prog = ''.join(prog) + return prog + def __enter__(self): return self @@ -704,22 +720,6 @@ def check_versioned_dep(self, name, version): return True return False - def scriptprog(self, which): - """ - Get the specified script interpreter as a string. - Depending on rpm-python version, the string may or may not include - interpreter arguments, if any. - """ - if which is None: - return '' - prog = self[which] - if prog is None: - prog = '' - elif isinstance(prog, (list, tuple)): - # http://rpm.org/ticket/847#comment:2 - prog = ''.join(prog) - return prog - def get_installed_pkgs(name): """Get list of installed package objects by name.""" @@ -796,6 +796,7 @@ def __init__(self, name, is_source=False): self.header[getattr(rpm, f'RPMTAG_{tagname}NAME')] = [] self.header[getattr(rpm, f'RPMTAG_{tagname}FLAGS')] = [] self.header[getattr(rpm, f'RPMTAG_{tagname}VERSION')] = [] + self.header[rpm.RPMTAG_FILENAMES] = [] def add_file(self, path, name): pkgfile = PkgFile(name) @@ -816,7 +817,11 @@ def _mock_file(self, path, attrs): elif 'content' in attrs: content = attrs['content'] - self.add_file_with_content(path, content, metadata=metadata) + if 'linkto' in attrs: + self.add_symlink_to(path, attrs['linkto']) + else: + self.add_file_with_content(path, content, metadata=metadata) + self.header[rpm.RPMTAG_FILENAMES].append(path) if 'content-path' in attrs: content.close() @@ -852,6 +857,8 @@ def add_file_with_content(self, name, content, metadata=None, **flags): pkg_file = PkgFile(name) pkg_file.path = path pkg_file.mode = stat.S_IFREG | 0o0644 + pkg_file.user = 'root' + pkg_file.group = 'root' self.files[name] = pkg_file # create files in filesystem @@ -915,6 +922,8 @@ def add_symlink_to(self, name, target): pkg_file = PkgFile(name) pkg_file.mode = stat.S_IFLNK pkg_file.linkto = target + pkg_file.user = 'root' + pkg_file.group = 'root' self.files[name] = pkg_file def readlink(self, pkgfile): @@ -937,3 +946,7 @@ def md5_checksum(self, file_name): def cleanup(self): if self.dirname: self.__tmpdir.cleanup() + + # access the tags like an array + def __getitem__(self, key): + return self.header.get(key, None)