-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://bugs.gentoo.org/show_bug.cgi?id=117988

Honestly, I don't really understand the code that emerge uses to restart 
itself.  Basically, the current behavior is to restart itself with a filtered 
version of it's original arguments.  It seems to be error prone and I don't see 
how it can handle all of the necessary cases.

The attached patch uses the existing "--resume" functionality to solve the 
problem.  The new argument list is generated from "myopts" and selected 
"badlongopts" are
filtered out.  I've been using this patch locally with no issues.  Feedback 
would be appreciated.

Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD3n1U/ejvha5XGaMRAgTGAKDHAQX1KylV3ySzSszz/5y0vFpppACgut85
igndUxDitsV5L05aISFxYi0=
=a5C4
-----END PGP SIGNATURE-----
Index: bin/emerge
===================================================================
--- bin/emerge	(revision 2608)
+++ bin/emerge	(working copy)
@@ -2112,36 +2112,16 @@
 						if (myver != portage.VERSION) and \
 						   ("livecvsportage" not in portage.settings.features):
 							if len(mymergelist) > mergecount:
-								myargv=sys.argv
-								myr=0
-								for myra in range(len(myargv)):
-									if myargv[myr][0:len("portage")]=="portage":
-										del myargv[myr]
-										myr-=1
-									if myargv[myr][0:len("sys-apps/portage")]=="sys-apps/portage":
-										del myargv[myr]
-										myr-=1
-									myr+=1
 								emergelog(" *** RESTARTING emerge via exec() after change of portage version.")
+								del portage.mtimedb["resume"]["mergelist"][0]
 								portage.portageexit()
-								# Remove --ask from options before restarting
 								mynewargv=[]
-								badlongopts = ["--ask","--tree","--changelog"]
-								badshortopts = ["a","t","l"]
-								for arg in myargv:
-									if arg[0:2] == "--":
-										if arg in badlongopts:
-											continue
-										mynewargv += [arg]
-									elif arg[0] == "-":
-										myarg = "-"
-										for ch in arg[1:]:
-											if ch in badshortopts:
-												continue
-											myarg += ch
-										mynewargv += [myarg]
-									else:
-										mynewargv += [arg]
+								badlongopts = ("--ask","--tree","--changelog","--skipfirst","--resume")
+								for arg in myopts:
+									if arg in badlongopts:
+										continue
+									mynewargv.append(arg)
+								mynewargv.append("--resume")
 								os.execv("/usr/lib/portage/bin/emerge", mynewargv)
 
 			if ("--pretend" not in myopts) and ("--fetchonly" not in myopts) and ("--fetch-all-uri" not in myopts):

Reply via email to