- 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:
+6
-2
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
+11
-7
@@ -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:
|
||||
|
||||
+12
-2
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user