Changeset 516 for yum/trunk/cli.py
Legend:
- Unmodified
- Added
- Removed
-
yum/trunk
-
Property svn:mergeinfo
set to
/yum/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
yum/trunk/cli.py
r19 r516 39 39 import yum.plugins 40 40 from rpmUtils.arch import isMultiLibArch 41 from yum import _ 41 from yum import _, P_ 42 42 from yum.rpmtrans import RPMTransaction 43 43 import signal … … 45 45 46 46 from yum.i18n import to_unicode, to_utf8 47 48 # This is for yum-utils/yumdownloader in RHEL-5, where it isn't importing this 49 # directly but did do "from cli import *", and we did have this in 3.2.22. I 50 # just _love_ how python re-exports these by default. 51 from yum.packages import parsePackages 47 52 48 53 def sigquit(signum, frame): … … 74 79 self.verbose_logger = logging.getLogger("yum.verbose.cli") 75 80 self.yum_cli_commands = {} 81 self.use_txmbr_in_callback = True 76 82 self.registerCommand(yumcommands.InstallCommand()) 77 83 self.registerCommand(yumcommands.UpdateCommand()) … … 79 85 self.registerCommand(yumcommands.ListCommand()) 80 86 self.registerCommand(yumcommands.EraseCommand()) 81 self.registerCommand(yumcommands.GroupCommand()) 82 self.registerCommand(yumcommands.GroupListCommand()) 83 self.registerCommand(yumcommands.GroupInstallCommand()) 84 self.registerCommand(yumcommands.GroupRemoveCommand()) 85 self.registerCommand(yumcommands.GroupInfoCommand()) 87 self.registerCommand(yumcommands.GroupsCommand()) 86 88 self.registerCommand(yumcommands.MakeCacheCommand()) 87 89 self.registerCommand(yumcommands.CleanCommand()) … … 101 103 self.registerCommand(yumcommands.HistoryCommand()) 102 104 self.registerCommand(yumcommands.CheckRpmdbCommand()) 105 self.registerCommand(yumcommands.DistroSyncCommand()) 106 self.registerCommand(yumcommands.LoadTransactionCommand()) 103 107 104 108 def registerCommand(self, command): … … 139 143 """ 140 144 usage = 'yum [options] COMMAND\n\nList of Commands:\n\n' 141 commands = yum.misc.unique(self.yum_cli_commands.values()) 145 commands = yum.misc.unique([x for x in self.yum_cli_commands.values() 146 if not (hasattr(x, 'hidden') and x.hidden)]) 142 147 commands.sort(key=lambda x: x.getNames()[0]) 143 148 for command in commands: … … 150 155 151 156 return usage 152 157 158 def _parseSetOpts(self, setopts): 159 """parse the setopts list handed to us and saves the results as 160 repo_setopts and main_setopts in the yumbase object""" 161 162 repoopts = {} 163 mainopts = yum.misc.GenericHolder() 164 mainopts.items = [] 165 166 for item in setopts: 167 k,v = item.split('=') 168 period = k.find('.') 169 if period != -1: 170 repo = k[:period] 171 k = k[period+1:] 172 if repo not in repoopts: 173 repoopts[repo] = yum.misc.GenericHolder() 174 repoopts[repo].items = [] 175 setattr(repoopts[repo], k, v) 176 repoopts[repo].items.append(k) 177 else: 178 setattr(mainopts, k, v) 179 mainopts.items.append(k) 180 181 self.main_setopts = mainopts 182 self.repo_setopts = repoopts 183 184 153 185 def getOptionsConfig(self, args): 154 186 """parses command line arguments, takes cli args: … … 167 199 opts.verbose = False 168 200 201 # go through all the setopts and set the global ones 202 self._parseSetOpts(opts.setopts) 203 204 if self.main_setopts: 205 for opt in self.main_setopts.items: 206 setattr(opts, opt, getattr(self.main_setopts, opt)) 207 169 208 # get the install root to use 170 209 root = self.optparser.getRoot(opts) … … 190 229 pc.releasever = opts.releasever 191 230 self.conf 192 231 232 # now set all the non-first-start opts from main from our setopts 233 if self.main_setopts: 234 for opt in self.main_setopts.items: 235 if not hasattr(self.conf, opt): 236 msg ="Main config did not have a %s attr. before setopt" 237 self.logger.warning(msg % opt) 238 setattr(self.conf, opt, getattr(self.main_setopts, opt)) 239 193 240 except yum.Errors.ConfigError, e: 194 241 self.logger.critical(_('Config Error: %s'), e) … … 205 252 # apply some of the options to self.conf 206 253 (opts, self.cmds) = self.optparser.setupYumConfig(args=args) 254 255 if opts.version: 256 opts.quiet = True 257 opts.verbose = False 258 259 # Check that firstParse didn't miss anything, and warn the user if it 260 # did ... because this is really magic, and unexpected. 261 if opts.quiet: 262 opts.debuglevel = 0 263 if opts.verbose: 264 opts.debuglevel = opts.errorlevel = 6 265 if opts.debuglevel != pc.debuglevel or opts.errorlevel != pc.errorlevel: 266 self.logger.warning("Ignored option -q, -v, -d or -e (probably due to merging: -yq != -y -q)") 267 # getRoot() changes it, but then setupYumConfig() changes it back. So 268 # don't test for this, if we are using --installroot. 269 if root == '/' and opts.conffile != pc.fn: 270 self.logger.warning("Ignored option -c (probably due to merging -yc != -y -c)") 207 271 208 272 if opts.version: … … 288 352 self.yum_cli_commands[self.basecmd].doCheck(self, self.basecmd, self.extcmds) 289 353 354 def _shell_history_write(self): 355 if not hasattr(self, '_shell_history_cmds'): 356 return 357 if not self._shell_history_cmds: 358 return 359 360 data = self._shell_history_cmds 361 # Turn: [["a", "b"], ["c", "d"]] => "a b\nc d\n" 362 data = [" ".join(cmds) for cmds in data] 363 data.append('') 364 data = "\n".join(data) 365 self.history.write_addon_data('shell-cmds', data) 366 290 367 def doShell(self): 291 368 """do a shell-like interface for yum commands""" 292 369 293 370 yumshell = shell.YumShell(base=self) 371 372 # We share this array... 373 self._shell_history_cmds = yumshell._shell_history_cmds 374 294 375 if len(self.extcmds) == 0: 295 376 yumshell.cmdloop() 296 377 else: 297 378 yumshell.script() 379 380 del self._shell_history_cmds 381 298 382 return yumshell.result, yumshell.resultmsgs 299 383 … … 306 390 disk = {} 307 391 for m in p.finditer(errstring): 308 if not disk.has_key(m.group(2)):392 if m.group(2) not in disk: 309 393 disk[m.group(2)] = int(m.group(1)) 310 394 if disk[m.group(2)] < int(m.group(1)): … … 314 398 summary += _('Disk Requirements:\n') 315 399 for k in disk: 316 summary += _(' At least %dMB more space needed on the %s filesystem.\n') % (disk[k], k)400 summary += P_(' At least %dMB more space needed on the %s filesystem.\n', ' At least %dMB more space needed on the %s filesystem.\n', disk[k]) % (disk[k], k) 317 401 318 402 # TODO: simplify the dependency errors? … … 363 447 if len(self.tsInfo) == 0: 364 448 self.verbose_logger.info(_('Trying to run the transaction but nothing to do. Exiting.')) 365 return 1449 return -1 366 450 367 451 # NOTE: In theory we can skip this in -q -y mode, for a slight perf. … … 377 461 # Check which packages have to be downloaded 378 462 downloadpkgs = [] 463 rmpkgs = [] 379 464 stuff_to_download = False 380 465 install_only = True 466 remove_only = True 381 467 for txmbr in self.tsInfo.getMembers(): 382 468 if txmbr.ts_state not in ('i', 'u'): 383 469 install_only = False 470 po = txmbr.po 471 if po: 472 rmpkgs.append(po) 384 473 else: 474 remove_only = False 385 475 stuff_to_download = True 386 476 po = txmbr.po … … 395 485 # Report the total download size to the user, so he/she can base 396 486 # the answer on this info 397 if stuff_to_download: 487 if not stuff_to_download: 488 self.reportRemoveSize(rmpkgs) 489 else: 398 490 self.reportDownloadSize(downloadpkgs, install_only) 399 491 … … 402 494 if not self.userconfirm(): 403 495 self.verbose_logger.info(_('Exiting on user Command')) 404 return 1496 return -1 405 497 406 498 self.verbose_logger.log(yum.logginglevels.INFO_2, … … 419 511 # Check GPG signatures 420 512 if self.gpgsigcheck(downloadpkgs) != 0: 421 return 1 422 423 if self.conf.rpm_check_debug: 424 rcd_st = time.time() 425 self.verbose_logger.log(yum.logginglevels.INFO_2, 426 _('Running rpm_check_debug')) 427 msgs = self._run_rpm_check_debug() 428 if msgs: 429 rpmlib_only = True 430 for msg in msgs: 431 if msg.startswith('rpmlib('): 432 continue 433 rpmlib_only = False 434 if rpmlib_only: 435 print _("ERROR You need to update rpm to handle:") 436 else: 437 print _('ERROR with rpm_check_debug vs depsolve:') 438 439 for msg in msgs: 440 print to_utf8(msg) 441 442 if rpmlib_only: 443 return 1, [_('RPM needs to be updated')] 444 return 1, [_('Please report this error in %s') % self.conf.bugtracker_url] 445 446 self.verbose_logger.debug('rpm_check_debug time: %0.3f' % (time.time() - rcd_st)) 513 return -1 514 515 self.initActionTs() 516 # save our dsCallback out 517 dscb = self.dsCallback 518 self.dsCallback = None # dumb, dumb dumb dumb! 519 self.populateTs(keepold=0) # sigh 520 521 rcd_st = time.time() 522 self.verbose_logger.log(yum.logginglevels.INFO_2, 523 _('Running Transaction Check')) 524 msgs = self._run_rpm_check() 525 if msgs: 526 rpmlib_only = True 527 for msg in msgs: 528 if msg.startswith('rpmlib('): 529 continue 530 rpmlib_only = False 531 if rpmlib_only: 532 print _("ERROR You need to update rpm to handle:") 533 else: 534 print _('ERROR with transaction check vs depsolve:') 535 536 for msg in msgs: 537 print to_utf8(msg) 538 539 if rpmlib_only: 540 return 1, [_('RPM needs to be updated')] 541 return 1, [_('Please report this error in %s') % self.conf.bugtracker_url] 542 543 self.verbose_logger.debug('Transaction Check time: %0.3f' % (time.time() - rcd_st)) 447 544 448 545 tt_st = time.time() … … 452 549 self.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_DISKSPACE) 453 550 551 self.ts.order() # order the transaction 552 self.ts.clean() # release memory not needed beyond this point 454 553 455 554 testcb = RPMTransaction(self, test=True) 456 457 self.initActionTs()458 # save our dsCallback out459 dscb = self.dsCallback460 self.dsCallback = None # dumb, dumb dumb dumb!461 self.populateTs(keepold=0) # sigh462 555 tserrors = self.ts.test(testcb) 463 556 del testcb … … 472 565 self.verbose_logger.log(yum.logginglevels.INFO_2, 473 566 _('Transaction Test Succeeded')) 474 del self.ts475 567 476 568 self.verbose_logger.debug('Transaction Test time: %0.3f' % (time.time() - tt_st)) … … 480 572 481 573 ts_st = time.time() 482 self.initActionTs() # make a new, blank ts to populate 483 self.populateTs(keepold=0) # populate the ts 484 self.ts.check() #required for ordering 485 self.ts.order() # order 574 575 # Reinstalls broke in: 7115478c527415cb3c8317456cdf50024de89a94 ... 576 # I assume there's a "better" fix, but this fixes reinstalls and lets 577 # other options continue as is (and they seem to work). 578 have_reinstalls = False 579 for txmbr in self.tsInfo.getMembers(): 580 if txmbr.reinstall: 581 have_reinstalls = True 582 break 583 if have_reinstalls: 584 self.initActionTs() # make a new, blank ts to populate 585 self.populateTs(keepold=0) # populate the ts 586 self.ts.check() #required for ordering 587 self.ts.order() # order 588 self.ts.clean() # release memory not needed beyond this point 486 589 487 590 # put back our depcheck callback … … 544 647 msg = self.fmtKeyValFill(_(' * Maybe you meant: '), 545 648 ", ".join(matches)) 546 self.verbose_logger.log(yum.logginglevels.INFO_2, msg)547 548 def _checkMaybeYouMeant(self, arg, always_output=True ):649 self.verbose_logger.log(yum.logginglevels.INFO_2, to_unicode(msg)) 650 651 def _checkMaybeYouMeant(self, arg, always_output=True, rpmdb_only=False): 549 652 """ If the update/remove argument doesn't match with case, or due 550 653 to not being installed, tell the user. """ 551 654 # always_output is a wart due to update/remove not producing the 552 655 # same output. 553 matches = self.doPackageLists(patterns=[arg], ignore_case=False) 656 # if it is a grouppattern then none of this is going to make any sense 657 # skip it. 658 if not arg or arg[0] == '@': 659 return 660 661 pkgnarrow='all' 662 if rpmdb_only: 663 pkgnarrow='installed' 664 665 matches = self.doPackageLists(pkgnarrow=pkgnarrow, patterns=[arg], ignore_case=False) 554 666 if (matches.installed or (not matches.available and 555 667 self.returnInstalledPackagesByDep(arg))): … … 564 676 565 677 # No package name, so do the maybeYouMeant thing here too 566 matches = self.doPackageLists(p atterns=[arg], ignore_case=True)678 matches = self.doPackageLists(pkgnarrow=pkgnarrow, patterns=[arg], ignore_case=True) 567 679 if not matches.installed and matches.available: 568 680 self.verbose_logger.log(yum.logginglevels.INFO_2, … … 595 707 oldcount = len(self.tsInfo) 596 708 709 done = False 597 710 for arg in userlist: 598 711 if (arg.endswith('.rpm') and (yum.misc.re_remote_url(arg) or … … 609 722 self.term.MODE['normal']) 610 723 self._maybeYouMeant(arg) 724 else: 725 done = True 611 726 if len(self.tsInfo) > oldcount: 612 return 2, [_('Package(s) to install')] 727 change = len(self.tsInfo) - oldcount 728 return 2, [P_('%d package to install', '%d packages to install', change) % change] 729 730 if not done: 731 return 1, [_('Nothing to do')] 613 732 return 0, [_('Nothing to do')] 614 733 615 def updatePkgs(self, userlist, quiet=0 ):734 def updatePkgs(self, userlist, quiet=0, update_to=False): 616 735 """take user commands and populate transaction wrapper with 617 736 packages to be updated""" … … 640 759 641 760 for arg in userlist: 642 if not self.update(pattern=arg ):761 if not self.update(pattern=arg, update_to=update_to): 643 762 self._checkMaybeYouMeant(arg) 644 763 645 764 if len(self.tsInfo) > oldcount: 646 765 change = len(self.tsInfo) - oldcount 647 msg = _('%d packages marked for Update') % change 648 return 2, [msg] 766 return 2, [P_('%d package marked for Update', '%d packages marked for Update', change) % change] 649 767 else: 650 768 return 0, [_('No Packages marked for Update')] 769 770 # Note that we aren't in __init__ yet for a couple of reasons, but we 771 # probably will get there for 3.2.28. 772 def distroSyncPkgs(self, userlist): 773 """ This does either upgrade/downgrade, depending on if the latest 774 installed version is older or newer. We allow "selection" but not 775 local packages (use tmprepo, or something). """ 776 777 level = 'diff' 778 if userlist and userlist[0] in ('full', 'diff', 'different'): 779 level = userlist[0] 780 userlist = userlist[1:] 781 if level == 'different': 782 level = 'diff' 783 784 dupdates = [] 785 ipkgs = {} 786 for pkg in sorted(self.rpmdb.returnPackages(patterns=userlist)): 787 ipkgs[pkg.name] = pkg 788 789 obsoletes = [] 790 if self.conf.obsoletes: 791 obsoletes = self.up.getObsoletesTuples(newest=1) 792 793 for (obsoleting, installed) in obsoletes: 794 if installed[0] not in ipkgs: 795 continue 796 dupdates.extend(self.update(pkgtup=installed)) 797 for (obsoleting, installed) in obsoletes: 798 if installed[0] not in ipkgs: 799 continue 800 del ipkgs[installed[0]] 801 802 apkgs = {} 803 pkgs = [] 804 if ipkgs: 805 try: 806 pkgs = self.pkgSack.returnNewestByName(patterns=ipkgs.keys()) 807 except yum.Errors.PackageSackError: 808 pkgs = [] 809 810 for pkg in pkgs: 811 if pkg.name not in ipkgs: 812 continue 813 apkgs[pkg.name] = pkg 814 815 for ipkgname in ipkgs: 816 if ipkgname not in apkgs: 817 continue 818 819 ipkg = ipkgs[ipkgname] 820 apkg = apkgs[ipkgname] 821 if ipkg.verEQ(apkg): # Latest installed == Latest avail. 822 if level == 'diff': 823 continue 824 825 # level == full: do reinstalls if checksum doesn't match. 826 # do removals, if older installed versions. 827 for napkg in self.rpmdb.searchNames([ipkgname]): 828 if (not self.allowedMultipleInstalls(apkg) and 829 not napkg.verEQ(ipkg)): 830 dupdates.extend(self.remove(po=napkg)) 831 continue 832 833 nayi = napkg.yumdb_info 834 for apkg in self.pkgSack.searchPkgTuple(napkg.pkgtup): 835 if ('checksum_type' in nayi and 836 'checksum_data' in nayi and 837 nayi.checksum_type == apkg.checksum_type and 838 nayi.checksum_data == apkg.pkgId): 839 found = True 840 break 841 if found: 842 continue 843 dupdates.extend(self.reinstall(pkgtup=napkg.pkgtup)) 844 continue 845 846 if self.allowedMultipleInstalls(apkg): 847 found = False 848 for napkg in self.rpmdb.searchNames([apkg.name]): 849 if napkg.verEQ(apkg): 850 found = True 851 elif napkg.verGT(apkg): 852 dupdates.extend(self.remove(po=napkg)) 853 if found: 854 continue 855 dupdates.extend(self.install(pattern=apkg.name)) 856 elif ipkg.verLT(apkg): 857 n,a,e,v,r = apkg.pkgtup 858 dupdates.extend(self.update(name=n, epoch=e, ver=v, rel=r)) 859 else: 860 n,a,e,v,r = apkg.pkgtup 861 dupdates.extend(self.downgrade(name=n, epoch=e, ver=v, rel=r)) 862 863 if dupdates: 864 return 2, [P_('%d package marked for Distribution Synchronization', '%d packages marked for Distribution Synchronization', len(dupdates)) % len(dupdates)] 865 else: 866 return 0, [_('No Packages marked for Distribution Synchronization')] 651 867 652 868 def erasePkgs(self, userlist): … … 655 871 656 872 oldcount = len(self.tsInfo) 657 873 874 all_rms = [] 658 875 for arg in userlist: 659 if not self.remove(pattern=arg):660 self._checkMaybeYouMeant(arg, always_output=False)661 662 if len(self.tsInfo) > oldcount:663 change = len(self.tsInfo) - oldcount664 msg = _('%d packages marked for removal') % change665 return 2, [ msg]876 rms = self.remove(pattern=arg) 877 if not rms: 878 self._checkMaybeYouMeant(arg, always_output=False, rpmdb_only=True) 879 all_rms.extend(rms) 880 881 if all_rms: 882 return 2, [P_('%d package marked for removal', '%d packages marked for removal', len(all_rms)) % len(all_rms)] 666 883 else: 667 884 return 0, [_('No Packages marked for removal')] … … 690 907 self._maybeYouMeant(arg) 691 908 if len(self.tsInfo) > oldcount: 692 return 2, [_('Package(s) to downgrade')] 909 change = len(self.tsInfo) - oldcount 910 return 2, [P_('%d package to downgrade', '%d packages to downgrade', change) % change] 693 911 return 0, [_('Nothing to do')] 694 912 … … 711 929 self._checkMaybeYouMeant(arg, always_output=False) 712 930 except yum.Errors.ReinstallInstallError, e: 713 ipkg = self.rpmdb.returnPackages(patterns=[arg])[0]714 xmsg = ''715 if 'from_repo' in ipkg.yumdb_info:716 xmsg = ipkg.yumdb_info.from_repo717 xmsg = _(' (from %s)') % xmsg718 self.verbose_logger.log(yum.logginglevels.INFO_2,719 _('Installed package %s%s%s%s not available.'),720 self.term.MODE['bold'], ipkg,721 self.term.MODE['normal'], xmsg)931 for ipkg in e.failed_pkgs: 932 xmsg = '' 933 if 'from_repo' in ipkg.yumdb_info: 934 xmsg = ipkg.yumdb_info.from_repo 935 xmsg = _(' (from %s)') % xmsg 936 msg = _('Installed package %s%s%s%s not available.') 937 self.verbose_logger.log(yum.logginglevels.INFO_2, msg, 938 self.term.MODE['bold'], ipkg, 939 self.term.MODE['normal'], xmsg) 722 940 except yum.Errors.ReinstallError, e: 723 941 assert False, "Shouldn't happen, but just in case" 724 942 self.verbose_logger.log(yum.logginglevels.INFO_2, e) 725 943 if len(self.tsInfo) > oldcount: 726 return 2, [_('Package(s) to reinstall')] 944 change = len(self.tsInfo) - oldcount 945 return 2, [P_('%d package to reinstall', '%d packages to reinstall', change) % change] 727 946 return 0, [_('Nothing to do')] 728 947 … … 741 960 installing = False 742 961 for pkg in filelist: 962 if not pkg.endswith('.rpm'): 963 self.verbose_logger.log(yum.logginglevels.INFO_2, 964 "Skipping: %s, filename does not end in .rpm.", pkg) 965 continue 743 966 txmbrs = self.installLocal(pkg, updateonly=updateonly) 744 967 if txmbrs: … … 805 1028 dups = self.conf.showdupesfromrepos 806 1029 args = map(to_unicode, args) 1030 1031 okeys = set() 1032 akeys = set() # All keys, used to see if nothing matched 1033 mkeys = set() # "Main" set of keys for N/S search (biggest term. hit). 1034 pos = set() 1035 1036 def _print_match_section(text): 1037 # Print them in the order they were passed 1038 used_keys = [arg for arg in args if arg in keys] 1039 print self.fmtSection(text % ", ".join(used_keys)) 1040 1041 # First try just the name/summary fields, and if we get any hits 1042 # don't do the other stuff. Unless the user overrides via. "all". 1043 if len(args) > 1 and args[0] == 'all': 1044 args.pop(0) 1045 else: 1046 matching = self.searchGenerator(['name', 'summary'], args, 1047 showdups=dups, keys=True) 1048 for (po, keys, matched_value) in matching: 1049 if keys != okeys: 1050 if akeys: 1051 if len(mkeys) == len(args): 1052 break 1053 print "" 1054 else: 1055 mkeys = set(keys) 1056 _print_match_section(_('N/S Matched: %s')) 1057 okeys = keys 1058 pos.add(po) 1059 akeys.update(keys) 1060 self.matchcallback(po, matched_value, args) 1061 807 1062 matching = self.searchGenerator(searchlist, args, 808 1063 showdups=dups, keys=True) 809 1064 810 1065 okeys = set() 811 akeys = set() 1066 1067 # If we got a hit with just name/summary then we only care about hits 1068 # with _more_ search terms. Thus. if we hit all our search terms. do 1069 # nothing. 1070 if len(mkeys) == len(args): 1071 print "" 1072 if len(args) == 1: 1073 msg = _(' Name and summary matches %sonly%s, use "search all" for everything.') 1074 else: 1075 msg = _(' Full name and summary matches %sonly%s, use "search all" for everything.') 1076 print msg % (self.term.MODE['bold'], self.term.MODE['normal']) 1077 matching = [] 1078 812 1079 for (po, keys, matched_value) in matching: 1080 # Don't print matches for "a", "b", "c" on N+S+D when we already 1081 # matched that on just N+S. 1082 if len(keys) <= len(mkeys): 1083 continue 1084 # Just print the highest level of full matches, when we did 1085 # minimal matches. Ie. "A", "B" match N+S, just print the 1086 # "A", "B", "C", "D" full match, and not the "B", "C", "D" matches. 1087 if mkeys and len(keys) < len(okeys): 1088 continue 1089 813 1090 if keys != okeys: 814 1091 if akeys: 815 1092 print "" 816 # Print them in the order they were passed 817 used_keys = [arg for arg in args if arg in keys] 818 print self.fmtSection(_('Matched: %s') % ", ".join(used_keys)) 1093 _print_match_section(_('Matched: %s')) 819 1094 okeys = keys 820 1095 akeys.update(keys) 821 1096 self.matchcallback(po, matched_value, args) 1097 1098 if mkeys and len(mkeys) != len(args): 1099 print "" 1100 print _(' Name and summary matches %smostly%s, use "search all" for everything.') % (self.term.MODE['bold'], self.term.MODE['normal']) 822 1101 823 1102 for arg in args: … … 839 1118 thispkg = yum.packages.YumUrlPackage(self, self.ts, arg) 840 1119 pkgs.append(thispkg) 1120 elif self.conf.showdupesfromrepos: 1121 pkgs.extend(self.pkgSack.returnPackages(patterns=[arg])) 841 1122 else: 842 ematch, match, unmatch = self.pkgSack.matchPackageNames([arg]) 843 for po in ematch + match: 844 pkgs.append(po) 1123 try: 1124 pkgs.extend(self.pkgSack.returnNewestByName(patterns=[arg])) 1125 except yum.Errors.PackageSackError: 1126 pass 845 1127 846 results = self.findDeps(pkgs)847 self.depListOutput(results)1128 results = self.findDeps(pkgs) 1129 self.depListOutput(results) 848 1130 849 1131 return 0, [] … … 860 1142 matching = self.searchPackageProvides(args, callback=cb, 861 1143 callback_has_matchfor=True) 1144 if len(matching) == 0: 1145 # Try to be a bit clever, for commands, and python modules. 1146 # Maybe want something so we can do perl/etc. too? 1147 paths = set(sys.path + os.environ['PATH'].split(':')) 1148 nargs = [] 1149 for arg in args: 1150 if yum.misc.re_filename(arg) or yum.misc.re_glob(arg): 1151 continue 1152 for path in paths: 1153 if not path: 1154 continue 1155 nargs.append("%s/%s" % (path, arg)) 1156 matching = self.searchPackageProvides(nargs, callback=cb, 1157 callback_has_matchfor=True) 862 1158 self.conf.showdupesfromrepos = old_sdup 863 1159 864 1160 if len(matching) == 0: 865 for arg in args:866 if '*' in arg or (arg and arg[0] == '/'):867 continue868 self.logger.warning(_('Warning: 3.0.x versions of yum would erroneously match against filenames.\n You can use "%s*/%s%s" and/or "%s*bin/%s%s" to get that behaviour'),869 self.term.MODE['bold'], arg,870 self.term.MODE['normal'],871 self.term.MODE['bold'], arg,872 self.term.MODE['normal'])873 1161 return 0, ['No Matches found'] 874 1162 … … 892 1180 hdrcode = pkgcode = xmlcode = dbcode = expccode = 0 893 1181 pkgresults = hdrresults = xmlresults = dbresults = expcresults = [] 1182 msg = self.fmtKeyValFill(_('Cleaning repos: '), 1183 ' '.join([ x.id for x in self.repos.listEnabled()])) 1184 self.verbose_logger.log(yum.logginglevels.INFO_2, msg) 894 1185 if 'all' in userlist: 895 1186 self.verbose_logger.log(yum.logginglevels.INFO_2, … … 951 1242 patterns=userlist) 952 1243 953 if len(installed) > 0: 954 self.verbose_logger.log(yum.logginglevels.INFO_2, 955 _('Installed Groups:')) 956 for group in installed: 957 if self.verbose_logger.isEnabledFor(yum.logginglevels.DEBUG_3): 958 self.verbose_logger.log(yum.logginglevels.INFO_2, 959 ' %s (%s)', group.ui_name, 960 group.groupid) 961 else: 962 self.verbose_logger.log(yum.logginglevels.INFO_2, 963 ' %s', group.ui_name) 964 965 if len(available) > 0: 966 self.verbose_logger.log(yum.logginglevels.INFO_2, 967 _('Available Groups:')) 968 for group in available: 969 if self.verbose_logger.isEnabledFor(yum.logginglevels.DEBUG_3): 970 self.verbose_logger.log(yum.logginglevels.INFO_2, 971 ' %s (%s)', group.ui_name, 972 group.groupid) 973 else: 974 self.verbose_logger.log(yum.logginglevels.INFO_2, 975 ' %s', group.ui_name) 1244 if not installed and not available: 1245 self.logger.error(_('Warning: No groups match: %s'), 1246 ", ".join(userlist)) 1247 return 0, [] 1248 1249 def _out_grp(sect, group): 1250 if not done: 1251 self.verbose_logger.log(yum.logginglevels.INFO_2, sect) 1252 msg = ' %s' % group.ui_name 1253 if self.verbose_logger.isEnabledFor(yum.logginglevels.DEBUG_3): 1254 msg += ' (%s)' % group.groupid 1255 if group.langonly: 1256 msg += ' [%s]' % group.langonly 1257 self.verbose_logger.log(yum.logginglevels.INFO_2, '%s', msg) 1258 1259 done = False 1260 for group in installed: 1261 if group.langonly: continue 1262 _out_grp(_('Installed Groups:'), group) 1263 done = True 1264 1265 done = False 1266 for group in installed: 1267 if not group.langonly: continue 1268 _out_grp(_('Installed Language Groups:'), group) 1269 done = True 1270 1271 done = False 1272 for group in available: 1273 if group.langonly: continue 1274 _out_grp(_('Available Groups:'), group) 1275 done = True 1276 1277 done = False 1278 for group in available: 1279 if not group.langonly: continue 1280 _out_grp(_('Available Language Groups:'), group) 1281 done = True 1282 1283 return 0, [_('Done')] 1284 1285 def returnGroupSummary(self, userlist): 1286 1287 uservisible=1 1288 1289 if len(userlist) > 0: 1290 if userlist[0] == 'hidden': 1291 uservisible=0 1292 userlist.pop(0) 1293 if not userlist: 1294 userlist = None # Match everything... 1295 1296 installed, available = self.doGroupLists(uservisible=uservisible, 1297 patterns=userlist) 1298 1299 def _out_grp(sect, num): 1300 if not num: 1301 return 1302 self.verbose_logger.log(yum.logginglevels.INFO_2, '%s %u', sect,num) 1303 done = 0 1304 for group in installed: 1305 if group.langonly: continue 1306 done += 1 1307 _out_grp(_('Installed Groups:'), done) 1308 1309 done = 0 1310 for group in installed: 1311 if not group.langonly: continue 1312 done += 1 1313 _out_grp(_('Installed Language Groups:'), done) 1314 1315 done = False 1316 for group in available: 1317 if group.langonly: continue 1318 done += 1 1319 _out_grp(_('Available Groups:'), done) 1320 1321 done = False 1322 for group in available: 1323 if not group.langonly: continue 1324 done += 1 1325 _out_grp(_('Available Language Groups:'), done) 976 1326 977 1327 return 0, [_('Done')] … … 1016 1366 return 0, [_('No packages in any requested group available to install or update')] 1017 1367 else: 1018 return 2, [ _('%d Package(s) to Install') % len(pkgs_used)]1368 return 2, [P_('%d package to Install', '%d packages to Install', len(pkgs_used)) % len(pkgs_used)] 1019 1369 1020 1370 def removeGroups(self, grouplist): … … 1034 1384 return 0, [_('No packages to remove from groups')] 1035 1385 else: 1036 return 2, [ _('%d Package(s) to remove') % len(pkgs_used)]1386 return 2, [P_('%d package to remove', '%d packages to remove', len(pkgs_used)) % len(pkgs_used)] 1037 1387 1038 1388 … … 1149 1499 args = _filtercmdline( 1150 1500 ('--noplugins','--version','-q', '-v', "--quiet", "--verbose"), 1151 ('-c', '-d', '-e', '--installroot', 1152 '--disableplugin', '--enableplugin', '--releasever'), 1501 ('-c', '--config', '-d', '--debuglevel', 1502 '-e', '--errorlevel', 1503 '--installroot', 1504 '--disableplugin', '--enableplugin', '--releasever', 1505 '--setopt'), 1153 1506 args) 1154 1507 except ValueError, arg: … … 1197 1550 1198 1551 if opts.installroot: 1552 self._checkAbsInstallRoot(opts) 1199 1553 self.base.conf.installroot = opts.installroot 1200 1554 … … 1263 1617 # Disable all gpg key checking, if requested. 1264 1618 if opts.nogpgcheck: 1265 self.base.conf.gpgcheck = False 1266 self.base.conf.repo_gpgcheck = False 1619 # Altering the normal configs. doesn't work too well, esp. with 1620 # regard to dynamically enabled repos. 1621 self.base._override_sigchecks = True 1267 1622 for repo in self.base.repos.listEnabled(): 1268 repo.gpgcheck = False 1269 repo.repo_gpgcheck = False 1623 repo._override_sigchecks = True 1270 1624 1271 1625 except ValueError, e: … … 1276 1630 return opts, cmds 1277 1631 1632 def _checkAbsInstallRoot(self, opts): 1633 if not opts.installroot: 1634 return 1635 if opts.installroot[0] == '/': 1636 return 1637 # We have a relative installroot ... haha 1638 self.logger.critical(_('--installroot must be an absolute path: %s'), 1639 opts.installroot) 1640 sys.exit(1) 1641 1278 1642 def getRoot(self,opts): 1643 self._checkAbsInstallRoot(opts) 1279 1644 # If the conf file is inside the installroot - use that. 1280 1645 # otherwise look for it in the normal root … … 1384 1749 group.add_option("", "--releasever", dest="releasever", default=None, 1385 1750 help=_("set value of $releasever in yum config and repo files")) 1386 1751 group.add_option("", "--setopt", dest="setopts", default=[], 1752 action="append", help=_("set arbitrary config and repo options")) 1387 1753 1388 1754 … … 1401 1767 Will raise ValueError if there was a problem parsing the command line. 1402 1768 ''' 1769 # ' xemacs syntax hack 1403 1770 out = [] 1404 1771 args = list(args) # Make a copy because this func is destructive … … 1410 1777 if opt in valopts: 1411 1778 out.append(a) 1779 1780 elif a == '--': 1781 out.append(a) 1412 1782 1413 1783 elif a in novalopts:
Note:
See TracChangeset
for help on using the changeset viewer.
