示例#1
0
    def _install_actions(self, eggs, mode, force, forceall):
        if not forceall:
            # remove already installed eggs from egg list
            rm = lambda eggs: [e for e in eggs if self.find(e) is None]
            if force:
                eggs = rm(eggs[:-1]) + [eggs[-1]]
            else:
                eggs = rm(eggs)

        res = []
        for egg in eggs:
            res.append(('fetch_%d' % bool(forceall or force), egg))

        if not self.hook:
            # remove packages with the same name (from first egg collection
            # only, in reverse install order)
            for egg in reversed(eggs):
                name = split_eggname(egg)[0].lower()
                index = dict(self.ec.collections[0].query(name=name))
                assert len(index) < 2
                if len(index) == 1:
                    res.append(('remove', index.keys()[0]))
        for egg in eggs:
            res.append(('install', egg))
        return res
示例#2
0
 def calculate_all_patches():
     egg_names = [fn for fn in os.listdir(eggs_dir) if is_valid_eggname(fn)]
     names = set(split_eggname(egg_name)[0] for egg_name in egg_names)
     for name in sorted(names, key=string.lower):
         versions = []
         for egg_name in egg_names:
             n, v, b = split_eggname(egg_name)
             if n != name:
                 continue
             versions.append((v, b))
         versions.sort(key=(lambda vb: (comparable_version(vb[0]), vb[1])))
         versions = ['%s-%d' % vb for vb in versions]
         lv = len(versions)
         #print name, lv, versions
         for i in xrange(0, lv):
             for j in xrange(i + 1, lv):
                 yield '%s-%s--%s.zdiff' % (name, versions[i], versions[j])
示例#3
0
 def calculate_all_patches():
     egg_names = [fn for fn in os.listdir(eggs_dir)
                  if is_valid_eggname(fn)]
     names = set(split_eggname(egg_name)[0]
                 for egg_name in egg_names)
     for name in sorted(names, key=string.lower):
         versions = []
         for egg_name in egg_names:
             n, v, b = split_eggname(egg_name)
             if n != name:
                 continue
             versions.append((v, b))
         versions.sort(key=(lambda vb: (comparable_version(vb[0]), vb[1])))
         versions = ['%s-%d' % vb for vb in versions]
         lv = len(versions)
         #print name, lv, versions
         for i in xrange(0, lv):
             for j in xrange(i + 1, lv):
                 yield '%s-%s--%s.zdiff' % (name, versions[i], versions[j])
示例#4
0
 def find(self, egg):
     n, v, b = split_eggname(egg)
     if self.hook:
         return info_from_metadir(join(self.pkgs_dir,
                          '%s-%s-%d' % (n.lower(), v, b), 'EGG-INFO'))
     else:
         info = info_from_metadir(join(self.prefix, 'EGG-INFO', n.lower()))
         if info and info['key'] == egg:
             return info
         else:
             return None
示例#5
0
 def find(self, egg):
     try:
         n, v, b = split_eggname(egg)
     except AssertionError:
         return None
     if self.hook:
         path = join(self.pkgs_dir,
                     '%s-%s-%d' % (n.lower(), v, b), 'EGG-INFO')
     else:
         path = join(self.prefix, 'EGG-INFO', n.lower())
     info = info_from_metadir(path)
     if info and info['key'] == egg:
         return info
     else:
         return None
示例#6
0
 def find(self, egg):
     try:
         n, v, b = split_eggname(egg)
     except AssertionError:
         return None
     if self.hook:
         path = join(self.pkgs_dir, '%s-%s-%d' % (n.lower(), v, b),
                     'EGG-INFO')
     else:
         path = join(self.prefix, 'EGG-INFO', n.lower())
     info = info_from_metadir(path)
     if info and info['key'] == egg:
         return info
     else:
         return None
    def _filter_installed_eggs(self, eggs):
        """ Filter out already installed eggs from the given egg list.

        Note that only visible eggs are filtered.
        For example, if in multiple prefixes, a lower prefix has an egg
        which is overridden by a different version in a higher prefix,
        then only the top-most egg is considered and the egg in lower prefix
        is not considered.
        """
        filtered_eggs = []
        for egg in eggs:
            for installed in self.ec.query(name=split_eggname(egg)[0].lower()):
                if installed[0] == egg:
                    break
            else:
                filtered_eggs.append(egg)
        return filtered_eggs
    def _install_actions_enstaller(self, installed_version=None):
        # installed_version is only useful for testing
        if installed_version is None:
            installed_version = enstaller.__version__

        mode = 'recur'
        self._connect()
        req = req_from_anything("enstaller")
        eggs = Resolve(self.remote, self.verbose).install_sequence(req, mode)
        if eggs is None:
            raise EnpkgError("No egg found for requirement '%s'." % req)
        elif not len(eggs) == 1:
            raise EnpkgError("No egg found to update enstaller, aborting...")
        else:
            name, version, build = split_eggname(eggs[0])
            if version == installed_version:
                return []
            else:
                return self._install_actions(eggs, mode, False, False)
