def addRPMComponent(self, nameSpec, rpmPath, versus = None,
        fileContents=None, requires=deps.DependencySet()):

        if rpmPath[0] != '/':
            rpmPath = resources.get_archive(rpmPath)

        f = open(rpmPath, "r")
        h = rpmhelper.readHeader(f)
        expandDir = self.workDir + '/rpm'
        if os.path.exists(expandDir):
            shutil.rmtree(expandDir)
        os.mkdir(expandDir)

        p = os.popen("cd %s; cpio --quiet -iumd" % (expandDir, ), "w")
        rpmhelper.extractRpmPayload(f, p)
        p.close()
        f.close()

        fl = []
        for path, mode, flags, linksTo, fileColor, rdev in itertools.izip(
                        h[rpmhelper.OLDFILENAMES],
                        h[rpmhelper.FILEMODES], h[rpmhelper.FILEFLAGS],
                        h[rpmhelper.FILELINKTOS],
                        h[rpmhelper.FILECOLORS],
                        h[rpmhelper.FILERDEVS]):
            if stat.S_ISDIR(mode):
                fl.append((path, Directory()))
            elif stat.S_ISBLK(mode) or stat.S_ISCHR(mode):
                minor = rdev & 0xff | (rdev >> 12) & 0xffffff00
                major = (rdev >> 8) & 0xfff
                if stat.S_ISBLK(mode):
                    fl.append((path, BlockDevice(major, minor)))
                elif stat.S_ISCHR(mode):
                    fl.append((path, CharacterDevice(major, minor)))
            else:
                isConfig = ((flags & rpmhelper.RPMFILE_CONFIG) != 0)
                isGhost = ((flags & rpmhelper.RPMFILE_GHOST) != 0)
                # You can't have symlinks that are initialContents
                if stat.S_ISLNK(mode):
                    fobj = Symlink(linksTo)
                else:
                    if isGhost:
                        contents = ''
                        # can't have files which are both initialContents
                        # and config
                        isConfig = False
                    else:
                        contents = open(expandDir + path)

                    if fileColor == 2:
                        req = 'abi: ELF64(SysV x86_64)'
                    elif fileColor == 1:
                        req = 'abi: ELF32(SysV x86)'
                    else:
                        req = None

                    fobj = RegularFile(contents = contents,
                                       config = isConfig,
                                       initialContents = isGhost,
                                       requires = req)
                    if isGhost:
                        # RBL-5684: we force ghost files to not be marked as
                        # payload (see Component)
                        fobj.isGhost = True

                fl.append((path, fobj))
        fl.extend(fileContents or [])

        return self.addComponent(nameSpec, fileContents = fl,
                                 capsule = rpmPath, versus = versus,
                                 requires=requires)
dataset/ETHPy150Open sassoftware/conary/conary_test/rephelp.py/RepositoryHelper.addRPMComponent/original