- fix: make using pisi-index.xml (without .bz2 suffix) possible.

- fix: generate pisi-index.xml.sha1sum also
- add an option to skip index signing
This commit is contained in:
Barış Metin
2006-04-17 14:48:57 +00:00
parent bcac1a2bb2
commit d65ef53cbc
4 changed files with 38 additions and 13 deletions
+6 -2
View File
@@ -295,7 +295,7 @@ def check(package):
ctx.ui.info("OK", False) ctx.ui.info("OK", False)
return corrupt return corrupt
def index(dirs=None, output = 'pisi-index.xml', skip_sources=False): def index(dirs=None, output='pisi-index.xml', skip_sources=False, skip_signing=False):
"""accumulate PISI XML files in a directory""" """accumulate PISI XML files in a directory"""
index = Index() index = Index()
if not dirs: if not dirs:
@@ -304,7 +304,11 @@ def index(dirs=None, output = 'pisi-index.xml', skip_sources=False):
repo_dir = str(repo_dir) repo_dir = str(repo_dir)
ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir) ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir)
index.index(repo_dir, skip_sources) index.index(repo_dir, skip_sources)
index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached)
if skip_signing:
index.write(output, sha1sum=True, compress=File.bz2, sign=None)
else:
index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached)
ctx.ui.info(_('* Index file written')) ctx.ui.info(_('* Index file written'))
def add_repo(name, indexuri): def add_repo(name, indexuri):
+9 -2
View File
@@ -730,16 +730,23 @@ source and binary packages.
self.parser.add_option("-S", "--skip-sources", action="store_true", self.parser.add_option("-S", "--skip-sources", action="store_true",
default=False, default=False,
help=_("do not index pisi spec files.")) help=_("do not index pisi spec files."))
self.parser.add_option("-G", "--skip-signing", action="store_true",
default=False,
help=_("do not sign index."))
def run(self): def run(self):
self.init(database = True, write = False) self.init(database = True, write = False)
from pisi.api import index from pisi.api import index
if len(self.args)>0: if len(self.args)>0:
index(self.args, ctx.get_option('output'), skip_sources = ctx.get_option('skip_sources')) index(self.args, ctx.get_option('output'),
skip_sources = ctx.get_option('skip_sources'),
skip_signing = ctx.get_option('skip_signing'))
elif len(self.args)==0: elif len(self.args)==0:
ctx.ui.info(_('Indexing current directory.')) ctx.ui.info(_('Indexing current directory.'))
index(['.'], ctx.get_option('output'), skip_sources = ctx.get_option('skip_sources')) index(['.'], ctx.get_option('output'),
skip_sources = ctx.get_option('skip_sources'),
skip_signing = ctx.get_option('skip_signing'))
self.finalize() self.finalize()
+10 -6
View File
@@ -162,13 +162,10 @@ class File:
"this method must be called at the end of operation" "this method must be called at the end of operation"
self.__file__.close() self.__file__.close()
if self.mode == File.write: if self.mode == File.write:
compressed_file = None
if self.compress == File.bz2: if self.compress == File.bz2:
bz2file = self.localfile + ".bz2" compressed_file = self.localfile + ".bz2"
bz2.BZ2File(bz2file, "w").write(open(self.localfile, "r").read()) bz2.BZ2File(compressed_file, "w").write(open(self.localfile, "r").read())
# FIXME: I hate side effects, but this is designed
# that way :(. -- baris
self.localfile = bz2file
elif self.compress == File.sevenzip: elif self.compress == File.sevenzip:
raise Error(_("sevenzip compression not supported yet")) raise Error(_("sevenzip compression not supported yet"))
@@ -178,9 +175,16 @@ class File:
cs = file(self.localfile + '.sha1sum', 'w') cs = file(self.localfile + '.sha1sum', 'w')
cs.write(sha1) cs.write(sha1)
cs.close() cs.close()
if compressed_file:
sha1 = pisi.util.sha1_file(compressed_file)
cs = file(compressed_file + '.sha1sum', 'w')
cs.write(sha1)
cs.close()
if self.sign==File.detached: if self.sign==File.detached:
pisi.util.run_batch('gpg --detach-sig ' + self.localfile) pisi.util.run_batch('gpg --detach-sig ' + self.localfile)
if compressed_file:
pisi.util.run_batch('gpg --detach-sig ' + compressed_file)
@staticmethod @staticmethod
def check_signature(uri, transfer_dir, sign=detached): def check_signature(uri, transfer_dir, sign=detached):
+12 -2
View File
@@ -67,8 +67,18 @@ class Index(XmlFile):
urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w') urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w')
urlfile.write(filename) # uri urlfile.write(filename) # uri
self.read(filename, tmpDir=tmpdir, sha1sum=not force,
compress=File.bz2, sign=File.detached) # FIXME: This is a mess, we have a compress flag and we have to
# use it with filename extention. Because File.decompress also
# checks the extension. We really have to go all over the code
# and simplify it. -- baris
if filename.endswith(".bz2"):
self.read(filename, tmpDir=tmpdir, sha1sum=not force,
compress=File.bz2, sign=File.detached)
else:
self.read(filename, tmpDir=tmpdir, sha1sum=not force,
compress=None, sign=File.detached)
if not repo: if not repo:
repo = self.distribution.name() repo = self.distribution.name()