Beispiel #1
0
    def _correctEnv(self, m, path):
        destdir = self.recipe.macros.destdir
        d = util.joinPaths(destdir, path)

        interp = m.contents['interpreter']
        if interp.find('/bin/env') != -1: #finds /usr/bin/env too...
            line = m.contents['line']
            # rewrite to not have env
            wordlist = [ x for x in line.split() ]
            if len(wordlist) == 1:
                self.error("Interpreter is not given for %s in %s", wordlist[0], path)
                return
            wordlist.pop(0) # get rid of env
            # first look in package
            fullintpath = util.checkPath(wordlist[0], root=destdir)
            if fullintpath == None:
                # then look on installed system
                fullintpath = util.checkPath(wordlist[0])
            if fullintpath == None:
                self.error("Interpreter %s for file %s not found, could not convert from /usr/bin/env syntax", wordlist[0], path)
                return False

            wordlist[0] = fullintpath

            self._changeInterpLine(d, '#!'+" ".join(wordlist)+'\n')
            self.info('changing %s to %s in %s',
                        line, " ".join(wordlist), path)
            return True
        return False
Beispiel #2
0
 def preProcess(self):
     self.invariantsubtrees = [x[0] for x in self.invariantinclusions]
     # see if we can do debuginfo
     self.debuginfo = False
     # we need this for the debuginfo case
     self.dm = macros.Macros()
     self.dm.update(self.macros)
     # we need to start searching from just below the build directory
     topbuilddir = '/'.join(self.macros.builddir.split('/')[:-1])
     if self.tryDebuginfo and\
        'eu-strip' in self.macros.strip and \
        'debugedit' in self.macros and \
        util.checkPath(self.macros.debugedit):
         if len(self.macros.debugsrcdir) > len(topbuilddir):
             # because we have to overwrite fixed-length strings
             # in binaries, we need to ensure that the value being
             # written is no longer than the existing value to
             # avoid corrupting the binaries
             raise RuntimeError(
                 'insufficient space in binaries'
                 ' for path replacement, add %d characters to buildPath' %
                 (len(self.macros.debugsrcdir) - len(topbuilddir)))
         self.debuginfo = True
         self.debugfiles = set()
         self.dm.topbuilddir = topbuilddir
Beispiel #3
0
 def preProcess(self):
     self.invariantsubtrees = [x[0] for x in self.invariantinclusions]
     # see if we can do debuginfo
     self.debuginfo = False
     # we need this for the debuginfo case
     self.dm = macros.Macros()
     self.dm.update(self.macros)
     # we need to start searching from just below the build directory
     topbuilddir = '/'.join(self.macros.builddir.split('/')[:-1])
     if self.tryDebuginfo and\
        'eu-strip' in self.macros.strip and \
        'debugedit' in self.macros and \
        util.checkPath(self.macros.debugedit):
         if len(self.macros.debugsrcdir) > len(topbuilddir):
             # because we have to overwrite fixed-length strings
             # in binaries, we need to ensure that the value being
             # written is no longer than the existing value to
             # avoid corrupting the binaries
             raise RuntimeError('insufficient space in binaries'
                 ' for path replacement, add %d characters to buildPath'
                 % (len(self.macros.debugsrcdir) - len(topbuilddir)))
         self.debuginfo = True
         self.debugfiles = set()
         self.dm.topbuilddir = topbuilddir
