예제 #1
0
 def doRpm(self, recipe, queryformat, split='\n'):
     if not self.includes: return []
     rpmFileNames = []
     for include in self.includes:
         rpmFileNames += glob.glob(include%recipe.macros)
     for exclude in self.excludes:
         for rpmFileName in glob.glob(exclude%recipe.macros):
             rpmFileNames.remove(rpmFileName)
     return util.popen('rpm -qp --queryformat \'%s\' %s' % (queryformat, ' '.join(rpmFileNames))).read().split(split)
예제 #2
0
 def doRpm(self, recipe, queryformat, split='\n'):
     if not self.includes: return []
     rpmFileNames = []
     for include in self.includes:
         rpmFileNames += glob.glob(include % recipe.macros)
     for exclude in self.excludes:
         for rpmFileName in glob.glob(exclude % recipe.macros):
             rpmFileNames.remove(rpmFileName)
     return util.popen(
         'rpm -qp --queryformat \'%s\' %s' %
         (queryformat, ' '.join(rpmFileNames))).read().split(split)
예제 #3
0
    def findRightFile(self, fullpath, fileName, dirList):
        """
        Search for the best match in buildir for the the destdirfile
        fullPath.  Match I{fullpath} against %(builddir)/dir/fileName for each
        directory in I{dirList}
        """

        # XXX need to cache size/diff info
        exactMatchPossible = True
        builddir = self.macros.builddir
        builddirlen = len(builddir)
        size = os.stat(fullpath)[stat.ST_SIZE]

        fileList = [
            ''.join([builddir, dir, os.sep, fileName]) for dir in dirList
        ]
        newFileList = [
            file for file in fileList if size == os.stat(file)[stat.ST_SIZE]
        ]
        if len(newFileList) == 1:
            return os.path.dirname(newFileList[0])[builddirlen:]
        elif len(newFileList) > 1:
            # narrow down our search and continue looking
            fileList = newFileList
        else:
            exactMatchPossible = False

        # okay, there either at least two entries who passed,
        # or no entries who passed -- next heuristic

        if exactMatchPossible:
            # we found at least 2 that were the same size --
            # let's try for the more expensive diff
            # since this should be a very small set of files
            for file in fileList:
                fd = util.popen('diff %s %s' % (fullpath, file))
                results = fd.read()
                if results == "":
                    return os.path.dirname(file)[builddirlen:]

        # I give up: don't make the link because it's probably wrong
        # XXX other, missing tests: magic, close filenames, close sizes
        # destdirlen = len(self.macros.destdir)
        # self.warn('Could not determine which builddir file %s corresponds to for creating test component', fullpath[destdirlen:])
        return None
예제 #4
0
    def findRightFile(self, fullpath, fileName, dirList):
        """
        Search for the best match in buildir for the the destdirfile
        fullPath.  Match I{fullpath} against %(builddir)/dir/fileName for each
        directory in I{dirList}
        """

        # XXX need to cache size/diff info
        exactMatchPossible = True
        builddir = self.macros.builddir
        builddirlen = len(builddir)
        size = os.stat(fullpath)[stat.ST_SIZE]

        fileList = [ ''.join([builddir, dir, os.sep, fileName]) for dir in dirList ]
        newFileList = [ file for file in fileList if size == os.stat(file)[stat.ST_SIZE] ]
        if len(newFileList) == 1:
            return os.path.dirname(newFileList[0])[builddirlen:]
        elif len(newFileList) > 1:
            # narrow down our search and continue looking
            fileList = newFileList
        else:
            exactMatchPossible = False

        # okay, there either at least two entries who passed,
        # or no entries who passed -- next heuristic

        if exactMatchPossible:
            # we found at least 2 that were the same size --
            # let's try for the more expensive diff
            # since this should be a very small set of files
            for file in fileList:
                fd = util.popen('diff %s %s' % (fullpath, file))
                results = fd.read()
                if results == "":
                    return os.path.dirname(file)[builddirlen:]

        # I give up: don't make the link because it's probably wrong
        # XXX other, missing tests: magic, close filenames, close sizes
        # destdirlen = len(self.macros.destdir)
        # self.warn('Could not determine which builddir file %s corresponds to for creating test component', fullpath[destdirlen:])
        return None
