*** portage.py.orig 2003-06-16 16:52:48.000000000 +0200 --- portage.py 2003-06-16 17:06:30.000000000 +0200 *************** *** 208,213 **** --- 208,236 ---- os.kill(0,signal.SIGKILL) sys.exit(1) + lockdir="var/tmp/portage/" + def lockfile(filename,verbose=1): + "Locks on /lockdir/filename, creates the lock file if necessary" + #fd=open(root+lockdir+md5.new(filename).hexdigest(),'w') + fd=open(root+lockdir+filename,'w') + if verbose: + try: + fcntl.lockf(fd,fcntl.LOCK_EX|fcntl.LOCK_NB) + except IOError: + print green(" * ")+"Another process is holding a lock on '"+filename+"'" + print green(" * ")+"Waiting.. ", + sys.stdout.flush() + fcntl.lockf(fd,fcntl.LOCK_EX) + print "Resuming." + else: + fcntl.lockf(fd,fcntl.LOCK_EX) + return fd + + def unlockfile(fd): + "Releases a lock on fd" + fcntl.lockf(fd,fcntl.LOCK_UN) + fd.close() + # dropping the signal handler to gives better tracebacks # enable unless we're debugging if not os.environ.has_key("DEBUG"): *************** *** 1108,1113 **** --- 1131,1137 ---- if listonly: fetched=0 print "" + myfilefd=lockfile(myfile) for loc in filedict[myfile]: if listonly: print loc+" ", *************** *** 1195,1200 **** --- 1219,1225 ---- if not myret: fetched=2 break + unlockfile(myfilefd) if (fetched!=2) and not listonly: print '!!! Couldn\'t download',myfile+". Aborting." return 0