diff -u -r1.177 emerge --- bin/emerge 2003/01/15 22:57:42 1.177 +++ bin/emerge 2003/01/19 07:54:15 @@ -16,11 +16,11 @@ params=["selective", "deep", "self", "recurse", "empty"] actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean"] options=["--autoclean", "--deep", "--selective", "--buildpkg", "--buildpkgonly", "--debug", "--nodeps", "--emptytree", "--fetchonly", "--changelog", -"--noreplace", "--onlydeps", "--pretend", "--usepkg", "--usepkgonly", "--searchdesc", "--verbose", "--update", "--help", "--oneshot", "--version"] +"--noreplace", "--onlydeps", "--pretend", "--usepkg", "--usepkgonly", "--searchdesc", "--verbose", "--update", "--help", "--oneshot", "--version", "--nodowngrade"] shortmapping={"a":"--autoclean", "b":"--buildpkg", "B":"--buildpkgonly", "c":"clean", "C":"unmerge", "e":"--emptytree", "d":"--debug", "f":"--fetchonly", - "h":"--help", "i":"inject", "k":"--usepkg", "K":"--usepkgonly", "l":"--changelog", "n":"--noreplace", "o":"--onlydeps", "O":"--nodeps", - "p":"--pretend", "P":"prune", "s":"search", "S":"--searchdesc", "u":"--update", "v":"--verbose", "V":"--version"} + "g":"--nodowngrade", "h":"--help", "i":"inject", "k":"--usepkg", "K":"--usepkgonly", "l":"--changelog", "n":"--noreplace", "o":"--onlydeps", + "O":"--nodeps", "p":"--pretend", "P":"prune", "s":"search", "S":"--searchdesc", "u":"--update", "v":"--verbose", "V":"--version"} def emergelog(mystr): try: @@ -576,6 +576,22 @@ # We're true here unless we are missing binaries. return (not self.missingbins,myfavorites) + def is_newer_ver_installed(self,myroot,pkg,pkgver): + "if there is a version of pkg installed newer than pkgver, return it" + vardbapi=portage.db[myroot]["vartree"].dbapi + + alleb=portage.portdb.xmatch("match-all",pkg) + while alleb: + cand=portage.portdb.xmatch("bestmatch-list",pkg,mylist=alleb) + if not cand: + break + if vardbapi.cpv_exists(cand): + # installed, is this package newer? + if portage.pkgcmp(portage.catpkgsplit(pkgver)[1:], portage.catpkgsplit(cand)[1:]) < 0: + return cand + break + alleb.remove(cand) + def select_dep(self,myroot,depstring,myparent=None,arg=None): "given a dependency string, create the appropriate depgraph and return 1 on success and 0 on failure" if not arg: @@ -616,6 +632,12 @@ else: print "\nemerge: there are no masked or unmasked ebuilds to satisfy "+xinfo+"." return 0 + + if "--nodowngrade" in myopts: + # Check that there isn't a newer version of this package already installed + cand=self.is_newer_ver_installed(myroot,x,myeb) + if cand: + myeb=cand if "--usepkg" in myopts: #If we want to use packages, see if we have a pre-built one... @@ -702,6 +724,12 @@ if not myeb: #this is an unavailable world entry; just continue continue + + if "--nodowngrade" in myopts: + cand=self.is_newer_ver_installed(portage.root,mydep,myeb) + if cand: + myeb=cand + #THIS NEXT BUNCH OF CODE NEEDS TO BE REPLACED TO SUPPORT WORLD ANTI-DEPS #if mydep2[0]=="!":, etc. if "--usepkg" in myopts: diff -u -r1.2 emergehelp.py --- bin/emergehelp.py 2003/01/07 13:08:48 1.2 +++ bin/emergehelp.py 2003/01/19 07:54:16 @@ -14,7 +14,7 @@ print " "+turquoise("emerge")+" [ "+green("options")+" ] [ "+green("action")+" ] < "+turquoise("system")+" | "+turquoise("world")+" >" print " "+turquoise("emerge")+" < "+turquoise("sync")+" | "+turquoise("rsync")+" | "+turquoise("info")+" >" print " "+turquoise("emerge")+" "+green("--help")+" "+green("-h")+" [ "+turquoise("system")+" | "+turquoise("config")+" ] " - print bold("Options:")+" "+green("-")+"["+green("abcCdefhikKlnoOpPsSuvV")+"] ["+green("--deep")+"] ["+green("--oneshot")+"]" + print bold("Options:")+" "+green("-")+"["+green("abcCdefghikKlnoOpPsSuvV")+"] ["+green("--deep")+"] ["+green("--oneshot")+"]" print bold("Actions:")+" [ clean | depclean | inject | prune | regen | search | unmerge ]" print @@ -144,6 +144,10 @@ print " all packages (main package as well as all dependencies.) When" print " used in combination with --pretend all the SRC_URIs will be" print " displayed multiple mirrors per line, one line per file." + print + print " "+green("--nodowngrade")+" ("+green("-g")+" short option)" + print " If an installed package becomes masked, do not downgrade to" + print " a lower, unmasked version." print print " "+green("--nodeps")+" ("+green("-O")+" short option)" print " Merge specified packages, but don't merge any dependencies."