Exemplo n.º 1
0
class ImageTroveSettings(trovesettings.TroveSettings):
    urls = CfgList(CfgString)
    imageType = CfgString
    imageOptions = CfgDict(CfgString)
    imageBuildId = CfgInt
    productName = CfgString
    buildName = CfgString
Exemplo n.º 2
0
    def updateFromString(self, val, str):
        suppProtocols = ['http', 'https']
        vlist = str.split()
        if len(vlist) > 2:
            raise ParseError("Too many arguments for proxy configuration '%s'"
                             % str)
        if not vlist:
            raise ParseError("Arguments required for proxy configuration")
        if len(vlist) == 2:
            if vlist[0] not in suppProtocols:
                raise ParseError('Unknown proxy procotol %s' % vlist[0])
            if vlist[1] == "None":
                # Special value to turn proxy values off
                if vlist[0] in val:
                    del val[vlist[0]]
                return val
            return CfgDict.updateFromString(self, val, str)

        # At this point, len(vlist) == 1
        # Fix it up
        try:
            protocol, rest = str.split(':', 1)
        except ValueError:
            # : not in the value
            if str == "None":
                # Special value that turns off the proxy
                for protocol in suppProtocols:
                    if protocol in val:
                        del val[protocol]
                return val
            raise ParseError("Invalid proxy configuration value %s" % str)

        # This next test duplicates the work done by ProxyEntry.parseString,
        # but it's pretty cheap to do here since we already have the protocol
        # parsed out
        if protocol not in suppProtocols:
                raise ParseError('Unknown proxy procotol %s' % protocol)

        CfgDict.updateFromString(self, val, 'http http:' + rest)
        CfgDict.updateFromString(self, val, 'https https:' + rest)
        return val
Exemplo n.º 3
0
    def updateFromString(self, val, str):
        suppProtocols = ['http', 'https']
        vlist = str.split()
        if len(vlist) > 2:
            raise ParseError(
                "Too many arguments for proxy configuration '%s'" % str)
        if not vlist:
            raise ParseError("Arguments required for proxy configuration")
        if len(vlist) == 2:
            if vlist[0] not in suppProtocols:
                raise ParseError('Unknown proxy procotol %s' % vlist[0])
            if vlist[1] == "None":
                # Special value to turn proxy values off
                if vlist[0] in val:
                    del val[vlist[0]]
                return val
            return CfgDict.updateFromString(self, val, str)

        # At this point, len(vlist) == 1
        # Fix it up
        try:
            protocol, rest = str.split(':', 1)
        except ValueError:
            # : not in the value
            if str == "None":
                # Special value that turns off the proxy
                for protocol in suppProtocols:
                    if protocol in val:
                        del val[protocol]
                return val
            raise ParseError("Invalid proxy configuration value %s" % str)

        # This next test duplicates the work done by ProxyEntry.parseString,
        # but it's pretty cheap to do here since we already have the protocol
        # parsed out
        if protocol not in suppProtocols:
            raise ParseError('Unknown proxy procotol %s' % protocol)

        CfgDict.updateFromString(self, val, 'http http:' + rest)
        CfgDict.updateFromString(self, val, 'https https:' + rest)
        return val
Exemplo n.º 4
0
class RmakeBuildContext(cfg.ConfigSection):

    _cfg_bases = [conarycfg.ConaryContext]

    bootstrapTroves = (
        CfgList(CfgTroveSpec), [],
        "INTERNAL USE ONLY: Troves to be installed before the remaining "
        "chroot contents.")
    copyInConary = (CfgBool, False)
    copyInConfig = (CfgBool, False)  # RMK-1052
    rbuilderUrl = (cfgtypes.CfgString, 'https://localhost/')
    rmakeUser = (CfgUser, None)
    if not compat.ConaryVersion().supportsDefaultBuildReqs():
        defaultBuildReqs = (CfgList(CfgString), [
            'bash:runtime',
            'coreutils:runtime',
            'filesystem',
            'conary:runtime',
            'conary-build:runtime',
            'dev:runtime',
            'grep:runtime',
            'sed:runtime',
            'findutils:runtime',
            'gawk:runtime',
        ])
    else:
        defaultBuildReqs = (CfgList(CfgString), [])
    resolveTroves = (CfgList(CfgQuotedLineList(CfgTroveSpec)),
                     [[('group-dist', None, None)]])
    matchTroveRule = (CfgList(CfgString), [])
    resolveTrovesOnly = (CfgBool, False)
    reuseRoots = (CfgBool, False)
    rpmRequirements = (
        CfgList(CfgDependency), [],
        "INTERNAL USE ONLY: Dep provided by the RPM to be used for "
        "installation of the chroot.")
    strictMode = (CfgBool, False)
    targetLabel = (CfgLabel, versions.Label('NONE@local:NONE'))
    uuid = (CfgUUID, '')

    # DEPRECATED
    subscribe = CfgDict(CfgString)

    def __init__(self, parent, doc=None):
        cfg.ConfigSection.__init__(self, parent, doc=None)
        if hasattr(self, 'addConfigOption'):
            # Conary < 2.5
            for info in conarycfg.ConaryContext._getConfigOptions():
                if info[0] not in self:
                    self.addConfigOption(*info)
