Exemplo n.º 1
0
    def processPath(self, path):
        if not path.startswith('/'):
            path = self.macros['builddir'] + os.sep + path
        f = open(path)
        for line in f:
            line = line.strip()
            fields = line.split(')')

            attr = fields[0].lstrip('%attr(').split(',')
            perms = attr[0].strip()
            owner = attr[1].strip()
            group = attr[2].strip()

            fields[1] = fields[1].strip()
            if fields[1].startswith('%dev('):
                dev = fields[1][5:].split(',')
                devtype = dev[0]
                major = dev[1]
                minor = dev[2]
                target = fields[2].strip()
                self.recipe.MakeDevices(target, devtype, int(major), int(minor),
                                        owner, group, int(perms, 0))
            elif fields[1].startswith('%dir '):
                pass
                # ignore -- Conary directory handling is too different
                # to map
            else:
                # XXX is this right?
                target = fields[1].strip()
                if int(perms, 0) & 06000:
                    self.recipe.setModes(int(perms, 0),
                                         util.literalRegex(target))
                if owner != 'root' or group != 'root':
                    self.recipe.Ownership(owner, group,
                                          util.literalRegex(target))
Exemplo n.º 2
0
 def doProcess(self, recipe):
     empty = True
     for files in self.doRpm(
             recipe,
             '[%{NAME} %{FILEMODES:octal} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\\n]'
     ):
         files_split = files.split(' ')
         for i in range(len(files_split) - 1, 0, -1):
             if files_split[i] == '(none)': del files_split[i]
         if len(files_split) >= 5:
             empty = False
             name, perms, owner, group = files_split[:4]
             target = ' '.join(files_split[4:])
             recipe.setModes(int(perms, 0), util.literalRegex(target))
             if owner != 'root' or group != 'root':
                 recipe.Ownership(owner, group, util.literalRegex(target))
             target = re.escape(target)
             print 'PackageSpec', name, target
             recipe.PackageSpec(name, target)
     if empty:
         os.makedirs('%(destdir)s/etc/condora/' % self.recipe.macros)
         with open('%(destdir)s/etc/condora/%(name)s' % self.recipe.macros,
                   'w') as f:
             f.write('')
Exemplo n.º 3
0
    def processPath(self, path):
        if not path.startswith('/'):
            path = self.macros['builddir'] + os.sep + path
        f = open(path)
        for line in f:
            line = line.strip()
            fields = line.split(')')

            attr = fields[0].lstrip('%attr(').split(',')
            perms = attr[0].strip()
            owner = attr[1].strip()
            group = attr[2].strip()

            fields[1] = fields[1].strip()
            if fields[1].startswith('%dev('):
                dev = fields[1][5:].split(',')
                devtype = dev[0]
                major = dev[1]
                minor = dev[2]
                target = fields[2].strip()
                self.recipe.MakeDevices(target, devtype,
                                        int(major), int(minor), owner, group,
                                        int(perms, 0))
            elif fields[1].startswith('%dir '):
                pass
                # ignore -- Conary directory handling is too different
                # to map
            else:
                # XXX is this right?
                target = fields[1].strip()
                if int(perms, 0) & 06000:
                    self.recipe.setModes(int(perms, 0),
                                         util.literalRegex(target))
                if owner != 'root' or group != 'root':
                    self.recipe.Ownership(owner, group,
                                          util.literalRegex(target))
Exemplo n.º 4
0
 def doProcess(self, recipe):
     empty = True
     for files in self.doRpm(recipe, '[%{NAME} %{FILEMODES:octal} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\\n]'):
         files_split = files.split(' ')
         for i in range(len(files_split)-1, 0, -1):
             if files_split[i] == '(none)': del files_split[i]
         if len(files_split) >= 5:
             empty = False
             name, perms, owner, group = files_split[:4]
             target = ' '.join(files_split[4:])
             recipe.setModes(int(perms, 0), util.literalRegex(target))
             if owner != 'root' or group != 'root': recipe.Ownership(owner, group, util.literalRegex(target))
             target = re.escape(target)
             print 'PackageSpec', name, target
             recipe.PackageSpec(name, target)
     if empty:
         os.makedirs('%(destdir)s/etc/condora/'%self.recipe.macros)
         with open('%(destdir)s/etc/condora/%(name)s'%self.recipe.macros,'w') as f: f.write('')
Exemplo n.º 5
0
    def doFile(self, path):
        if hasattr(self.recipe, '_getCapsulePathsForFile'):
            if self.recipe._getCapsulePathsForFile(path):
                return

        m = self.recipe.macros
        fullpath = '/'.join((m.destdir, path))
        if os.path.islink(fullpath):
            linkpath = os.readlink(fullpath)
            if m.destdir not in linkpath:
                # RelativeSymlinks has already run. linkpath is relative to
                # fullpath
                newpath = util.joinPaths(os.path.dirname(fullpath), linkpath)
                if os.path.exists(newpath):
                    fullpath = newpath
                else:
                    # If the target of an init script is not present, don't
                    # error, DanglingSymlinks will address this situation.
                    self.warn('%s is a symlink to %s, which does not exist.' % \
                            (path, linkpath))
                    return

        contents = file(fullpath).read()
        modified = False
        if ('/etc/rc.d/init.d' != m.initdir and
            '/etc/rc.d/init.d' in contents):
            contents = contents.replace('/etc/rc.d/init.d', m.initdir)
            modified = True
        elif ('/etc/init.d' != m.initdir and
              '/etc/init.d' in contents):
            contents = contents.replace('/etc/init.d', m.initdir)
            modified = True

        if '%(initdir)s/functions' %m in contents:
            self.recipe.Requires('file: %(initdir)s/functions',
                                 util.literalRegex(path))

        if modified:
            file(fullpath, 'w').write(contents)
