Ejemplo n.º 1
0
    def _ensureDeclare(self, pkgroot, mprod, flavor, rootdir, productRoot, setups):

        flavor = self.eups.flavor

        prod = self.eups.findProduct(mprod.product, mprod.version, flavor=flavor)
        if prod:
            return

        repos = self.repos[pkgroot]

        if rootdir and not os.path.exists(rootdir):
            raise EupsException("%s %s installation not found at %s" % (mprod.product, mprod.version, rootdir))

        # make sure we have a table file if we need it
        
        if not rootdir:
            rootdir = "none"
            
        if rootdir == "none":
            rootdir = "/dev/null"
            upsdir = None
            tablefile = mprod.tablefile
        else:
            upsdir = os.path.join(rootdir, "ups")
            tablefile = os.path.join(upsdir, "%s.table" % mprod.product)


        # Expand that tablefile (adding an exact block)
        def expandTableFile(tablefile):
            cmd = "\n".join(setups + ["eups expandtable -i --force %s" % tablefile])
            try:
                server.system(cmd)
            except OSError, e:
                print >> self.log, e
Ejemplo n.º 2
0
    def __init__(self, pkgroots, options=None, eupsenv=None,
                 installFlavor=None, distribClasses=None, override=None, allowEmptyPkgroot=False,
                 verbosity=None, log=sys.stderr):
                 
        """
        @param pkgroots   the base URLs for the distribution repositories.  This
                            can either be a list or a pipe-delimited ("|") 
                            string.  
        @param options    a dictionary of named options that are used to fine-
                            tune the behavior of the repositories.  These are
                            passed onto the constructors for the underlying 
                            Reposistory classes.
        @param eupsenv    an instance of a Eups class containing the Eups
                            environment to assume
        @param installFlavor   the desired flavor any install requests
        @param distribClasses  a dictionary by name of the Distrib classes 
                            to support.  This will augmented by those specified
                            by a server.  
        @param override   a dictionary of server configuration parameters that
                            should override the configuration received from 
                            each server.
        @param allowEmptyPkgroot     we are creating a distribution, so it's OK for pkgroot to be empty
        @param verbosity  if > 0, print status messages; the higher the 
                            number, the more messages that are printed
                            (default is the value of eupsenv.verbose).
        @param log        the destination for status messages (default:
                            sys.stderr)
        """
        if isinstance(pkgroots, str):
            pkgroots = map(lambda p: p.strip(), pkgroots.split("|"))
        if not allowEmptyPkgroot and len(pkgroots) == 0:
            raise EupsException("No package servers to query; set -r or $EUPS_PKGROOT")

        # the Eups environment
        self.eups = eupsenv
        if not self.eups:
            self.eups = Eups()

        self.verbose = verbosity
        if self.verbose is None:
            self.verbose = self.eups.verbose
        self.log = log
        if self.log is None:
            self.log = sys.stdout

        if not distribClasses:
            distribClasses = {}

        # the list of repository base URLs
        self.pkgroots = []

        # a lookup of Repository instances by its base URL
        self.repos = {}

        # the preferred installation flavor
        self.flavor = installFlavor
        if not self.flavor:
            self.flavor = self.eups.flavor

        df = DistribFactory(self.eups)
        for name in distribClasses.keys():
            # note: this will override the server's recommendation
            # if we want change this, use:
            #   if not df.supportsName(name):
            #       df.register(distribClasses[name], name)
            # 
            df.register(distribClasses[name], name)

        for pkgroot in pkgroots:
#            if pkgroot == None:
#                ds = None
#            else:
#                ds = ServerConf.makeServer(pkgroot, eupsenv=eupsenv, 
#                                           override=override,
#                                           verbosity=self.eups.verbose)
#
            try:
                dist = Repository(self.eups, pkgroot, options=options, 
                                  flavor=installFlavor, distFactory=df, 
                                  verbosity=self.eups.verbose)

                self.pkgroots += [pkgroot]
                self.repos[pkgroot] = dist

            except ImportError, e:
                msg =  "Unable to use server %s: \"%s\"" % (pkgroot, e)
                if self.eups.force:
                    print >> self.log, msg + "; continuing"
                else:
                    raise RuntimeError(msg + ". Remove server from PKGROOT or use force")
