*** /usr/lib/python2.2/site-packages/portage.py 2003-05-07 10:06:10.000000000 +0200 --- portage.py 2003-05-07 10:08:01.000000000 +0200 *************** *** 59,64 **** --- 59,87 ---- return "/" getcwd() + 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() + def abssymlink(symlink): "This reads symlinks, resolving the relative symlinks, and returning the absolute." mylink=os.readlink(symlink) *************** *** 1060,1065 **** --- 1083,1089 ---- if listonly: fetched=0 print "" + myfilefd=lockfile(myfile) for loc in filedict[myfile]: if listonly: print loc+" ", *************** *** 1120,1125 **** --- 1144,1150 ---- if not myret: fetched=2 break + unlockfile(myfilefd) if (fetched!=2) and not listonly: print '!!! Couldn\'t download',myfile+". Aborting." return 0