예제 #5
0
    def doFile(self, path):
        if hasattr(self.recipe, '_getCapsulePathsForFile'):
            if self.recipe._getCapsulePathsForFile(path):
                return

        m = self.recipe.magic[path]
        if not m:
            return
        # FIXME: should be:
        #if (m.name == "ELF" or m.name == "ar") and \
        #   m.contents['hasDebug']):
        # but this has to wait until ewt writes debug detection
        # for archives as well as elf files
        if (m.name == "ELF" and m.contents['hasDebug']) or \
           (m.name == "ar"):
            oldmode = None
            fullpath = self.dm.destdir+path
            mode = os.lstat(fullpath)[stat.ST_MODE]
            if mode & 0600 != 0600:
                # need to be able to read and write the file to strip it
                oldmode = mode
                os.chmod(fullpath, mode|0600)
            if self.debuginfo and m.name == 'ELF' and not path.endswith('.o'):

                dir=os.path.dirname(path)
                b=os.path.basename(path)
                if not b.endswith('.debug'):
                    b += '.debug'

                debuglibdir = '%(destdir)s%(debuglibdir)s' %self.dm +dir
                debuglibpath = util.joinPaths(debuglibdir, b)
                if os.path.exists(debuglibpath):
                    return

                self._openDb()
                if (_findProgPath(self.macros.debugedit, self.db,
                                  self.recipe, error=False) and
                    _findProgPath(self.macros.strip, self.db,
                                  self.recipe, error=False)):

                    # null-separated AND terminated list, so we need to throw
                    # away the last (empty) item before updating self.debugfiles
                    self.debugfiles |= set(util.popen(
                        '%(debugedit)s -b %(topbuilddir)s -d %(debugsrcdir)s'
                        ' -l /dev/stdout '%self.dm
                        +fullpath).read().split('\x00')[:-1])
                    util.mkdirChain(debuglibdir)
                    util.execute('%s -f %s %s' %(
                        self.dm.strip, debuglibpath, fullpath))

            else:
                self._openDb()
                if m.name == 'ar' or path.endswith('.o'):
                    # just in case strip is eu-strip, which segfaults
                    # whenever it touches an ar archive, and seems to
                    # break some .o files
                    if _findProgPath(self.macros.strip_archive, self.db, self.recipe, error=False):
                        util.execute('%(strip_archive)s ' %self.dm +fullpath)
                else:
                    if _findProgPath(self.macros.strip, self.db, self.recipe, error=False):
                        util.execute('%(strip)s ' %self.dm +fullpath)

            del self.recipe.magic[path]
            if oldmode is not None:
                os.chmod(fullpath, oldmode)
예제 #6
0
    def doFile(self, path):
        if hasattr(self.recipe, '_getCapsulePathsForFile'):
            if self.recipe._getCapsulePathsForFile(path):
                return

        m = self.recipe.magic[path]
        if not m:
            return
        # FIXME: should be:
        #if (m.name == "ELF" or m.name == "ar") and \
        #   m.contents['hasDebug']):
        # but this has to wait until ewt writes debug detection
        # for archives as well as elf files
        if (m.name == "ELF" and m.contents['hasDebug']) or \
           (m.name == "ar"):
            oldmode = None
            fullpath = self.dm.destdir + path
            mode = os.lstat(fullpath)[stat.ST_MODE]
            if mode & 0600 != 0600:
                # need to be able to read and write the file to strip it
                oldmode = mode
                os.chmod(fullpath, mode | 0600)
            if self.debuginfo and m.name == 'ELF' and not path.endswith('.o'):

                dir = os.path.dirname(path)
                b = os.path.basename(path)
                if not b.endswith('.debug'):
                    b += '.debug'

                debuglibdir = '%(destdir)s%(debuglibdir)s' % self.dm + dir
                debuglibpath = util.joinPaths(debuglibdir, b)
                if os.path.exists(debuglibpath):
                    return

                self._openDb()
                if (_findProgPath(
                        self.macros.debugedit, self.db, self.recipe,
                        error=False) and _findProgPath(self.macros.strip,
                                                       self.db,
                                                       self.recipe,
                                                       error=False)):

                    # null-separated AND terminated list, so we need to throw
                    # away the last (empty) item before updating self.debugfiles
                    self.debugfiles |= set(
                        util.popen(
                            '%(debugedit)s -b %(topbuilddir)s -d %(debugsrcdir)s'
                            ' -l /dev/stdout ' % self.dm +
                            fullpath).read().split('\x00')[:-1])
                    util.mkdirChain(debuglibdir)
                    util.execute('%s -f %s %s' %
                                 (self.dm.strip, debuglibpath, fullpath))

            else:
                self._openDb()
                if m.name == 'ar' or path.endswith('.o'):
                    # just in case strip is eu-strip, which segfaults
                    # whenever it touches an ar archive, and seems to
                    # break some .o files
                    if _findProgPath(self.macros.strip_archive,
                                     self.db,
                                     self.recipe,
                                     error=False):
                        util.execute('%(strip_archive)s ' % self.dm + fullpath)
                else:
                    if _findProgPath(self.macros.strip,
                                     self.db,
                                     self.recipe,
                                     error=False):
                        util.execute('%(strip)s ' % self.dm + fullpath)

            del self.recipe.magic[path]
            if oldmode is not None:
                os.chmod(fullpath, oldmode)