Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 33619 Details for
Bug 14983
CONTENTS use spaces as delimiters
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
update_vardb.py
cleanse-db.py (text/plain), 3.14 KB, created by
Brian Harring (RETIRED)
on 2004-06-20 04:08:30 UTC
(
hide
)
Description:
update_vardb.py
Filename:
MIME Type:
Creator:
Brian Harring (RETIRED)
Created:
2004-06-20 04:08:30 UTC
Size:
3.14 KB
patch
obsolete
>#!/usr/bin/python >#fix CONTENTS entries, keep the backwards compatabilty fixes outside of portage, in an ancillary script > >import os, commands,sys, string > >from stat import S_ISDIR > >def check_contents(mydata): > #simplistic, but more can be jammed in here later on. > for line in mydata: > if line.find("\t") == -1: > return 1 > return 0 > >def update_contents(mydata): > count = len(mydata) > for x in range(0, count): > new_entry = [] > entry = mydata[0].split() > mydata.pop(0) > > if entry[0]=="obj": > #format: type, md5sum, mtime > new_entry = ['obj',string.join(entry[1:-2],' '), entry[-2], entry[-1]] > elif entry[0]=="dir": > #format: type > new_entry = ['dir', string.join(entry[1:],' ')] > elif entry[0]=="sym": > #format: type, mtime, dest > x=len(entry)-1 > if (x >= 13) and (entry[-1][-1]==')'): # Old/Broken symlink entry > entry = entry[:-10]+[entry[-10:][ST_MTIME][:-1]] > print "FIXED SYMLINK LINE: %s\n" % entry > x=len(entry)-1 > splitter=-1 > while(x>=0): > if entry[x]=="->": > splitter=x > break > x=x-1 > if splitter==-1: > return None > new_entry = ['sym', string.join(entry[:splitter], ' '), entry[-1], string.join(entry[(splitter+1):-1]," ")] > elif entry[0]=="dev": > #format: type > new_entry = ['dev', string.join(entry[1:]," ")] > elif entry[0]=="fif": > #format: type > new_entry = ['fif', string.join(entry[1:], " ")] > else: > print "unable to handle type %s" % entry[0] > return 0 > mydata.append(new_entry) > return 1 > > >def process(base): > files = commands.getoutput("find '%s/' -name CONTENTS -type f -maxdepth 3 -mindepth 2" % base) > updated = 0 > processed = 0 > failed = 0 > for filename in files.split("\n"): > try: > file = open(filename, "r") > except: > print "unable to open '%s', skipping\n" % filename > continue > mydata=file.readlines() > file.close() > processed += 1 > if len(mydata) == 0: > continue > if check_contents(mydata): > try: > if update_contents(mydata): > if len(mydata) == 0: > print "bypassing %s: no data from update" % filename > failed += 1 > continue > try: > file = open(filename, "w") > except: > print "unable to write to %s" % filename > failed += 1 > continue > updated += 1 > for line in mydata: > file.write(string.join(line,"\t")+"\n") > file.close() > print "updated %s" % filename > else: > failed += 1 > print "unable to update %s, skipping." % filename > except Exception, e: > failed += 1 > print "detected that '%s' needed updating, but failed due to exception '%s'" % (filename, str(e)) > return processed, updated, failed > >if __name__ == "__main__": > if not len(sys.argv) == 2: > print "I need one arguement, the vardb directory to work on\n" > sys.exit(1) > print "processing %s" % str(sys.argv[1]) > import stat > if not (os.path.exists(sys.argv[1]) and S_ISDIR(os.lstat(sys.argv[1])[stat.ST_MODE])): > print "sorry, but %s is not a dir. good bye.\n" % sys.argv[1] > sys.exit(1) > processed, updated, failed = process(sys.argv[1]) > print "processed %u packages" % processed > print "updated %u packages" % updated > if failed > 0: > print "failed updating %u packages" % failed > print "finished" > if failed: > sys.exit(1) > sys.exit(0)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 14983
:
25157
|
25188
|
33618
| 33619 |
33620
|
33723