Exemplo n.º 5
0
class BobTargetSection(cfg.ConfigSection):
    '''
    Target trove configuration:
    [target:tmpwatch]
    flavor_set plain
    '''

    scm                     = CfgString
    after                   = CfgList(CfgString)
    classVar                = CfgDict(CfgString)
    flavor_mask             = CfgFlavor
    flavor_set              = CfgString
    flavor                  = CfgList(CfgString)
    macros                  = CfgDict(CfgString)
    version                 = CfgString             # macros supported
    sourceTree              = CfgString
    serializeFlavors        = CfgBool
    noBuild                 = CfgBool
    factory                 = (CfgString, '')

    _cfg_aliases = [
            ('hg', 'scm'),
            ('git', 'scm'),
            ]
Exemplo n.º 6
0
class rMakeBuilderConfiguration(daemon.DaemonConfig):
    buildDir = (CfgPath, '/var/rmake')
    helperDir = (CfgPath, "/usr/libexec/rmake")
    slots = (CfgInt, 1)
    useCache = (CfgBool, False)
    useTmpfs = (CfgBool, False)
    pluginDirs = (CfgPathList, ['/usr/share/rmake/plugins'])
    usePlugins = (CfgBool, True)
    usePlugin = CfgDict(CfgBool)
    chrootLimit = (CfgInt, 4)
    chrootCache = CfgChrootCache
    chrootCaps = (CfgBool, False,
                  "Set capability masks as directed by chroot contents. "
                  "This has the potential to be unsafe.")
    chrootServerPorts = (CfgPortRange, (63000, 64000),
                         "Port range to be used for 'rmake chroot' sessions.")
    hostName = (CfgString, 'localhost')
    verbose = False

    def getAuthUrl(self):
        return None

    def getCommandSocketDir(self):
        return self.buildDir + '/tmp/'

    def getName(self):
        return '_local_'

    def getCacheDir(self):
        return self.buildDir + '/cscache'

    def getChrootDir(self):
        return self.buildDir + '/chroots'

    def getChrootArchiveDir(self):
        return self.buildDir + '/archive'

    def getBuildLogDir(self, jobId=None):
        if jobId:
            return self.logDir + '/buildlogs/%d/' % jobId
        return self.logDir + '/buildlogs/'

    def getBuildLogPath(self, jobId):
        return self.logDir + '/buildlogs/%d.log' % jobId

    def getChrootHelper(self):
        return self.helperDir + '/chroothelper'

    def getChrootCache(self):
        if not self.chrootCache:
            return None
        elif self.chrootCache[0] == 'local':
            return chrootcache.LocalChrootCache(self.chrootCache[1])
        else:
            raise errors.RmakeError(
                'unknown chroot cache type of "%s" specified' %
                self.chrootCache[0])

    def _getChrootCacheDir(self):
        if not self.chrootCache:
            return None
        elif self.chrootCache[0] == 'local':
            return self.chrootCache[1]
        return None

    def _checkDir(self, name, path, requiredOwner=None, requiredMode=None):
        if not os.path.exists(path):
            raise errors.RmakeError(
                '%s does not exist, expected at %s - cannot start server' %
                (name, path))
            sys.exit(1)
        if not (requiredOwner or requiredMode):
            return
        statInfo = os.stat(path)
        if requiredMode and statInfo.st_mode & 0777 != requiredMode:
            raise errors.RmakeError('%s (%s) must have mode %o' %
                                    (path, name, requiredMode))
        if requiredOwner:
            ownerName = pwd.getpwuid(statInfo.st_uid).pw_name
            if ownerName != requiredOwner:
                raise errors.RmakeError('%s (%s) must have owner %s' %
                                        (path, name, requiredOwner))
Exemplo n.º 7
0
 def __init__(self, default={}):
     CfgDict.__init__(self, ProxyEntry, default=default)
