Exemple #1
0
    def isWritable(self):
        """
        return true if new packages, tag assignments, etc. can be added to 
        this repository.

        This implementation returns True only if the repository is accessible
        via local disk.
        """
        return LocalTransporter.canHandle(self.pkgroot) and isDbWritable(self.pkgroot)
Exemple #2
0
    def isWritable(self):
        """
        return true if new packages, tag assignments, etc. can be added to
        this repository.

        This implementation returns True only if the repository is accessible
        via local disk.
        """
        return (LocalTransporter.canHandle(self.pkgroot) and
                isDbWritable(self.pkgroot))
Exemple #3
0
    def clean(self, product, version, flavor=None, options=None, 
              installDir=None, uninstall=False):
        """clean up the remaining remants of the failed installation of 
        a distribution.  
        @param product      the name of the product to clean up after
        @param version      the version of the product
        @param flavor       the flavor for the product to assume.  This affects
                               where we look for partially installed packages.
                               None (the default) means the default flavor.
        @param options      extra options for fine-tuning the distrib-specific
                               cleaning as a dictionary
        @param installDir   the directory where the product should be installed
                               If None, a default location based on the above
                               parameters will be assumed.
        @parma uninstall    if True, run the equivalent of "eups remove" for 
                               this package. default: False.
        """
        handlePartialInstalls = True
        productRoot = self.getInstallRoot()
        if not flavor:  flavor = self.eups.flavor

        # check the build directory
        buildDir = self.getBuildDirFor(productRoot, product, version, 
                                       options, flavor)
        if self.verbose > 1 or (self.verbose > 0 and not os.path.exists(buildDir)):
            msg = "Looking for build directory to cleanup: %s" % buildDir
            if not os.path.exists(buildDir):
                msg += "; not found"

            print >> self.log, msg

        if os.path.exists(buildDir):
            distidfile = os.path.join(buildDir, "distID.txt")
            if os.path.isfile(distidfile):
                (distId, pkgroot) = self._readDistIDFile(distidfile)
                if distId and pkgroot:
                    if self.verbose > 1:
                        print >> self.log, "Attempting distClean for", \
                            "build directory via ", distId
                    self.distribClean(product, version, pkgroot, distId, flavor)

            self.cleanBuildDirFor(productRoot, product, version, options, 
                                  flavor=flavor)

        # now look for a partially installed (but not yet eups-declared) package
        if handlePartialInstalls:
            if not installDir:
                installDir = os.path.join(productRoot, flavor, product, version)

            if self.verbose > 1:
                print >> self.log, "Looking for a partially installed package:",\
                    product, version

            if os.path.isdir(installDir):
                distidfile = os.path.join(installDir, "ups", "distID.txt")
                if os.path.isfile(distidfile):
                    (pkgroot, distId) = self._readDistIDFile(distidfile)
                    if distId:
                        if self.verbose > 1:
                            print >> self.log, "Attempting distClean for", \
                                "installation directory via ", distId
                        self.distribClean(product,version,pkgroot,distId,flavor)
                
                # make sure this directory is not declared for any product
                installDirs = map(lambda x: x.dir, self.eups.findProducts())
                if installDir not in installDirs:
                  if not installDir.startswith(productRoot) and \
                     not self.eups.force:
                      if self.verbose >= 0:
                          print >> self.log, "Too scared to delete product dir",\
                              "that's not under the product root:", installDir

                  else:
                    if self.verbose > 0:
                        print >> self.log, "Removing installation dir:", \
                            installDir
                    if utils.isDbWritable(installDir):
                        try:
                            server.system("/bin/rm -rf %s" % installDir)
                        except OSError, e:
                            print >> self.log, "Error removing %s; Continuing" % (installDir)

                    elif self.verbose >= 0:
                        print >> self.log, "No permission on install dir %s" % (installDir)