diff options
author | Robert Buchholz <rbu@goodpoint.de> | 2008-03-24 22:30:32 +0100 |
---|---|---|
committer | Robert Buchholz <rbu@goodpoint.de> | 2008-03-24 23:06:03 +0100 |
commit | 387c07320a892d11d953690be7d5b3c129f6fae3 (patch) | |
tree | 582025e48421f221b3199809db7f981d29722cca | |
parent | Add tools to query and dump the index. (diff) | |
download | distindex-387c07320a892d11d953690be7d5b3c129f6fae3.tar.gz distindex-387c07320a892d11d953690be7d5b3c129f6fae3.tar.bz2 distindex-387c07320a892d11d953690be7d5b3c129f6fae3.zip |
Remove url and ebuild from generated distfile, use .INDEX file ending.
-rwxr-xr-x | distfiles-indexer.py | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/distfiles-indexer.py b/distfiles-indexer.py index 5351a04..0895fe0 100755 --- a/distfiles-indexer.py +++ b/distfiles-indexer.py @@ -30,19 +30,16 @@ def hash_file(fileobj, *hashobjects): class ArchiveInfo: - def __init__(self, filename, url, ebuild): + def __init__(self, filename): self.filename = filename self.filesize = os.path.getsize(filename) # this can throw an exception self.mtime = os.path.getmtime(filename) self.basename = os.path.basename(filename) - self.ebuild = ebuild - self.url = url def write_info(self, outfiledir): - outfilename = "" + outfilename = "%s.INDEX" % (self.basename) try: - (fnum, outfilename) = self.make_outfile(outfiledir) self.out_fd = open(outfilename, "w") self.write_header() self.write_content() @@ -57,7 +54,7 @@ class ArchiveInfo: self.out_fd.write("File-dist-name: %s\n" % (self.basename)) self.out_fd.write("File-dist-size: %s\n" % (self.filesize)) self.out_fd.write("File-dist-isdistfile: 1\n") - self.out_fd.write("File-dist-origin: %s\n" % (self.url)) + #self.out_fd.write("File-dist-origin: %s\n" % (self.url)) #self.out_fd.write("File-dist-cpv: %s\n" % (self.cpv)) #self.out_fd.write("File-dist-cat: %s\n" % (self.cat)) #self.out_fd.write("File-dist-pn: %s\n" % (self.pn)) @@ -66,22 +63,18 @@ class ArchiveInfo: #self.out_fd.write("File-dist-pf: %s\n" % (self.pf)) #self.out_fd.write("File-dist-cpv: %s\n" % (self.cpv)) self.out_fd.write("File-dist-mtime: %s\n" %(self.mtime)) - + distfile = open(self.filename) (md5, sha1) = hash_file(distfile, md5_cons(), sha1_cons()) self.out_fd.write("File-dist-md5: %s\n" % (md5)) self.out_fd.write("File-dist-sha1: %s\n" % (sha1)) distfile.close() - def make_outfile(self, tdir): - import tempfile - outfdname = tempfile.mkstemp(prefix=self.basename, dir=tdir) - return outfdname class TarInfo(ArchiveInfo): def write_content(self): tar = tarfile.TarFile.open(self.filename, 'r') - + file_info = tar.next() filecount = 0 while file_info != None: @@ -141,7 +134,6 @@ def main(): infilename = None outdir = "." - url = None for opt, arg in optlist: if opt == '-h': usage(sys.argv[0]) @@ -150,15 +142,13 @@ def main(): infilename = arg if opt == '-P': outdir = arg - if opt == '-u': - url = arg if not infilename: print "Please specify a filename." else: tar_finished = False try: - t = TarInfo(infilename, url, None) + t = TarInfo(infilename) filename = t.write_info(outdir) tar_finished = True except: @@ -166,14 +156,14 @@ def main(): if tar_finished: sys.exit(0) try: - t = ZipInfo(infilename, url, None) + t = ZipInfo(infilename) filename = t.write_info(outdir) except: print infilename, " could not be opened" def usage(programname): """ Print usage information """ - print "Usage: %s [-h] [-P <dir>] [-f <file>] [-u <url>]" % (programname) + print "Usage: %s [-h] [-P <dir>] [-f <file>]" % (programname) print ''' This script opens the file specified by -f, and writes the index to the directory specified by -P. @@ -181,7 +171,6 @@ Parameters: -h Display this help -f file Path to the file to index, must be present -P path Directory to create the index file in (default: .) - -u url URL to record inside the index ''' |