The principle is to run emerge -uDpv world or similar once and stop it (Ctrl-c), a bit after displaying the list of packages. Then run the script. The script get the list of packages from emerge -resume --resume --pretend.
Then it try to install the 1st package of the list. If it's okay it goes on
If not, it remove the package from the start of the list and put at the end...
It may end or not but it will most probably install more package than a simple emerge --....etc
If you want to stop just use your keyboard!
HéHé! One known problem is that you don't read the warning and may hands up with some few problems.
SOmething that is shurely missing is to make 2 threads : one for downloading the packages and another for compilation that would boost up things especially with slow connection like mine
Code: Select all
import os,sys
def instal(pack):
a='emerge -1 '+pack
return os.system(a)
class pack_update:
def __init__(self):
self.packlist=[]
self.nostop = 1
#pass
def get_packages(self):
#get package list
os.system("emerge --resume --pretend>last_emerge")
l=open("last_emerge")
ll=l.readlines()
#put package names in packlist
for lll in ll[:]:
if lll.count('['):
l4=lll.split(' ')
for i in l4:
if i.count('-')>=2 and i.count('/')>=1:
self.packlist.append("="+i)
def print_packlist(self):
print self.packlist
def insert_package(self,aditionalpack):
self.packlist.insert(0,aditionalpack)
def install_packlist(self):
#try to install all packages if one packages fail, it will install it in the end...
#it also tries to install another packages before
while self.nostop and self.packlist:
if instal(self.packlist[0]) != 0:#if error
self.packlist.append(self.packlist.pop(0))
else:self.packlist.pop(0)#if no error
if __name__ == "__main__":
import threading
import time
import threading
class MyThread ( threading.Thread ):
def __init__(self):
threading.Thread.__init__(self)
self.P=pack_update()
self.P.get_packages()
self.P.print_packlist()
for pack in sys.argv[1:]:
self.P.insert_package(pack)
def run ( self ):
while self.P.nostop and self.P.packlist:
self.P.install_packlist()
A=MyThread()
A.start()
while A.P.nostop:
if "" == raw_input():
A.P.nostop = 0
print "stopped!"