Exemplo n.º 8
0
class UpdateBotConfigSection(cfg.ConfigSection):
    """
    Config class for updatebot.
    """

    # R0904 - to many public methods
    # pylint: disable=R0904

    # Mode that updatebot is running in. (possible values ar
    # 'ordered' and 'latest'.
    updateMode = CfgString

    # name of the product to use in advisories
    productName = CfgString

    # platform short name
    platformName = CfgString

    # upstream product version
    upstreamProductVersion = CfgString

    # disables checks for update completeness, this should only be enabled if
    # you know what you are doing and have a good reason.
    disableUpdateSanity = CfgBool

    # path to configuration files relative to updatebotrc (conaryrc, rmakerc)
    configPath = (CfgString, './')

    # type of upstream repostory to pull packages from, supported are apt
    # and yum.
    repositoryFormat = (CfgString, 'yum')

    # Default commit message to use when committing to the repository.
    commitMessage = (CfgString, 'Automated commit by updateBot')

    # Url to the yum repository
    repositoryUrl = CfgString

    # Paths based off of the repositoryUrl to get to individual repositories.
    repositoryPaths = (CfgList(CfgString), ['/'])

    # Treat any path matching this spec as "base" (ISO) content.
    # In other words, these packages are the golden bits, not errata.
    repositoryBasePaths = (CfgList(CfgRegExp), [])

    # Arch strings for each repository to signify what base architecture each
    # repository is meant for.
    # repositoryName archString
    repositoryArch = (CfgDict(CfgString), {})

    # Add a package to a particular repository. This is useful for adding x86
    # packages to an x86_64 group. Normally in the form: pkgName conaryVersion
    # archStr repositoryArch
    repositoryPackage = (CfgList(CfgStringFourTuple), [])

    # Associate binaries generated from a nosrc package with a source package
    # name if the nosrc package matches a given regular expression.
    nosrcFilter = (CfgList(CfgStringFilter), [])

    # Ignore packages with "32bit" in the name. This is intened for use with
    # SLES based platforms.
    ignore32bitPackages = (CfgBool, False)

    # Data source for determining platform version information, only used for
    # group versioning.
    versionSources = (CfgDict(CfgString), {})

    # The top level binary group, this may be the same as topSourceGroup.
    topGroup = CfgTroveSpec

    # The top level source group.
    topSourceGroup = CfgTroveSpec

    # Parent top level source group
    topParentSourceGroup = CfgTroveSpec

    # Path to search for packages to be included in the platform.
    platformSearchPath = (CfgQuotedLineList(CfgLabel), [])

    # Group contents info.
    groupContents = (CfgDict(CfgDict(CfgString)), {})

    # Other labels that are referenced in the group that need to be flattend
    # onto the targetLabel.
    sourceLabel = (CfgList(CfgBranch), [])

    # Label to promote to
    targetLabel = CfgBranch

    # Packages other than the topGroup that need to be promoted.
    extraPromoteTroves = (CfgList(CfgTroveSpec), [])

    # Extra packages that are expected to be in the promote result set at a
    # given bucketId. These are normally packages that for some reason or
    # another, usually deps, we had to rebuild.
    extraExpectedPromoteTroves = (CfgIntDict(CfgList(CfgTroveSpec)), {})

    # List of source packages for which we expect manifest differences
    # between parent and child platform. When differences are found,
    # create a new package on the child label, overriding the
    # parent-platform package/manifest.
    expectParentManifestDifferences = (CfgList(CfgString), [])

    # For debugging the above--use with caution!
    ignoreAllParentManifestDifferences = (CfgBool, False)

    # Packages to import
    package = (CfgList(CfgString), [])

    # Include all packages, if this is set to true packages becomes an
    # exclude list.
    packageAll = (CfgBool, False)

    # Factory to use for importing
    newPackageFactory = (CfgString, None)

    # Package to exclude from all updates, these are normally packages that
    # are not managed as part of this distro (ie. in sles we pull some
    # packages from rpl:1).
    excludePackages = (CfgList(CfgString), [])

    # Exclude these archs from the rpm source.
    excludeArch = (CfgList(CfgString), [])

    # Disable advisories all together.
    disableAdvisories = (CfgBool, False)

    # Packages for which there might not reasonably be advisories. Define a
    # default advisory message to send with these packages.
    advisoryException = (CfgList(CfgList(CfgString)), [])

    # Filter out patches with matching descriptions or summaries.
    patchFilter = (CfgList(CfgRegExp), [])

    # url to base archive searchs off of
    listArchiveBaseUrl = CfgString

    # date to start querying archives
    listArchiveStartDate = CfgString

    # list of contexts that all packages are built in.
    archContexts = CfgList(CfgStringFilter)

    # flavors to build the source group.
    groupFlavors = (CfgList(CfgFlavor), [])

    # flavors to build kernels.
    kernelFlavors = (CfgList(CfgStringFlavor), [])

    # packages other than "kernel" to be built in kernelFlavers
    kernelModules = (CfgList(CfgString), [])

    # flavors to build packages in for packages that need specific flavoring.
    packageFlavors = (CfgDict(CfgList(CfgStringFlavor)), {})

    # 3-tuple of (context, flavor, regex) of arch-specific package
    # flavors to omit unless the regex matches a binary package in the
    # manifest.  Useful for omitting built of otherwise-expected flavors
    # when a package is missing from the repository.
    packageFlavorsMissing = (CfgDict(CfgList(CfgFlavorFilter)), {})

    # After committing a rMake job to the repository pull the changeset back out
    # to make sure all of the contents made it into the repository.
    sanityCheckCommits = (CfgBool, False)

    # Check the changeset for any rpm capsules and validate that the changeset
    # contents match the rpm header. Implies saveChangeSets.
    sanityCheckChangesets = (CfgBool, False)

    # Save all binary changesets to disk before committing them.
    saveChangeSets = (CfgBool, False)

    # Always build this list of package names in one job rather than splitting
    # them up in the case that you are using a builder that splits by default.
    combinePackages = (CfgList(CfgQuotedLineList(CfgString)), [])

    # email information for sending advisories
    emailFromName = CfgString
    emailFrom = CfgString
    emailTo = (CfgList(CfgString), [])
    emailBcc = (CfgList(CfgString), [])
    smtpServer = CfgString

    # Jira Info
    jiraUser = CfgString
    jiraPassword = CfgString
    jiraUrl = CfgString
    jiraSecurityGroup = CfgString

    # Satis Info
    satisUrl = CfgString

    # Try to build from source rpms
    buildFromSource = (CfgBool, False)

    # Write package metadata to the source trove no matter the source
    # package format.
    writePackageMetadata = (CfgBool, False)

    # Write version information to the source trove, generated from the source
    # version and revision.
    writePackageVersion = (CfgBool, False)

    # If sources are not available pkgSource will attempt to build artificial
    # source information if this is set to True.
    synthesizeSources = (CfgBool, False)

    # Number of troves at which to switch to a splitarch build. This is mostly
    # a magic number, but at least it is configurable?
    maxBuildSize = (CfgInt, 10)

    # Map of updateIds to upstream versions to use if you don't want to use the
    # normal versioning scheme.
    upstreamVersionMap = (CfgIntDict(CfgString), {})

    # List of errata timestamps to merge together. This is used when one errata
    # leaves the platform in a non dependency closed state and a later update
    # should solve the dependency problem. All updates are folded into the first
    # bucket listed.
    mergeUpdates = (CfgList(CfgQuotedLineList(CfgInt)), [])

    # Sometimes, we synthesize a source for a nosrc rpm, because we
    # really don't know any better.  When we find out that, in fact,
    # the nosrc rpm belongs to a src rpm with a _different_ version,
    # the only way to resolve it is by an explicit merging of the two
    # source packages.
    mergeSources = (CfgList(CfgNevraTuple), [])

    # Timestamp of first erratum.  This is used as a baseline for
    # determining if any update packages are missing errata.  It should
    # auto-detect correctly, but in some cases--for instance, when a
    # distribution releases the same package as a baseline package on
    # one channel and an update on a parallel channel--this will require
    # manual specification.
    firstErrata = CfgInt

    # Timestamp of last erratum.  This is used to stop errata processing
    # at a specified timestamp, which is useful if recent errata are
    # broken and some sort of catch-up run is being done.
    lastErrata = CfgInt

    # Timestamp after which errata promotions begin.  This is useful in
    # cases where the baseline distribution must be split across
    # multiple updateId's in order to de-dupe the package list.
    errataPromoteAfter = (CfgInt, 0)

    # Errata timestamp pairs for rescheduling when updates are applied. The
    # first element is the current timestamp of the update. The second element
    # is the new timestamp. You may need to use this option if it appears that
    # the upstream provider has somehow managed to release updates out of order
    # and has caused dependency closure problems. Note that you will need to
    # mark remove anything that has been committed past the destination
    # timestamp to get mirrorball to go back and apply this update.
    reorderUpdates = (CfgList(CfgQuotedLineList(CfgInt)), [])

    # fromUpdateId toUpdateId advisory
    # Sometimes advisories are released out of order, but it is inconvienent to
    # move the entire update bucket.
    reorderAdvisory = (CfgList(CfgAdvisoryOrder), [])

    # advisory trovespec
    extendAdvisory = (CfgDict(CfgList(CfgTroveSpec)), {})

    # fromUpdateId toUpdateId sourceNevra
    # Sometimes multiple versions of the same package are released as part of a
    # single advisory. This does not fit the conary model of doing things, so we
    # have to reschedule one or more of these sources to another time so that
    # they end up in a binary group and get updated in the correct order.
    reorderSource = (CfgList(CfgSourceOrder), [])

    # reuse old revisions as used in SLES, where if on a rebuild with the
    # same version but different revision a subpackage does not change
    # content, the new build is not used
    reuseOldRevisions = (CfgBool, False)

    # updateId binaryPackageName
    # Dictionary of bucketIds and packages that are expected to be removed.
    updateRemovesPackages = (CfgIntDict(CfgList(CfgString)), {})

    # updateId binaryPackageName
    # Dictionary of bucketIds and packages that are expected to be moved
    # between sources.
    updateReplacesPackages = (CfgIntDict(CfgList(CfgString)), {})

    # updateId sourceNevra
    # As of updateId, remove source package specified by sourceNevra
    # from the package model
    removeSource = (CfgIntDict(CfgList(CfgNevra)), {})

    # updateId sourceNevra
    # As of updateId, remove resulting binaries from source package
    # specified by sourceNevra used when new pkg exists but has different
    # srpm than older pkg
    removeObsoletedSource = (CfgIntDict(CfgList(CfgNevra)), {})

    # updateId sourceNevra
    # At updateId, ignore the source package update specified by
    # sourceNevra and continue to use whatever previous version was in
    # the model.
    ignoreSourceUpdate = (CfgIntDict(CfgList(CfgNevra)), {})

    # updateId sourceNevra
    # At updateId, allow the source package (and any related binary
    # packages) specified by sourceNevra to be missing from the
    # repository. Useful for working around selected gaps uncovered by
    # OrderedBot._checkMissingPackages() during updates or promotes.
    allowMissingPackage = (CfgIntDict(CfgList(CfgNevra)), {})

    # updateId binaryNevra
    # As of updateId, I expect the code to think this nevra should be removed,
    # but I want to keep it.
    keepRemoved = (CfgIntDict(CfgList(CfgNevra)), {})

    # updateId sourceNevra
    # As of updateId, the specified src is fully obsoleted, but
    # should be retained in groups
    keepObsoleteSource = (CfgList(CfgNevraTuple), [])

    # Some obsoletes are merely conceptual preferences, and should not
    # turn into removals.
    # We would prefer CfgSet(CfgTuple(CfgNevra, CfgNevra), set())
    # but CfgSet and CfgTuple do not exist at this point;
    # maybe we can add them later.
    # keepObsolete <obsoleting nevra> <obsoleted nevra>
    keepObsolete = (CfgList(CfgNevraTuple), [])

    # updateId packageName [packageName ...]
    # remove obsoleted packages when other subpackages of the same
    # srpm are not obsoleted, so we cannot use removeSource
    removeObsoleted = (CfgIntDict(CfgList(CfgString)), {})

    # List of broken errata that have been researched and should be ignored
    # when reporting errors.
    brokenErrata = (CfgDict(CfgList(CfgNevra)), {})

    # Dictionary of updateId to list of trove specs. When the bucketId has been
    # reached, update to the version specified in the trovespec rather than the
    # latest that matches the current rpm version.
    useOldVersion = (CfgIntDict(CfgList(CfgTroveSpec)), {})

    # Add a package to a specific group
    addPackage = (CfgIntDict(CfgDict(CfgList(CfgStringFlavorUse))), {})

    # Remove a package from a specific group
    removePackage = (CfgIntDict(CfgDict(CfgList(CfgStringFlavorUse))), {})

    # Group name for group that contains all packages in a platform.
    packageGroupName = (CfgString, 'group-packages')

    # Allow updates for a given nevra to be published without matching errata.
    allowMissingErrata = (CfgList(CfgNevra), [])

    # Allow updates to have versions that go backwards.
    # updateId: [ (from srcTrvSpec, to srcTrvSpec), ... ]
    allowPackageDowngrades = (CfgIntDict(CfgList(CfgNevraTuple)), {})

    # Allow updates which don't include all binary packages corresponding
    # to a given source.
    allowRemovedPackages = (CfgBool, False)

    # Add a source to a specific updateId. This is used to move updates forward
    # after allowing an update to downgrade the version.
    addSource = (CfgIntDict(CfgList(CfgNevra)), {})

    # recreate any previously built packages. The default "false" will not attempt
    # to import the same package version more than once.
    recreate = (CfgBool, False)

    # uri to a pkgcache server
    pkgcacheUri = CfgString

    # Set the number of troves to send to rmake at the same time in current mode
    # It was hardwired to 1 now it is configurable. Be careful.
    # If you don't know then don't change it
    chunkSize = (CfgInt, 1)

    # Disable OldVersion check for repos that only move forward.
    # Added to support epel
    disableOldVersionCheck = (CfgBool, False)

    # Gem Factory to use for importing
    gemPackageFactory = (CfgString, None)

    # Gem Packages to import
    gemPackage = (CfgList(CfgString), [])

    # Gem Package Prefix to use for packages
    # because we need to know what the gem name is
    # without checking out the manifest
    # so we will strip off the prefix
    gemPrefix = (CfgString, None)

    # user config for artifactory api
    artifactoryUser = CfgUserInfo

    # allow rmake to commit outdated sources
    commitOutdatedSources = (CfgBool, False)

    # pom exclusion
    excludePoms = (CfgMavenCoordinateList, [])

    # pom relocation
    relocatePoms = (CfgRelocatePomList, [])
