Ejemplo n.º 1
0
    def check(self, pkg):
	# Check only binary package
	if pkg.isSource():
	    return
	
        info=pkg.getFilesInfo()
	arch=pkg[rpm.RPMTAG_ARCH]
        files=pkg.files()
        exec_files=[]
        has_lib=[]
        version=None
        binary=0
        binary_in_usr_lib=0
        has_usr_lib_file=0

        res=srcname_regex.search(pkg[rpm.RPMTAG_SOURCERPM])
        if res:
            multi_pkg=(pkg.name != res.group(1))
        else:
            multi_pkg=0

        for f in files.keys():
            if usr_lib_regex.search(f) and not usr_lib_exception_regex.search(f) and not stat.S_ISDIR(files[f][0]):
                has_usr_lib_file=f
                break
            
	for i in info:
	    is_binary=binary_regex.search(i[1])
            
	    if is_binary:
                binary=binary+1
                if has_usr_lib_file and not binary_in_usr_lib and usr_lib_regex.search(i[0]):
                    binary_in_usr_lib=1
                    
		if arch == 'noarch':
		    yield ArchIndependentPackageContainsBinaryOrObject(pkg, i[0])
		else:
		    # in /usr/share ?
		    if usr_share.search(i[0]):
			yield ArchDependentFileInUsrShare(pkg, i[0])
		    # in /etc ?
		    if etc.search(i[0]):
			yield BinaryInEtc(pkg, i[0])

                    if arch == 'sparc' and sparc_regex.search(i[1]):
                        yield NonSparc32Binary(pkg, i[0])

		    # stripped ?
		    if not unstrippable.search(i[0]):
			if not_stripped.search(i[1]):
			    yield UnstrippedBinaryOrObject(pkg, i[0])

			# inspect binary file
			bin_info=BinaryInfo(pkg.dirName()+i[0], i[0])

                        # so name in library
                        if so_regex.search(i[0]):
                            has_lib.append(i[0])
                            if not bin_info.soname:
                                yield NoSoname(pkg, i[0])
                            else:
                                if not validso_regex.search(bin_info.soname):
                                    yield InvalidSoname(pkg, i[0], bin_info.soname)
                                else:
                                    (dir, base) = dir_base(i[0])
                                    try:
                                        symlink = dir + bin_info.soname
                                        (perm, owner, group, link, size, md5, mtime, rdev) = files[symlink]
                                        if link != i[0] and link != base and link != '':
                                            yield InvalidLdconfigSymlink(pkg, i[0], link)
                                    except KeyError:
                                        yield NoLdconfigSymlink(pkg, i[0])
                                res=soversion_regex.search(bin_info.soname)
                                if res:
                                    soversion=res.group(1) or res.group(2)
                                    if version == None:
                                        version = soversion
                                    elif version != soversion:
                                        version = -1
                                    
                            if bin_info.non_pic:
                                yield ShlibWithNonPicCode(pkg, i[0])
			# rpath ?
			if bin_info.rpath:
                            for p in bin_info.rpath:
                                if p in system_lib_paths or \
                                   not usr_lib_regex.search(p):
                                    yield BinaryOrShlibDefinesRpath(pkg, i[0], bin_info.rpath)
                                    break

			# statically linked ?
                        is_exec=executable_regex.search(i[1])
			if shared_object_regex.search(i[1]) or \
			   is_exec:

                            if is_exec and bin_regex.search(i[0]):
                                exec_files.append(i[0])
                                
			    if not bin_info.needed and \
                               not (bin_info.soname and \
                                    ldso_soname_regex.search(bin_info.soname)):
				if shared_object_regex.search(i[1]):
				    yield SharedLibWithoutDependencyInformation(pkg, i[0])
				else:
				    yield StaticallyLinkedBinary(pkg, i[0])
			    else:
				# linked against libc ?
				if not libc_regex.search(i[0]) and \
				   ( not bin_info.soname or \
				     ( not libc_regex.search(bin_info.soname) and \
				       not ldso_soname_regex.search(bin_info.soname))):
				    found_libc=0
				    for lib in bin_info.needed:
					if libc_regex.search(lib):
					    found_libc=1
					    break
				    if not found_libc:
					if shared_object_regex.search(i[1]):
					    yield LibraryNotLinkedAgainstLibc(pkg, i[0])
					else:
					    yield ProgramNotLinkedAgainstLibc(pkg, i[0])
            else:
                if reference_regex.search(i[0]):
                    if Pkg.grep('tmp|home', pkg.dirname + '/' + i[0]):
                        yield InvalidDirectoryReference(pkg, i[0])

        if has_lib != []:
            if exec_files != []:
                for f in exec_files:
                    yield ExecutableInLibraryPackage(pkg, f)
            for f in files.keys():
                res=numeric_dir_regex.search(f)
                fn=res and res.group(1) or f
                if not f in exec_files and not so_regex.search(f) and not versioned_dir_regex.search(fn):
                    yield NonVersionedFileInLibraryPackage(pkg, f)
            if version and version != -1 and string.find(pkg.name, version) == -1:
                yield IncoherentVersionInName(pkg, version)

        if arch != 'noarch' and not multi_pkg:
            if binary == 0:
                yield NoBinary(pkg)

        if has_usr_lib_file and not binary_in_usr_lib:
            yield OnlyNonBinaryInUsrLib(pkg)
Ejemplo n.º 2
0
             if mode & 0111 != 0:
                 yield ExecutableMenuFile(pkg, f)
             menus.append(f)
     else:
         # Check old menus from KDE and GNOME
         res=old_menu_file_regex.search(f)
         if res:
             mode=files[f][0]
             if stat.S_ISREG(mode):
                 yield OldMenuEntry(pkg, f)
         else:
             # Check non transparent xpm files
             res=xpm_ext_regex.search(f)
             if res:
                 mode=files[f][0]
                 if stat.S_ISREG(mode) and not Pkg.grep('None",', dirname + '/' + f):
                     yield NonTransparentXpm(pkg, f)
 if len(menus) > 0:
     dir=pkg.dirName()
     if menus != []:
         postin=pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
         if not postin:
             yield MenuWithoutPostin(pkg)
         else:
             if not update_menus_regex.search(postin):
                 yield PostinWithoutUpdateMenus(pkg)                    
             
         postun=pkg[rpm.RPMTAG_POSTUN] or pkg[rpm.RPMTAG_POSTUNPROG]
         if not postun:
             yield MenuWithoutPostun(pkg)
         else: