index: Add --compression-types option
With this option, the compression type of index file can be selected. It is possible to pass multiple types separated by comma. e.g. pisi index --skip-signing --compression-types=bz2,xz
This commit is contained in:
+3
-2
@@ -763,7 +763,9 @@ def info_name(package_name, useinstalldb=False):
|
||||
files = None
|
||||
return metadata, files, repo
|
||||
|
||||
def index(dirs=None, output='pisi-index.xml', skip_sources=False, skip_signing=False):
|
||||
def index(dirs=None, output='pisi-index.xml',
|
||||
skip_sources=False, skip_signing=False,
|
||||
compression=0):
|
||||
"""Accumulate PiSi XML files in a directory, and write an index."""
|
||||
index = pisi.index.Index()
|
||||
index.distribution = None
|
||||
@@ -774,7 +776,6 @@ def index(dirs=None, output='pisi-index.xml', skip_sources=False, skip_signing=F
|
||||
ctx.ui.info(_('* Building index of PiSi files under %s') % repo_dir)
|
||||
index.index(repo_dir, skip_sources)
|
||||
|
||||
compression = pisi.file.File.COMPRESSION_TYPE_XZ
|
||||
sign = None if skip_signing else pisi.file.File.detached
|
||||
index.write(output, sha1sum=True, compress=compression, sign=sign)
|
||||
ctx.ui.info(_('* Index file written'))
|
||||
|
||||
+15
-1
@@ -57,6 +57,12 @@ class Index(command.Command):
|
||||
default='pisi-index.xml',
|
||||
help=_("Index output file"))
|
||||
|
||||
group.add_option("--compression-types",
|
||||
action="store",
|
||||
default="xz",
|
||||
help=_("Comma-separated compression types "
|
||||
"for index file"))
|
||||
|
||||
group.add_option("--skip-sources",
|
||||
action="store_true",
|
||||
default=False,
|
||||
@@ -73,7 +79,15 @@ class Index(command.Command):
|
||||
self.init(database=True, write=False)
|
||||
|
||||
from pisi.api import index
|
||||
from pisi.file import File
|
||||
|
||||
ctypes = {"bz2": File.COMPRESSION_TYPE_BZ2,
|
||||
"xz": File.COMPRESSION_TYPE_XZ}
|
||||
compression = 0
|
||||
for type_str in ctx.get_option("compression_types").split(","):
|
||||
compression |= ctypes.get(type_str, 0)
|
||||
|
||||
index(self.args or ["."], ctx.get_option('output'),
|
||||
skip_sources=ctx.get_option('skip_sources'),
|
||||
skip_signing=ctx.get_option('skip_signing'))
|
||||
skip_signing=ctx.get_option('skip_signing'),
|
||||
compression=compression)
|
||||
|
||||
Reference in New Issue
Block a user