Exemplo n.º 9
0
 def toStrings(self, value, displayOptions):
     value = dict([(str(x), y) for x, y in value.iteritems()])
     return CfgDict.toStrings(self, value, displayOptions)
Exemplo n.º 10
0
class ConaryContext(ConfigSection):
    """ Conary uses context to let the value of particular config parameters
        be set based on a keyword that can be set at the command line.
        Configuartion values that are set in a context are overridden
        by the values in the context that have been set.  Values that are
        unset in the context do not override the default config values.
    """
    archDirs = (CfgPathList, ('/etc/conary/arch', '/etc/conary/distro/arch',
                              '~/.conary/arch'))
    autoLoadRecipes = CfgList(CfgString)
    autoResolve = (CfgBool, False)
    autoResolvePackages = (CfgBool, True)
    buildFlavor = CfgFlavor
    buildLabel = CfgLabel
    buildPath = (CfgPath, '~/conary/builds')
    cleanAfterCook = (CfgBool, True)
    commitRelativeChangeset = (CfgBool, False)
    componentDirs = (CfgPathList,
                     ('/etc/conary/components',
                      '/etc/conary/distro/components', '~/.conary/components'))
    configComponent = (CfgBool, True)
    contact = None
    context = None
    dbPath = '/var/lib/conarydb'
    debugExceptions = (CfgBool, False)
    debugRecipeExceptions = (CfgBool, False)
    defaultMacros = (CfgPathList,
                     ('/etc/conary/macros', '/etc/conary/macros.d/*',
                      '~/.conary/macros'))
    emergeUser = (CfgString, 'emerge')
    enableRPMVersionDeps = (CfgBool, True)
    enforceManagedPolicy = (CfgBool, True)
    entitlement = CfgEntitlement
    entitlementDirectory = (CfgPath, '/etc/conary/entitlements')
    environment = CfgDict(CfgString)
    excludeTroves = CfgRegExpList
    flavor = CfgList(CfgFlavor)
    flavorPreferences = CfgList(CfgFlavor)
    fullVersions = CfgBool
    fullFlavors = CfgBool
    localRollbacks = CfgBool
    keepRequired = CfgBool
    ignoreDependencies = (CfgDependencyClassList,
                          [deps.AbiDependency, deps.RpmLibDependencies])
    installLabelPath = CfgInstallLabelPath
    interactive = (CfgBool, False)
    logFile = (CfgPathList, (
        '/var/log/conary',
        '~/.conary/log',
    ))
    lookaside = (CfgPath, '~/conary/cache')
    macros = CfgDict(CfgString)
    mirrorDirs = (CfgPathList, (
        '~/.conary/mirrors',
        '/etc/conary/distro/mirrors',
        '/etc/conary/mirrors',
    ))
    modelPath = '/etc/conary/system-model'
    name = None
    quiet = CfgBool
    pinTroves = CfgRegExpList
    policyDirs = (CfgPathList,
                  ('/usr/lib/conary/policy', '/usr/lib/conary/distro/policy',
                   '/etc/conary/policy', '~/.conary/policy'))
    shortenGroupFlavors = CfgBool
    syncCapsuleDatabase = (CfgCapsuleSync, 'update')
    # Upstream Conary proxy
    conaryProxy = CfgProxy
    # HTTP proxy
    proxy = CfgProxy
    proxyMap = CfgProxyMap
    connectAttempts = (CfgInt, 3, "Number of connection attempts to make "
                       "for outbound HTTP requests.")
    downloadAttempts = (CfgInt, 3, "Number of attempts to restart an "
                        "interrupted download")
    downloadRetryThreshold = (
        CfgBytes('M'), 10000000,
        "Reset the download attempt count if at least this many megabytes "
        "have been transferred since the last failure")
    downloadRetryTrim = (
        CfgBytes('k'), 1000000,
        "If a download is reattempted, trim this many kilobytes off the "
        "end of what was previously downloaded. 0 disables this feature.")
    # The first keyring in the list is writable, and is used for storing the
    # keys that are not present on the system-wide keyring. Always expect
    # Conary to write to the first keyring.
    pubRing = (CfgPathList, _getDefaultPublicKeyrings())
    uploadRateLimit = (CfgBytes(perSecond=True), 0,
                       "Upload rate limit, in bytes per second")
    downloadRateLimit = (CfgBytes(perSecond=True), 0,
                         "Download rate limit, in bytes per second")

    recipeTemplate = None
    repositoryMap = CfgRepoMap
    resolveLevel = (CfgInt, 2)
    root = (CfgPath, '/')
    recipeTemplateDirs = (CfgPathList, ('~/.conary/recipeTemplates',
                                        '/etc/conary/recipeTemplates'))
    showLabels = CfgBool
    showComponents = CfgBool
    searchPath = CfgSearchPath
    signatureKey = CfgFingerPrint
    signatureKeyMap = CfgFingerPrintMap
    siteConfigPath = (CfgPathList,
                      ('/etc/conary/site', '/etc/conary/distro/site',
                       '~/.conary/site'))
    sourceSearchDir = (CfgPath, '.')
    threaded = (CfgBool, True)
    downloadFirst = (CfgBool, False)
    tmpDir = (CfgPath, _getDefaultTempDir())
    trustThreshold = (CfgInt, 0)
    trustedCerts = (
        CfgPathList, (),
        'List of CA certificates which are trusted to identify a remote '
        'repository using SSL. Entries may be files, dirs, or globs.')
    trustedKeys = (CfgList(CfgString), [])
    updateThreshold = (CfgInt, 15)
    useDirs = (CfgPathList, ('/etc/conary/use', '/etc/conary/distro/use',
                             '~/.conary/use'))
    user = CfgUserInfo
    baseClassDir = (CfgPath, '/usr/share/conary/baseclasses')
    verifyDirsNoNewFiles = (CfgPathList,
                            ('/proc', '/sys', '/home', '/dev', '/mnt', '/tmp',
                             '/var', '/media', '/initrd'))
    windowsBuildService = CfgString

    systemIdScript = CfgPath

    def _resetSigMap(self):
        self.resetToDefault('signatureKeyMap')

    def __init__(self, *args, **kw):
        ConfigSection.__init__(self, *args, **kw)
        self.addListener('signatureKey', lambda *args: self._resetSigMap())

    def _writeKey(self, out, cfgItem, value, options):
        # Suppress all default values, as opposed to the default behavior which
        # only suppresses defaults that are None
        name = cfgItem.name
        if name not in self._values or self._values[name].isDefault():
            return
        ConfigSection._writeKey(self, out, cfgItem, value, options)
