def downloadPackages(self, opts): toDownload = [] packages = self.cmds for pkg in packages: toActOn = [] if not pkg or pkg[0] != '@': pkgnames = [pkg] else: group_string = pkg[1:] pkgnames = set() for grp in self.comps.return_groups(group_string): if 'mandatory' in self.conf.group_package_types: pkgnames.update(grp.mandatory_packages) if 'default' in self.conf.group_package_types: pkgnames.update(grp.default_packages) if 'optional' in self.conf.group_package_types: pkgnames.update(grp.optional_packages) if self.conf.enable_group_conditionals: for condreq, cond in grp.conditional_packages.iteritems( ): if self.isPackageInstalled(cond): pkgnames.add(condreq) if not pkgnames: self.logger.error('No packages for group %s' % group_string) continue pos = self.pkgSack.returnPackages(patterns=pkgnames) exactmatch, matched, unmatched = parsePackages(pos, pkgnames) installable = (exactmatch + matched) if not installable: try: installable = self.returnPackagesByDep(pkg) installable = yum.misc.unique(installable) except yum.Errors.YumBaseError, msg: self.logger.error(exception2msg(msg)) continue if not installable: # doing one at a time, apart from groups self.logger.error('No Match for argument %s' % pkg) continue for newpkg in installable: toActOn.extend(_best_convert_pkg2srcpkgs(self, opts, newpkg)) if toActOn: pkgGroups = self._groupPackages(toActOn) for group in pkgGroups: pkgs = pkgGroups[group] if opts.source: toDownload.extend( self.bestPackagesFromList(pkgs, 'src')) elif opts.archlist: for arch in opts.archlist.split(','): toDownload.extend( self.bestPackagesFromList(pkgs, arch)) else: toDownload.extend(self.bestPackagesFromList(pkgs))
def downloadPackages(self,opts): toDownload = [] packages = self.cmds for pkg in packages: toActOn = [] if not pkg or pkg[0] != '@': pkgnames = [pkg] else: group_string = pkg[1:] pkgnames = set() for grp in self.comps.return_groups(group_string): if 'mandatory' in self.conf.group_package_types: pkgnames.update(grp.mandatory_packages) if 'default' in self.conf.group_package_types: pkgnames.update(grp.default_packages) if 'optional' in self.conf.group_package_types: pkgnames.update(grp.optional_packages) if self.conf.enable_group_conditionals: for condreq, cond in grp.conditional_packages.iteritems(): if self.isPackageInstalled(cond): pkgnames.add(condreq) if not pkgnames: self.logger.error('No packages for group %s' % group_string) continue pos = self.pkgSack.returnPackages(patterns=pkgnames) exactmatch, matched, unmatched = parsePackages(pos, pkgnames) installable = (exactmatch + matched) if not installable: try: installable = self.returnPackagesByDep(pkg) installable = yum.misc.unique(installable) except yum.Errors.YumBaseError, msg: self.logger.error(str(msg)) continue if not installable: # doing one at a time, apart from groups self.logger.error('No Match for argument %s' % pkg) continue for newpkg in installable: toActOn.extend(_best_convert_pkg2srcpkgs(self, opts, newpkg)) if toActOn: pkgGroups = self._groupPackages(toActOn) for group in pkgGroups: pkgs = pkgGroups[group] if opts.source: toDownload.extend(self.bestPackagesFromList(pkgs, 'src')) elif opts.archlist: for arch in opts.archlist.split(','): toDownload.extend(self.bestPackagesFromList(pkgs, arch)) else: toDownload.extend(self.bestPackagesFromList(pkgs))
def getDependencylist(self): """ Get dependency list and suggested packages for package names provided. The dependency lookup is only one level in this case. The package name format could be any of the following: name, name.arch, name-ver-rel.arch, name-ver, name-ver-rel, epoch:name-ver-rel.arch, name-epoch:ver-rel.arch """ ematch, match, unmatch = parsePackages(self._repostore.pkgSack, self.pkgs) pkgs = [] for po in ematch + match: pkgs.append(po) results = self.__locateDeps(pkgs) return results
def getDependencylist(self): """ Get dependency list and suggested packages for package names provided. The dependency lookup is only one level in this case. The package name format could be any of the following: name, name.arch, name-ver-rel.arch, name-ver, name-ver-rel, epoch:name-ver-rel.arch, name-epoch:ver-rel.arch """ ematch, match, _unmatch = parsePackages(self._repostore.pkgSack, self.pkgs) pkgs = [] for po in ematch + match: pkgs.append(po) results = self.__locateDeps(pkgs) return results
def posttrans_hook(conduit): # we have provides/requires for everything # we do not have filelists for erasures # we have to fetch filelists for the package object for installs/updates action_dir = conduit.confString('main','actiondir','/etc/yum/post-actions/') action_tuples = parse_actions(action_dir, conduit) commands_to_run = {} ts = conduit.getTsInfo() rpmdb = conduit.getRpmDB() all = ts.getMembers() removes = ts.getMembersWithState(output_states=TS_REMOVE_STATES) installs = ts.getMembersWithState(output_states=TS_INSTALL_STATES) updates = ts.getMembersWithState(output_states=[TS_UPDATE, TS_OBSOLETING]) for (a_k, a_s, a_c) in action_tuples: #print 'if %s in state %s the run %s' %( a_k, a_s, a_c) if a_s == 'update': pkgset = updates elif a_s == 'install': pkgset = installs elif a_s == 'remove': pkgset = removes elif a_s == 'any': pkgset = all else: # no idea what this is skip it conduit.error(2,'whaa? %s' % a_s) continue if a_k.startswith('/'): if yum.misc.re_glob(a_k): restring = fnmatch.translate(a_k) c_string = re.compile(restring) for txmbr in pkgset: matched = False thispo = txmbr.po if txmbr.output_state in TS_INSTALL_STATES: # thispo is AvailablePackage; filelist access could trigger download # of the filelist. Since it's installed now, use rpmdb data instead. thispo = _get_installed_po(rpmdb, txmbr.pkgtup) if not yum.misc.re_glob(a_k): if a_k in thispo.filelist + thispo.dirlist + thispo.ghostlist: thiscommand = _convert_vars(txmbr, a_c) commands_to_run[thiscommand] = 1 matched = True else: for name in thispo.filelist + thispo.dirlist + thispo.ghostlist: if c_string.match(name): thiscommand = _convert_vars(txmbr, a_c) commands_to_run[thiscommand] = 1 matched = True break if matched: break continue if a_k.find('/') == -1: # pkgspec pkgs = [ txmbr.po for txmbr in pkgset ] e,m,u = parsePackages(pkgs, [a_k]) if not u: for pkg in e+m: for txmbr in ts.getMembers(pkgtup=pkg.pkgtup): thiscommand = _convert_vars(txmbr, a_c) commands_to_run[thiscommand] = 1 continue for comm in commands_to_run.keys(): try: args = shlex.split(comm) except ValueError, e: conduit.error(2,"command was not parseable: %s" % comm) continue #try conduit.info(2,'Running post transaction command: %s' % comm) p = os.system(comm)
# enable the ones we like for repo in myrepos: repo.enable() my._getSacks(archlist=archlist, thisrepo=repo.id) my.doRepoSetup() my._getSacks(archlist=archlist) unprocessed_pkgs = {} final_pkgs = {} pkg_list = [] avail = my.pkgSack.returnPackages() for item in user_pkg_list: exactmatch, matched, unmatched = parsePackages(avail, [item]) pkg_list.extend(exactmatch) pkg_list.extend(matched) if opts.newest: this_sack = ListPackageSack() this_sack.addList(pkg_list) pkg_list = this_sack.returnNewestByNameArch() del this_sack if len(pkg_list) == 0: print >> sys.stderr, "Nothing found to download matching packages specified" sys.exit(1) for po in pkg_list: unprocessed_pkgs[po.pkgtup] = po
my.logger.info("Added %s repo from %s" % (repoid, repopath)) try: my.doRepoSetup() my._getSacks(archlist=archlist) except yum.Errors.RepoError, e: my.logger.error(e) sys.exit(1) unprocessed_pkgs = {} final_pkgs = {} pkg_list = [] avail = my.pkgSack.returnPackages() for item in user_pkg_list: exactmatch, matched, unmatched = parsePackages(avail, [item]) pkg_list.extend(exactmatch) pkg_list.extend(matched) if opts.newest: this_sack = ListPackageSack() this_sack.addList(pkg_list) pkg_list = this_sack.returnNewestByNameArch() del this_sack if len(pkg_list) == 0: print >> sys.stderr, "Nothing found to download matching packages specified" sys.exit(1) for po in pkg_list: unprocessed_pkgs[po.pkgtup] = po
def posttrans_hook(conduit): # we have provides/requires for everything # we do not have filelists for erasures # we have to fetch filelists for the package object for installs/updates action_dir = conduit.confString('main', 'actiondir', '/etc/yum/post-actions/') action_tuples = parse_actions(action_dir, conduit) commands_to_run = {} ts = conduit.getTsInfo() rpmdb = conduit.getRpmDB() all = ts.getMembers() removes = ts.getMembersWithState(output_states=TS_REMOVE_STATES) installs = ts.getMembersWithState(output_states=TS_INSTALL_STATES) updates = ts.getMembersWithState(output_states=[TS_UPDATE, TS_OBSOLETING]) for (a_k, a_s, a_c) in action_tuples: #print 'if %s in state %s the run %s' %( a_k, a_s, a_c) if a_s == 'update': pkgset = updates elif a_s == 'install': pkgset = installs elif a_s == 'remove': pkgset = removes elif a_s == 'any': pkgset = all else: # no idea what this is skip it conduit.error(2, 'whaa? %s' % a_s) continue if a_k.startswith('/'): if yum.misc.re_glob(a_k): restring = fnmatch.translate(a_k) c_string = re.compile(restring) for txmbr in pkgset: matched = False thispo = txmbr.po if txmbr.output_state in TS_INSTALL_STATES: # thispo is AvailablePackage; filelist access could trigger download # of the filelist. Since it's installed now, use rpmdb data instead. thispo = _get_installed_po(rpmdb, txmbr.pkgtup) if not yum.misc.re_glob(a_k): if a_k in thispo.filelist + thispo.dirlist + thispo.ghostlist: thiscommand = _convert_vars(txmbr, a_c) commands_to_run[thiscommand] = 1 matched = True else: for name in thispo.filelist + thispo.dirlist + thispo.ghostlist: if c_string.match(name): thiscommand = _convert_vars(txmbr, a_c) commands_to_run[thiscommand] = 1 matched = True break if matched: break continue if a_k.find('/') == -1: # pkgspec pkgs = [txmbr.po for txmbr in pkgset] e, m, u = parsePackages(pkgs, [a_k]) if not u: for pkg in e + m: for txmbr in ts.getMembers(pkgtup=pkg.pkgtup): thiscommand = _convert_vars(txmbr, a_c) commands_to_run[thiscommand] = 1 continue for comm in commands_to_run.keys(): try: args = shlex.split(comm) except ValueError, e: conduit.error(2, "command was not parseable: %s" % comm) continue #try conduit.info(2, 'Running post transaction command: %s' % comm) p = os.system(comm)