diff --git a/pisi/api.py b/pisi/api.py index 77ff5803..f46d359d 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -295,7 +295,7 @@ def check(package): ctx.ui.info("OK", False) 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""" index = Index() if not dirs: @@ -304,7 +304,11 @@ def index(dirs=None, output = 'pisi-index.xml', skip_sources=False): repo_dir = str(repo_dir) ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir) 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')) def add_repo(name, indexuri): diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index c1a385b7..7f53c5d3 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -730,16 +730,23 @@ source and binary packages. self.parser.add_option("-S", "--skip-sources", action="store_true", default=False, 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): self.init(database = True, write = False) from pisi.api import index 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: 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() diff --git a/pisi/file.py b/pisi/file.py index 7bdf7ad1..ac904c3e 100644 --- a/pisi/file.py +++ b/pisi/file.py @@ -162,13 +162,10 @@ class File: "this method must be called at the end of operation" self.__file__.close() if self.mode == File.write: + compressed_file = None if self.compress == File.bz2: - bz2file = self.localfile + ".bz2" - bz2.BZ2File(bz2file, "w").write(open(self.localfile, "r").read()) - - # FIXME: I hate side effects, but this is designed - # that way :(. -- baris - self.localfile = bz2file + compressed_file = self.localfile + ".bz2" + bz2.BZ2File(compressed_file, "w").write(open(self.localfile, "r").read()) elif self.compress == File.sevenzip: raise Error(_("sevenzip compression not supported yet")) @@ -178,10 +175,17 @@ class File: cs = file(self.localfile + '.sha1sum', 'w') cs.write(sha1) 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: pisi.util.run_batch('gpg --detach-sig ' + self.localfile) - + if compressed_file: + pisi.util.run_batch('gpg --detach-sig ' + compressed_file) + @staticmethod def check_signature(uri, transfer_dir, sign=detached): if sign==File.detached: diff --git a/pisi/index.py b/pisi/index.py index fd9448de..074a26fa 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -67,8 +67,18 @@ class Index(XmlFile): urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w') 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: repo = self.distribution.name()