Exemplo n.º 11
0
 def __init__(self, default={}):
     CfgDict.__init__(self, ProxyEntry, default=default)
Exemplo n.º 12
0
class BobConfig(cfg.SectionedConfigFile):
    targetLabel             = CfgString             # macros supported

    # source
    sourceLabel             = CfgString             # DEPRECATED (ignored)
    macros                  = CfgDict(CfgString)
    override                = CfgDict(CfgString)
    resolveTroves           = CfgList(CfgQuotedLineList(
                                        CfgString)) # macros supported
    resolveTrovesOnly       = (CfgBool, True)
    ephemeral               = (CfgBool, False)
    ephemeralSourceDir      = CfgPath
    autoLoadRecipes         = (CfgList(CfgString), [])
    scm                     = CfgDict(CfgString)    # macros supported
    refreshSources          = (CfgBool, False)
    wmsBase                 = CfgString

    # build
    installLabelPath        = CfgQuotedLineList(
                                CfgString)          # macros supported
    needWmsToken            = CfgBool
    noClean                 = (CfgBool, False,
            "Don't clean the rMake chroot immediately "
            "after a successful build.")
    shortenGroupFlavors     = (CfgBool, True)
    target                  = CfgList(CfgString)
    showBuildLogs           = (CfgBool, False)
    defaultBuildReqs        = CfgList(CfgString)
    rpmRequirements         = CfgList(CfgDependency)

    # misc
    commitMessage           = (CfgString, 'Automated clone by bob')
    skipMacros              = (CfgList(CfgString), ['version'])

    # debugging
    dumpRecipes             = CfgBool
    depMode                 = CfgBool
    recipeDir               = CfgPath

    # custom handling of sections
    _sectionMap = {'target': BobTargetSection}

    def __init__(self):
        cfg.SectionedConfigFile.__init__(self)
        self.scmPins = {}
        self._macros = None

    def read(self, path, **kwargs):
        if path.startswith('http://') or path.startswith('https://'):
            return cfg.SectionedConfigFile.readUrl(self, path, **kwargs)
        else:
            return cfg.SectionedConfigFile.read(self, path, **kwargs)

    def setSection(self, sectionName):
        if not self.hasSection(sectionName):
            found = False
            for name, cls in self._sectionMap.iteritems():
                if sectionName == name or sectionName.startswith(name + ':'):
                    found = True
                    self._addSection(sectionName, cls(self))
            if not found:
                raise ParseError('Unknown section "%s"' % sectionName)
        self._sectionName = sectionName
        return self._sections[sectionName]

    def setPins(self, scmPins):
        self.scmPins = scmPins

    def getMacros(self):
        if self._macros is None:
            macros = Macros(self.macros)
            macros.update(self.override)
            macros['start_time'] = time.strftime('%Y%m%d_%H%M%S')
            macros['target_label'] = self.targetLabel % macros
            self._macros = macros
        return self._macros

    def getRepositories(self, macros=None):
        """
        Get a mapping of SCM repository aliases to the repository
        objects (which specify kind, hostname, path, and pinned
        revision).
        """

        if self.scmPins:
            # Someone already went to the trouble of determining what
            # we have (e.g. they "pinned" the repositories)
            return self.scmPins

        if not macros:
            macros = self.getMacros()

        out = {}
        for name, value in self.scm.iteritems():
            if ' ' not in value:
                raise ValueError("Invalid scm directive %r -- must take the "
                        "form 'scm <hg|git> <uri> [rev]" % (value,))
            kind, uri = value.split(' ', 1)
            name %= macros
            if ' ' in uri:
                uri, revision = uri.split(' ', 1)
                uri %= macros
                revision %= macros
            else:
                uri %= macros
                revision = None
            out[name] = (kind, uri, revision)

        return out

    def getTargetLabel(self):
        return Label(self.targetLabel % self.getMacros())

    @cfg.directive
    def hg(self, value):
        key, value = value.split(' ', 1)
        self.configLine('scm %s hg %s' % (key, value))