Exemplo n.º 6
0
    def do(self):
        missingBuildRequiresChoices = []

        components = self.recipe.autopkg.components
        pathMap = self.recipe.autopkg.pathMap
        pathReqMap = {}
        interpreterSet = set()

        interpreterMap = {}
        for path in pathMap:
            if (hasattr(self.recipe, '_isDerived')
                and self.recipe._isDerived == True
                and self.processUnmodified is False
                and path in self.recipe._derivedFiles
                and not self.mtimeChanged(path)):
                # ignore this file
                continue
            if self.ignoreCapsuleFiles and hasattr(self.recipe,
                                              '_getCapsulePathsForFile'):
                if self.recipe._getCapsulePathsForFile(path):
                    continue
            pkgfile = pathMap[path]
            if pkgfile.hasContents:
                m = self.recipe.magic[path]
                if isinstance(m, magic.script):
                    interpreter = m.contents['interpreter']
                    if interpreter:
                        interpreterMap[path] = (pkgfile.requires(), interpreter)

        provideNameMap = dict([(x[0], x) for x in
                               itertools.chain(*self.systemProvides.values())])

        for dep in self.systemProvides:
            provideNameList = [x[0] for x in self.systemProvides[dep]]
            # normally, there is only one name in provideNameList

            foundCandidates = set()
            for name in provideNameList:
                for candidate in _providesNames(name):
                    if self.db.hasTroveByName(candidate):
                        foundCandidates.add(candidate)
                        provideNameMap[candidate] = provideNameMap[name]
                        break
            # report before exceptions
            reportFoundBuildRequires(self.recipe, foundCandidates)
            foundCandidates = self._removeExceptions(foundCandidates)

            missingCandidates = foundCandidates - self.transitiveBuildRequires
            if foundCandidates and missingCandidates == foundCandidates:
                # None of the troves that provides this requirement is
                # reflected in the buildRequires list.  Add candidates
                # to proper list to print at the end:
                if len(foundCandidates) > 1:
                    reduceTroves = sorted([provideNameMap[x]
                                          for x in foundCandidates])
                    reduceTroves = _reduceCandidates(self.db, reduceTroves)
                    foundCandidates = set([x[0] for x in reduceTroves])
                    if len(foundCandidates) == 1:
                        break
                    found = False
                    for candidateSet in missingBuildRequiresChoices:
                        if candidateSet == foundCandidates:
                            found = True
                    if found == False:
                        self.addMissingBuildRequires(foundCandidates)
                else:
                    self.addMissingBuildRequires(foundCandidates)

                # Now give lots of specific information to help the packager
                # in case things do not look so obvious...
                pathList = []
                for path in pathMap:
                    if (hasattr(self.recipe, '_isDerived')
                        and self.recipe._isDerived == True
                        and self.processUnmodified is False
                        and path in self.recipe._derivedFiles
                        and not self.mtimeChanged(path)):
                        # ignore this file
                        continue
                    if self.ignoreCapsuleFiles and hasattr(self.recipe,
                                                  '_getCapsulePathsForFile'):
                        if self.recipe._getCapsulePathsForFile(path):
                            continue
                    pkgfile = pathMap[path]
                    if pkgfile.hasContents and (pkgfile.requires() & dep):
                        pathList.append(path)
                        l = pathReqMap.setdefault(path, [])
                        l.append(dep)
                if pathList:
                    self.warn('buildRequires %s needed to satisfy "%s"'
                              ' for files: %s',
                              str(sorted(list(foundCandidates))),
                              str(dep),
                              ', '.join(sorted(pathList)))

            # look for interpreters
            if path in interpreterMap:
                requires, interpreter = interpreterMap[path]
                if requires & dep:
                    interpreterSet.add(interpreter)

        if interpreterSet:
            # find their components and add them to the list
            for interpreter in interpreterSet:
                for trove in self.db.iterTrovesByPath(interpreter):
                    interpreterTroveName = trove.getName()
                    if interpreterTroveName not in self.transitiveBuildRequires:
                        self.talk('interpreter %s missing build requirement %s',
                                  interpreter, interpreterTroveName)
                        self.addMissingBuildRequires((interpreterTroveName,))

        if pathReqMap:
            for path in pathReqMap:
                self.warn('file %s has unsatisfied build requirements "%s"',
                          path, '", "'.join([
                             str(x) for x in
                               sorted(list(set(pathReqMap[path])))]))

        if self.missingBuildRequires:
            self.reportMissingBuildRequires()

        if missingBuildRequiresChoices:
            for candidateSet in missingBuildRequiresChoices:
                self.talk('add to buildRequires one of: %s',
                           str(sorted(list(candidateSet))))
            # These are too unclear to pass to reportMissingBuildRequires
        if self.unprovided:
            self.talk('The following dependencies are not resolved'
                      ' within the package or in the system database: %s',
                      str(sorted([str(x) for x in self.unprovided])))
            self.talk('The package may not function if installed, and'
                      ' Conary may require the --no-deps option to install the'
                      ' package.')
            self.talk('If you know that these libraries are really provided'
                      ' within the package, add these lines:')
            for depStr in sorted(str(x) for x in self.unprovided):
                self.talk("       r.Requires(exceptDeps=r'%s')" % 
                           util.literalRegex(depStr))