示例#9
0
    def install_actions(self, arg, mode="recur", force=False, forceall=False):
        """
        Create a list of actions which are required for installing, which
        includes updating, a package (without actually doing anything).

        The first argument may be any of:
          * the KVS key, i.e. the egg filename
          * a requirement object (enstaller.resolve.Req)
          * the requirement as a string
        """
        req = req_from_anything(arg)
        # resolve the list of eggs that need to be installed
        self._connect()
        eggs = Resolve(self.remote, self.verbose).install_sequence(req, mode)
        if eggs is None:
            raise EnpkgError("No egg found for requirement '%s'." % req)

        if not forceall:
            # remove already installed eggs from egg list
            rm = lambda eggs: [e for e in eggs if self.find(e) is None]
            if force:
                eggs = rm(eggs[:-1]) + [eggs[-1]]
            else:
                eggs = rm(eggs)

        res = []
        for egg in eggs:
            res.append(("fetch_%d" % bool(forceall or force), egg))

        if not self.hook:
            # remove packages with the same name (from first egg collection
            # only, in reverse install order)
            for egg in reversed(eggs):
                name = split_eggname(egg)[0].lower()
                index = dict(self.ec.collections[0].query(name=name))
                assert len(index) < 2
                if len(index) == 1:
                    res.append(("remove", index.keys()[0]))
        for egg in eggs:
            res.append(("install", egg))
        return res
示例#10
0
    def install_actions(self, arg, mode='recur', force=False, forceall=False):
        """
        Create a list of actions which are required for installing, which
        includes updating, a package (without actually doing anything).

        The first argument may be any of:
          * the KVS key, i.e. the egg filename
          * a requirement object (enstaller.resolve.Req)
          * the requirement as a string
        """
        req = req_from_anything(arg)
        # resolve the list of eggs that need to be installed
        self._connect()
        eggs = Resolve(self.remote, self.verbose).install_sequence(req, mode)
        if eggs is None:
            raise EnpkgError("No egg found for requirement '%s'." % req)

        if not forceall:
            # remove already installed eggs from egg list
            rm = lambda eggs: [e for e in eggs if self.find(e) is None]
            if force:
                eggs = rm(eggs[:-1]) + [eggs[-1]]
            else:
                eggs = rm(eggs)

        res = []
        for egg in eggs:
            res.append(('fetch_%d' % bool(forceall or force), egg))

        if not self.hook:
            # remove packages with the same name (from first egg collection
            # only, in reverse install order)
            for egg in reversed(eggs):
                name = split_eggname(egg)[0].lower()
                index = dict(self.ec.collections[0].query(name=name))
                assert len(index) < 2
                if len(index) == 1:
                    res.append(('remove', index.keys()[0]))
        for egg in eggs:
            res.append(('install', egg))
        return res
def req_from_anything(arg):
    if isinstance(arg, Req):
        return arg
    if is_valid_eggname(arg):
        return Req('%s %s-%d' % split_eggname(arg))
    return Req(arg)
示例#12
0
def name_egg(egg):
    return split_eggname(egg)[0]
示例#13
0
文件: main.py 项目: bgrant/enstaller
def name_egg(egg):
    return split_eggname(egg)[0]
示例#14
0
def name_egg(egg):
    n, v, b = split_eggname(egg)
    return n.lower()
示例#15
0
def req_from_anything(arg):
    if isinstance(arg, Req):
        return arg
    if is_valid_eggname(arg):
        return Req('%s %s-%d' % split_eggname(arg))
    return Req(arg)