Exemplo n.º 13
0
 def toStrings(self, value, displayOptions):
     value = dict([ (str(x), y) for x, y in value.iteritems() ])
     return CfgDict.toStrings(self, value, displayOptions)
Exemplo n.º 14
0
class BuildConfiguration(conarycfg.ConaryConfiguration, FreezableConfigMixin):

    _cfg_bases = [RmakeBuildContext]

    buildTroveSpecs = CfgList(CfgTroveSpec)
    isolateTroves = (
        CfgBool, False, "Ignore the results of other "
        "troves in the same job when searching for build requirements.")
    resolveTroveTups = CfgList(CfgQuotedLineList(CfgTroveTuple))
    recurseGroups = (CfgInt, 0)
    prepOnly = (CfgBool, False)
    pluginDirs = (CfgPathList,
                  ['/usr/share/rmake/plugins', '~/.rmake/plugins.d'])
    usePlugin = CfgDict(CfgBool)
    usePlugins = (CfgBool, True)
    jobContext = CfgList(CfgInt)
    recursedGroupTroves = CfgList(CfgTroveTuple)
    reposName = (CfgString, None)
    prebuiltBinaries = CfgList(CfgTroveTuple)
    ignoreExternalRebuildDeps = (CfgBool, False)
    ignoreAllRebuildDeps = (CfgBool, False)
    primaryTroves = CfgList(CfgTroveTupleWithContext)

    # Here are options that are not visible from the command-line
    # and should not be displayed.  They are job-specific.  However,
    # they must be stored with the job, parsed with the job, etc.

    _cfg_hidden = [
        'buildTroveSpecs',
        'resolveTroveTups',
        'jobContext',
        'recurseGroups',
        'recursedGroupTroves',
        'prebuiltBinaries',
        'ignoreExternalRebuildDeps',
        'ignoreAllRebuildDeps',
        'primaryTroves',
        'reposName',
    ]

    _strictOptions = [
        'buildFlavor', 'buildLabel', 'cleanAfterCook', 'flavor',
        'installLabelPath', 'repositoryMap', 'root', 'user', 'name', 'contact',
        'signatureKey', 'dbPath', 'proxy', 'conaryProxy', 'lookaside',
        'entitlement', 'autoLoadRecipes', 'proxyMap'
    ]

    _dirsToCopy = [
        'archDirs', 'mirrorDirs', 'siteConfigPath', 'useDirs', 'componentDirs'
    ]
    _pathsToCopy = ['defaultMacros']
    _defaultSectionType = RmakeBuildContext

    def __init__(self,
                 readConfigFiles=False,
                 root='',
                 conaryConfig=None,
                 serverConfig=None,
                 ignoreErrors=False,
                 log=None,
                 strictMode=None):
        # we default the value of these items to whatever they
        # are set to on the local system's conaryrc.
        if log is None:
            log = logger.Logger('buildcfg')

        conarycfg.ConaryConfiguration.__init__(self, readConfigFiles=False)
        if hasattr(self, 'setIgnoreErrors'):
            self.setIgnoreErrors(ignoreErrors)
        if hasattr(self, 'addConfigOption'):
            # Conary < 2.5
            for info in RmakeBuildContext._getConfigOptions():
                if info[0] not in self:
                    self.addConfigOption(*info)
        if strictMode is not None:
            self.strictMode = strictMode
        if not hasattr(self, 'rmakeUrl'):
            self.rmakeUrl = None
        if not hasattr(self, 'clientCert'):
            self.clientCert = None

        if readConfigFiles:
            if os.path.exists(root + '/etc/rmake/clientrc'):
                log.warning(root + '/etc/rmake/clientrc should be renamed'
                            ' to /etc/rmake/rmakerc')
                self.read(root + '/etc/rmake/clientrc', exception=False)
            self.read(root + '/etc/rmake/rmakerc', exception=False)
            if os.environ.has_key("HOME"):
                self.read(root + os.environ["HOME"] + "/" + ".rmakerc",
                          exception=False)
            self.read('rmakerc', exception=False)

        if self.strictMode:
            self.enforceManagedPolicy = True
            self.copyInConary = False
            self.copyInConfig = False

        # these values are not set based on
        # config file values - we don't want to touch the system database,
        # and we don't want to use conary's logging mechanism.
        self.root = ':memory:'
        self.dbPath = ':memory:'
        self.logFile = []
        if hasattr(self, '_lowerCaseMap'):
            # Conary < 2.5
            for option in self._cfg_hidden:
                del self._lowerCaseMap[option.lower()]

        self.useConaryConfig(conaryConfig)
        if serverConfig:
            self.reposName = serverConfig.reposName
            self.repositoryMap.update(serverConfig.getRepositoryMap())
            self.user.extend(serverConfig.reposUser)

    def useConaryConfig(self, conaryConfig):
        def _shouldOverwrite(key, current, new):
            if key not in new:
                return False
            if (current.isDefault(key)
                    and current[key] == current.getDefaultValue(key)
                    and (not new.isDefault(key)
                         or new[key] != new.getDefaultValue(key))):
                return True
            return False

        if self.strictMode:
            if not conaryConfig:
                conaryConfig = conarycfg.ConaryConfiguration(False)
            for key in self.iterkeys():
                if key not in self._strictOptions and key in conaryConfig:
                    self.resetToDefault(key)

        if not conaryConfig:
            return

        # copy in conary config values that we haven't
        # overrided from the rmake config
        for key in self.iterkeys():
            if self.strictMode and key not in self._strictOptions:
                continue
            if _shouldOverwrite(key, self, conaryConfig):
                self[key] = conaryConfig[key]

        for sectionName in conaryConfig.iterSectionNames():
            conarySection = conaryConfig.getSection(sectionName)
            if not self.hasSection(sectionName):
                self._addSection(sectionName, self._defaultSectionType(self))
            mySection = self.getSection(sectionName)
            for key in mySection.iterkeys():
                if self.strictMode and key not in self._strictOptions:
                    continue
                if _shouldOverwrite(key, mySection, conarySection):
                    mySection[key] = conarySection[key]

        if self.strictMode:
            self.enforceManagedPolicy = True
            self.copyInConary = False
            self.copyInConfig = False
        if not self.copyInConfig:
            for option in self._dirsToCopy + self._pathsToCopy:
                self.resetToDefault(option)

    def getServerUri(self):
        if self.rmakeUrl:
            return self.rmakeUrl
        return 'unix:///var/lib/rmake/socket'

    def limitToHosts(self, hosts):
        if isinstance(hosts, str):
            hosts = [hosts]
        for host in hosts:
            if '@' in host or '=' in host:
                raise ParseError('Invalid host "%s"' % host)
            self.addMatchRule('=%s@' % host)

    def limitToLabels(self, labels):
        if isinstance(labels, str):
            labels = [labels]
        for label in labels:
            label = versions.Label(label)
            self.addMatchRule('=%s' % label)

    def addMatchRule(self, matchRule):
        self.configLine('matchTroveRule %s' % matchRule)

    def clearMatchRules(self):
        self.matchTroveRule = []
        for section in self.iterSections():
            section.matchTroveRule = []

    def getTargetLabel(self, versionOrLabel):
        if isinstance(versionOrLabel, versions.Label):
            cookLabel = versionOrLabel
        elif isinstance(versionOrLabel, versions.Branch):
            cookLabel = versionOrLabel.label()
        else:
            cookLabel = versionOrLabel.trailingLabel()

        targetLabel = self.targetLabel
        if targetLabel:
            # we treat NONE in the label as being a special target,
            # if your targetLabel is localhost@rpl:NONE, we build
            # onto localhost@rpl:<branch> where branch is the branch
            # of the source version.

            needNewLabel = False
            if targetLabel.getHost().lower() == 'none':
                needNewLabel = True
                host = self.reposName
            else:
                host = targetLabel.getHost()

            if targetLabel.getNamespace().lower() == 'none':
                needNewLabel = True
                nameSpace = cookLabel.getNamespace()
            else:
                nameSpace = targetLabel.getNamespace()

            if targetLabel.branch.lower() == 'none':
                needNewLabel = True
                branch = cookLabel.branch
            else:
                branch = targetLabel.branch

            if needNewLabel:
                targetLabel = '%s@%s:%s' % (host, nameSpace, branch)
                targetLabel = versions.Label(targetLabel)
            return targetLabel
        else:
            return cookLabel

    def dropContexts(self):
        self._sections = {}

    def storeConaryCfg(self, out):
        conaryCfg = conarycfg.ConaryConfiguration(False)
        for key, value in self.iteritems():
            if self.isDefault(key):
                continue
            if key in conaryCfg:
                if key == 'macros':
                    # multi-line macros break conary config files (RMK-996)
                    continue
                if key == 'context':
                    # we're not writing out contexts!
                    continue
                conaryCfg[key] = value
        conaryCfg.store(out, includeDocs=False)

    def getMacros(self):
        # multi-line macros break conary config files, so provide
        # any macros separately (RMK-996)
        if 'macros' in self:
            macros = sorted(x for x in self.macros.iteritems())
            if macros:
                return '\n'.join('%s = %r' % x for x in macros) + '\n'
        return ''

    def _writeKey(self, out, cfgItem, value, options):
        if cfgItem.name in self._cfg_hidden:
            if not options.get('displayHidden', False):
                return
        conarycfg.ConaryConfiguration._writeKey(self, out, cfgItem,
                                                self[cfgItem.name], options)