Beispiel #4
0
    def doSuggestAutoBuildReqs(self):
        if not hasattr(self.recipe, "buildRequires"):
            # Most likely group recipe
            return
        if hasattr(self.recipe, "getRepos"):
            repos = self.recipe.getRepos()
        else:
            repos = None

        paths = []
        buildRequires = self.recipe._getTransitiveBuildRequiresNames()
        for cmd in self._actionPathBuildRequires:
            # Catch the case "python setup.py", as well as
            # 'ENV="a b"  somecommand'
            cmdarr = shlex.split(cmd)
            # Try to catch the command "ENVVAR=val make": skip all words that
            # have an equal sign in them
            c = cmd
            for x in cmdarr:
                if '=' not in x:
                    c = x
                    break
            # If the above for loop didn't find anything remotely resembling a
            # command, use the original one
            c = c % self.recipe.macros
            fullPath = util.checkPath(c)
            if (not fullPath) and repos:
                if not c.startswith('/'):
                    candidatePaths = [
                        os.path.join(x, c)
                        for x in os.getenv('PATH', '').split(os.path.pathsep)
                    ]
                else:
                    candidatePaths = [c]
                foundProvider = False
                for label in self.recipe.cfg.installLabelPath:
                    trvDict = repos.getTroveVersionsByPath(
                        candidatePaths, label)
                    trvs = [x for x in trvDict.values() if x]
                    if trvs:
                        foundProvider = True
                        self._addActionTroveBuildRequires([trvs[0][0][0]])
                        break
                if not foundProvider:
                    log.warning('Failed to find possible build requirement'
                                ' for path "%s"' % c)
                continue
            paths.append(fullPath)
        if not hasattr(self.recipe, '_pathLookupCache'):
            pathCache = self.recipe._pathLookupCache = _pathLookupCache()
        else:
            pathCache = self.recipe._pathLookupCache
        suggestsMap = pathCache.getTrovesByPaths(self._getDb(), paths)
        suggests = set()
        for k, v in suggestsMap.items():
            suggests.update(v)
        # Add the trove requirements
        suggests.update(self._actionTroveBuildRequires)
        # Tell reportExcessBuildRequires that all these are necessary
        if not hasattr(self.recipe, 'reportExcessBuildRequires'):
            return
        self.recipe.reportExcessBuildRequires(suggests)
        # Remove build requires that were already added
        suggests = suggests - set(buildRequires)
        if suggests:
            log.warning('Some missing buildRequires %s' % (sorted(suggests)))
            self.recipe.reportMissingBuildRequires(sorted(suggests))
Beispiel #5
0
    def doSuggestAutoBuildReqs(self):
        if not hasattr(self.recipe, "buildRequires"):
            # Most likely group recipe
            return
        if hasattr(self.recipe, "getRepos"):
            repos = self.recipe.getRepos()
        else:
            repos = None

        paths = []
        buildRequires = self.recipe._getTransitiveBuildRequiresNames()
        for cmd in self._actionPathBuildRequires:
            # Catch the case "python setup.py", as well as
            # 'ENV="a b"  somecommand'
            cmdarr = shlex.split(cmd)
            # Try to catch the command "ENVVAR=val make": skip all words that
            # have an equal sign in them
            c = cmd
            for x in cmdarr:
                if '=' not in x:
                    c = x
                    break
            # If the above for loop didn't find anything remotely resembling a
            # command, use the original one
            c = c % self.recipe.macros
            fullPath = util.checkPath(c)
            if (not fullPath) and repos:
                if not c.startswith('/'):
                    candidatePaths = [os.path.join(x, c)
                        for x in os.getenv('PATH', '').split(os.path.pathsep)]
                else:
                    candidatePaths = [c]
                foundProvider = False
                for label in self.recipe.cfg.installLabelPath:
                    trvDict = repos.getTroveVersionsByPath(candidatePaths,
                                                           label)
                    trvs = [x for x in trvDict.values() if x]
                    if trvs:
                        foundProvider = True
                        self._addActionTroveBuildRequires([trvs[0][0][0]])
                        break
                if not foundProvider:
                    log.warning('Failed to find possible build requirement'
                        ' for path "%s"' % c)
                continue
            paths.append(fullPath)
        if not hasattr(self.recipe, '_pathLookupCache'):
            pathCache = self.recipe._pathLookupCache = _pathLookupCache()
        else:
            pathCache = self.recipe._pathLookupCache
        suggestsMap = pathCache.getTrovesByPaths(self._getDb(), paths)
        suggests = set()
        for k, v in suggestsMap.items():
            suggests.update(v)
        # Add the trove requirements
        suggests.update(self._actionTroveBuildRequires)
        # Tell reportExcessBuildRequires that all these are necessary
        if not hasattr(self.recipe, 'reportExcessBuildRequires'):
            return
        self.recipe.reportExcessBuildRequires(suggests)
        # Remove build requires that were already added
        suggests = suggests - set(buildRequires)
        if suggests:
            log.warning('Some missing buildRequires %s' %(sorted(suggests)))
            self.recipe.reportMissingBuildRequires(sorted(suggests))
Beispiel #6
0
 def setUp(self):
     if not util.checkPath('git'):
         raise testhelp.SkipTestException('git not installed')
     rephelp.RepositoryHelper.setUp(self)
Beispiel #7
0
 def setUp(self):
     if not util.checkPath('git'):
         raise testhelp.SkipTestException('git not installed')
     rephelp.RepositoryHelper.setUp(self)