Delete repoclosure cache

JIRA: COMPOSE-2565
Merges: https://pagure.io/pungi/pull-request/1253
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2019-08-13 20:15:35 +08:00 committed by Lubomír Sedlář
parent eeaee1c20f
commit 048698d885
2 changed files with 27 additions and 0 deletions

View File

@ -16,6 +16,7 @@
import glob
import os
import shutil
from kobo.shortcuts import run
@ -99,6 +100,17 @@ def _run_repoclosure_cmd(compose, repos, lookaside, arches, logfile):
# https://github.com/release-engineering/kobo/pull/26
run(cmd, logfile=logfile, workdir=tmp_dir, show_cmd=True)
# Delete cache dir
if 'dnf' == compose.conf["repoclosure_backend"]:
from dnf.yum.misc import getCacheDir
else:
from yum.misc import getCacheDir
top_cache_dir = getCacheDir()
for repo_id in repos.keys():
cache_dir = os.path.join(top_cache_dir, repo_id)
if os.path.isdir(cache_dir):
shutil.rmtree(cache_dir)
def check_image_sanity(compose):
"""

View File

@ -16,6 +16,18 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import pungi.phases.test as test_phase
from tests.helpers import DummyCompose, PungiTestCase, touch, mk_boom
try:
import dnf
HAS_DNF = True
except ImportError:
HAS_DNF = False
try:
import yum
HAS_YUM = True
except ImportError:
HAS_YUM = False
PAD = b'\0' * 100
UNBOOTABLE_ISO = (b'\0' * 0x8001) + b'CD001' + PAD
@ -305,6 +317,7 @@ class TestRepoclosure(PungiTestCase):
self.assertEqual(mock_grc.call_args_list, [])
@unittest.skipUnless(HAS_YUM, 'YUM is not available')
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
@mock.patch('pungi.phases.test.run')
def test_repoclosure_default_backend(self, mock_run, mock_grc):
@ -326,6 +339,7 @@ class TestRepoclosure(PungiTestCase):
mock.call(backend='yum', arch=['x86_64', 'noarch'], lookaside={},
repos=self._get_repo(compose.compose_id, 'Everything', 'x86_64'))])
@unittest.skipUnless(HAS_DNF, 'DNF is not available')
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
@mock.patch('pungi.phases.test.run')
def test_repoclosure_dnf_backend(self, mock_run, mock_grc):
@ -384,6 +398,7 @@ class TestRepoclosure(PungiTestCase):
with self.assertRaises(RuntimeError):
test_phase.run_repoclosure(compose)
@unittest.skipUnless(HAS_DNF, 'DNF is not available')
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
@mock.patch('pungi.phases.test.run')
def test_repoclosure_overwrite_options_creates_correct_commands(self, mock_run, mock_grc):