Ejemplo n.º 3
0
                        repos.distServer.getFileForProduct(mprod.tablefile, 
                                                           mprod.product, 
                                                           mprod.version, 
                                                           flavor)
                    expandTableFile(tablefile)
                    tablefile = open(tablefile, "r")
                else:
                    if upsdir and not os.path.exists(upsdir):
                        os.makedirs(upsdir)
                    tablefile = \
                              repos.distServer.getFileForProduct(mprod.tablefile,
                                                                 mprod.product, 
                                                                 mprod.version, flavor,
                                                                 filename=tablefile)
                    if not os.path.exists(tablefile):
                        raise EupsException("Failed to find table file %s" % tablefile)
                    expandTableFile(tablefile)

        self.eups.declare(mprod.product, mprod.version, rootdir, 
                          eupsPathDir=productRoot, tablefile=tablefile)

    def getInstallRoot(self):
        """return the first directory in the eups path that the user can install 
        stuff into
        """
        return findInstallableRoot(self.eups)

    def getBuildDirFor(self, productRoot, product, version, options=None, 
                       flavor=None):
        """return a recommended directory to use to build a given product.
        In this implementation, the returned path will usually be of the form
Ejemplo n.º 4
0
    def install(self, product, version=None, updateTags=True, alsoTag=None,
                depends=DEPS_ALL, noclean=False, noeups=False, options=None,
                manifest=None, searchDep=None):
        """
        Install a product and all its dependencies.
        @param product     the name of the product to install
        @param version     the desired version of the product.  This can either 
                            be a version string or an instance of Tag.  If 
                            not provided (or None) the most preferred version 
                            will be installed.  
        @param updateTags  when True (default), server-assigned tags will 
                            be updated for this product and all its dependcies
                            to match those recommended on the server (even if
                            a product is already installed); if False, tags 
                            will not be changed.
        @param alsoTag     A list of tags to assign to all installed products
                            (in addition to server tags).  This can either be
                            a space-delimited list, a list of string names,
                            a Tag instance, or a list of Tag instances.
        @param depends     If DEPS_ALL, product and dependencies will be installed
                              DEPS_NONE, dependencies will not be installed
                              DEPS_ONLY, only dependencies will be installed,
                              usefull for developement purpose (before a 
                              setup -r .)
        @param noclean     If False (default), the build directory will get
                            cleaned up after a successful install.  A True
                            value prevents this.
        @param noeups      if False (default), needed products that are already
                            installed will be skipped over.  If True, an 
                            attempt is made to install them anyway.  This 
                            allows a product to be installed in the target
                            install stack even if it is available in another
                            stack managed by EUPS.  Note, however, that if a
                            needed product is already installed into the target
                            stack, the installation may fail.  Use with caution.
        @param options     a dictionary of named options that are used to fine-
                            tune the behavior of this Distrib class.  See 
                            discussion above for a description of the options
                            supported by this implementation; sub-classes may
                            support different ones.
        @param manifest    use this manifest (a local file) as the manifest for 
                            the requested product instead of downloading manifest
                            from the server.
        @param searchDep   if False, install will be prevented from recursively
                            looking for dependencies of dependencies listed in
                            manifests.  In this case, it is assumed that a 
                            manifest contains all necessary dependencies.  If 
                            True, the distribution identifiers in the manifest
                            file are ignored and the dependencies will always
                            be recursively searched for.  If None,
                            the choice to recurse is left up to the server 
                            where the manifest comes from (which usually 
                            defaults to False).
        """
        if alsoTag is not None:
            if isinstance(alsoTag, str):
                alsoTag = [self.eups.tags.getTag(t) for t in alsoTag.split()]
            elif isinstance(alsoTag, Tag):
                alsoTag = [alsoTag]

        pkg = self.findPackage(product, version)
        if not pkg:
            raise ProductNotFound(product, version,
                    msg="Product %s %s not found in any package repository" % 
                        (product, version))

        (product, version, flavor, pkgroot) = pkg
        productRoot = self.getInstallRoot()
        if productRoot is None:
            raise EupsException("Unable to find writable place to install in EUPS_PATH")

        if manifest is not None:
            if not manifest or os.path.exists(manifest):
                raise EupsException("%s: user-provided manifest not found" %
                                    manifest)
            man = Manifest.fromFile(manifest, self.eups, 
                                    verbosity=self.eups.verbose-1)
        else:
            man = self.repos[pkgroot].getManifest(product, version, flavor)

        man.remapEntries()              # allow user to rewrite entries in the manifest
        if product not in [p.product for p in man.getProducts()]:
            raise EupsException("You asked to install %s %s but it is not in the manifest\nCheck manifest.remap (see \"eups startup\") and/or increase the verbosity" % (product, version))

        self._msgs = {}
        self._recursiveInstall(0, man, product, version, flavor, pkgroot, 
                               productRoot, updateTags, alsoTag, options, 
                               depends, noclean, noeups)
Ejemplo n.º 5
0
    def _ensureDeclare(self, pkgroot, mprod, flavor, rootdir, productRoot, setups):
        r"""Make sure that the product is installed

        \param pkgroot  Source of package being installed
        \param mprod    A eups.distrib.server.Dependency (e.g. with product name and version)
        \param flavor   Installation flavor
        \param rootdir
        \param productRoot  Element of EUPS_PATH that we are installing into
        \param setups       Products that are already setup, used in expanding tablefile
                            May be None to skip expanding tablefile
        """

        flavor = self.eups.flavor

        prod = self.eups.findProduct(mprod.product, mprod.version, flavor=flavor)
        if prod:
            return

        repos = self.repos[pkgroot]

        if rootdir and not os.path.exists(rootdir):
            raise EupsException("%s %s installation not found at %s" % (mprod.product, mprod.version, rootdir))

        # make sure we have a table file if we need it

        if not rootdir:
            rootdir = "none"

        if rootdir == "none":
            rootdir = "/dev/null"
            upsdir = None
            tablefile = mprod.tablefile
        else:
            upsdir = os.path.join(rootdir, "ups")
            tablefile = os.path.join(upsdir, "%s.table" % mprod.product)


        # Expand that tablefile (adding an exact block)
        def expandTableFile(tablefile):
            cmd = "\n".join(setups + ["eups expandtable -i --force %s" % tablefile])
            try:
                server.system(cmd)
            except OSError as e:
                print(e, file=self.log)


        if not os.path.exists(tablefile):
            if mprod.tablefile == "none":
                tablefile = "none"
            else:
                # retrieve the table file and install it
                if rootdir == "/dev/null":
                    tablefile = \
                        repos.distServer.getFileForProduct(mprod.tablefile,
                                                           mprod.product,
                                                           mprod.version,
                                                           flavor)
                    if setups is not None:
                        expandTableFile(tablefile)
                    tablefile = open(tablefile, "r")
                else:
                    if upsdir and not os.path.exists(upsdir):
                        os.makedirs(upsdir)
                    tablefile = \
                              repos.distServer.getFileForProduct(mprod.tablefile,
                                                                 mprod.product,
                                                                 mprod.version, flavor,
                                                                 filename=tablefile)
                    if not os.path.exists(tablefile):
                        raise EupsException("Failed to find table file %s" % tablefile)
                    if setups is not None:
                        expandTableFile(tablefile)

        self.eups.declare(mprod.product, mprod.version, rootdir,
                          eupsPathDir=productRoot, tablefile=tablefile)