createrepo: Add option to use xz compression

This patch adds a new config option createrepo_use_xz, which when set to
true will cause createrepo to compress sqlite databases with xz. The
default setting is False.

Fixes: #387
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-09-12 11:01:45 +02:00
parent 10b93796bd
commit bf46048cbf
6 changed files with 57 additions and 12 deletions

View file

@ -31,7 +31,8 @@ class CreateRepoWrapperTest(unittest.TestCase):
update=False, update_md_path='/test/md_path', skip_stat=True, checkts=True,
split=True, pretty=False, database=False, checksum='sha256', unique_md_filenames=False,
distro='Fedora', content=['c1', 'c2'], repo=['r1', 'r2'], revision='rev', deltas=True,
oldpackagedirs='/test/old', num_deltas=2, workers=3, outputdir='/test/output'
oldpackagedirs='/test/old', num_deltas=2, workers=3, outputdir='/test/output',
use_xz=True
)
self.maxDiff = None
@ -43,7 +44,7 @@ class CreateRepoWrapperTest(unittest.TestCase):
'--checksum=sha256', '--distro=Fedora', '--simple-md-filenames', '--no-database',
'--content=c1', '--content=c2', '--repo=r1', '--repo=r2', '--revision=rev',
'--deltas', '--oldpackagedirs=/test/old', '--num-deltas=2', '--workers=3',
'--outputdir=/test/output', '--verbose'])
'--outputdir=/test/output', '--verbose', '--xz'])
def test_get_createrepo_cmd_minimal(self):
repo = CreaterepoWrapper(False)

View file

@ -110,7 +110,7 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/x86_64/os',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo',
deltas=False, oldpackagedirs=None)])
deltas=False, oldpackagedirs=None, use_xz=False)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n')
@ -138,7 +138,7 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/source/tree',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/global/repo',
deltas=False, oldpackagedirs=None)])
deltas=False, oldpackagedirs=None, use_xz=False)])
with open(list_file) as f:
self.assertItemsEqual(
f.read().strip().split('\n'),
@ -169,7 +169,7 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/x86_64/debug/tree',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo',
deltas=False, oldpackagedirs=None)])
deltas=False, oldpackagedirs=None, use_xz=False)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-debuginfo-4.3.30-2.fc21.x86_64.rpm\n')
@ -198,7 +198,7 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/x86_64/os',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo',
deltas=False, oldpackagedirs=None)])
deltas=False, oldpackagedirs=None, use_xz=False)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n')
@ -228,7 +228,36 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/x86_64/os',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo',
deltas=False, oldpackagedirs=None)])
deltas=False, oldpackagedirs=None, use_xz=False)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n')
@mock.patch('pungi.phases.createrepo.run')
@mock.patch('pungi.phases.createrepo.CreaterepoWrapper')
def test_variant_repo_rpms_with_xz(self, CreaterepoWrapperCls, run):
compose = DummyCompose(self.topdir, {
'createrepo_checksum': 'sha256',
'createrepo_use_xz': True,
})
compose.DEBUG = False
compose.has_comps = False
repo = CreaterepoWrapperCls.return_value
copy_fixture('server-rpms.json', compose.paths.compose.metadata('rpms.json'))
create_variant_repo(compose, 'x86_64', compose.variants['Server'], 'rpm')
list_file = self.topdir + '/work/x86_64/repo_package_list/Server.x86_64.rpm.conf'
self.assertEqual(CreaterepoWrapperCls.mock_calls[0],
mock.call(createrepo_c=True))
self.assertItemsEqual(
repo.get_createrepo_cmd.mock_calls,
[mock.call(self.topdir + '/compose/Server/x86_64/os', checksum='sha256',
database=True, groupfile=None, workers=3,
outputdir=self.topdir + '/compose/Server/x86_64/os',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo', deltas=False,
oldpackagedirs=None, use_xz=True)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n')
@ -259,7 +288,8 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/x86_64/os',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo', deltas=True,
oldpackagedirs=self.topdir + '/old/test-1.0-20151203.0/compose/Server/x86_64/os')])
oldpackagedirs=self.topdir + '/old/test-1.0-20151203.0/compose/Server/x86_64/os',
use_xz=False)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n')
@ -290,7 +320,8 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/source/tree',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/global/repo', deltas=True,
oldpackagedirs=self.topdir + '/old/test-1.0-20151203.0/compose/Server/source/tree')])
oldpackagedirs=self.topdir + '/old/test-1.0-20151203.0/compose/Server/source/tree',
use_xz=False)])
with open(list_file) as f:
self.assertItemsEqual(
f.read().strip().split('\n'),
@ -323,7 +354,8 @@ class TestCreateRepoThread(PungiTestCase):
outputdir=self.topdir + '/compose/Server/x86_64/debug/tree',
pkglist=list_file, skip_stat=True, update=True,
update_md_path=self.topdir + '/work/x86_64/repo', deltas=True,
oldpackagedirs=self.topdir + '/old/test-1.0-20151203.0/compose/Server/x86_64/debug/tree')])
oldpackagedirs=self.topdir + '/old/test-1.0-20151203.0/compose/Server/x86_64/debug/tree',
use_xz=False)])
with open(list_file) as f:
self.assertEqual(f.read(), 'Packages/b/bash-debuginfo-4.3.30-2.fc21.x86_64.rpm\n')