def execute(self, options_dict, non_option_args): if len(non_option_args) < 1 or (options_dict.has_key('uninstalled-only') and options_dict.has_key('installed-only')): self.usage() return False table_rows = [] yum = self.yum() dtype = self.dep_type(); plist = [] unmatched1 = None unmatched2 = None if not options_dict.has_key('uninstalled-only'): exactmatches, matches, unmatched1 = self.find_packages (non_option_args, installed=True) plist = exactmatches + matches if not options_dict.has_key('installed-only'): exactmatches, matches, unmatched2 = self.find_packages (non_option_args, installed=False) plist += exactmatches plist += matches if (unmatched1 is None or len(unmatched1) > 0) and (unmatched2 is None or len(unmatched2)) > 0: if unmatched1 != None: arg = unmatched1[0] else: arg = unmatched2[0] rucktalk.error("Could not find package '%s'" % arg) return False for p in plist: rucktalk.message("--- %s ---" % ruckformat.package_to_str(p)) deps = p.returnPrco(dtype) if len(deps) == 0: rucktalk.message("\nNo %s found\n" % dtype) else: for dep in deps: #FIXME: piece of crap prcoPrintable sometimes chokes try: rucktalk.message(p.prcoPrintable(dep)) except: pass rucktalk.message('')
def start_transaction(self, dryrun=False, download_only=False): yum = self.yum() if not download_only: (rescode, resmsgs) = self.resolve_deps() if rescode != 2: for resmsg in resmsgs: rucktalk.error(resmsg) return False self.show_ts_packages() if self.tsInfo_is_empty(yum.tsInfo): rucktalk.warning("Nothing to do.") return False downloadpkgs = self.get_pkgs_to_download() if len(downloadpkgs) > 0: total_size = 0 for p in downloadpkgs: try: size = int(p.size()) total_size += size except: pass if total_size > 0: rucktalk.message("\nTotal download size: %s\n" % (ruckformat.bytes_to_str(total_size))) if self.need_prompt(): answer = raw_input('\nProceed with transaction? (y/N) ') if len(answer) != 1 or answer[0] != 'y': rucktalk.message('Transaction Canceled') return False problems = yum.downloadPkgs(downloadpkgs) if len(problems.keys()) > 0: rucktalk.error("Error downloading packages:") for key in problems.keys(): for error in unique(problems[key]): rucktalk.message(" %s: %s" % (key, error)) return False if download_only: for pkg in downloadpkgs: dest = ruckformat.package_to_str(pkg, repo=False) + ".rpm" shutil.move(pkg.localpath, dest) rucktalk.message ("Downloaded '%s'" % dest) return True # Check GPG signatures if not self.gpgsigcheck(downloadpkgs): return False tsConf = {} for feature in ['diskspacecheck']: # more to come, I'm sure tsConf[feature] = getattr(yum.conf, feature) if dryrun: testcb = ruckyum.RPMInstallCallback(output=1) testcb.tsInfo = yum.tsInfo # clean out the ts b/c we have to give it new paths to the rpms del yum.ts yum.initActionTs() yum.populateTs(keepold=0) # sigh tserrors = yum.ts.test(testcb, conf=tsConf) del testcb if len(tserrors) > 0: errstring = '' for descr in tserrors: errstring += ' %s\n' % descr rucktalk.error(errstring) return False else: rucktalk.message('Running Transaction Test') testcb = ruckyum.RPMInstallCallback(output=0) testcb.tsInfo = yum.tsInfo # clean out the ts b/c we have to give it new paths to the rpms del yum.ts yum.initActionTs() # save our dsCallback out dscb = yum.dsCallback yum.dsCallback = None # dumb, dumb dumb dumb! yum.populateTs(keepold=0) # sigh tserrors = yum.ts.test(testcb, conf=tsConf) del testcb if len(tserrors) > 0: errstring = 'Transaction Check Error: ' for descr in tserrors: errstring += ' %s\n' % descr rucktalk.error(errstring) return False rucktalk.message('Transaction Test Succeeded\n') del yum.ts yum.initActionTs() # make a new, blank ts to populate yum.populateTs(keepold=0) # populate the ts yum.ts.check() #required for ordering yum.ts.order() # order # put back our depcheck callback yum.dsCallback = dscb cb = ruckyum.RPMInstallCallback(output=1) cb.tsInfo = yum.tsInfo yum.runTransaction(cb=cb) rucktalk.message('\nTransaction Finished') return True
def show_ts_list(self, items, isdep=False): for pkg in items: msg = " " + ruckformat.package_to_str(pkg) if isdep: msg += " (dependency)" rucktalk.message(msg)