Make sure repoclosure cache cleaned when running as root
When running repoclosure as root user, it will use other dir instead of the one returned by getCacheDir(). For yum, with --tempcache option could let the cache dir returned by getCacheDir() always be used. For dnf, there's no such an option and we have to handle it specially. JIRA: COMPOSE-3922 Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
parent
90187298f2
commit
242100eb72
@ -94,11 +94,17 @@ def run_repoclosure(compose):
|
||||
|
||||
def _delete_repoclosure_cache_dirs(compose):
|
||||
if 'dnf' == compose.conf["repoclosure_backend"]:
|
||||
from dnf.const import SYSTEM_CACHEDIR
|
||||
from dnf.util import am_i_root
|
||||
from dnf.yum.misc import getCacheDir
|
||||
if am_i_root():
|
||||
top_cache_dir = SYSTEM_CACHEDIR
|
||||
else:
|
||||
top_cache_dir = getCacheDir()
|
||||
else:
|
||||
from yum.misc import getCacheDir
|
||||
top_cache_dir = getCacheDir()
|
||||
|
||||
top_cache_dir = getCacheDir()
|
||||
for name in os.listdir(top_cache_dir):
|
||||
if name.startswith(compose.compose_id):
|
||||
cache_path = os.path.join(top_cache_dir, name)
|
||||
|
@ -21,7 +21,7 @@ from kobo.shortcuts import force_list
|
||||
|
||||
def get_repoclosure_cmd(backend='yum', arch=None, repos=None, lookaside=None):
|
||||
cmds = {
|
||||
'yum': {'cmd': ['/usr/bin/repoclosure'], 'repoarg': '--repoid=%s', 'lookaside': '--lookaside=%s'},
|
||||
'yum': {'cmd': ['/usr/bin/repoclosure', '--tempcache'], 'repoarg': '--repoid=%s', 'lookaside': '--lookaside=%s'},
|
||||
'dnf': {'cmd': ['dnf', 'repoclosure'], 'repoarg': '--repo=%s', 'lookaside': '--repo=%s'},
|
||||
}
|
||||
try:
|
||||
|
@ -14,7 +14,7 @@ from . import helpers
|
||||
class RepoclosureWrapperTestCase(helpers.BaseTestCase):
|
||||
def test_minimal_command(self):
|
||||
self.assertEqual(rc.get_repoclosure_cmd(),
|
||||
['/usr/bin/repoclosure'])
|
||||
['/usr/bin/repoclosure', '--tempcache'])
|
||||
|
||||
def test_minimal_dnf_command(self):
|
||||
self.assertEqual(rc.get_repoclosure_cmd(backend='dnf'),
|
||||
@ -28,7 +28,7 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase):
|
||||
|
||||
def test_multiple_arches(self):
|
||||
self.assertEqual(rc.get_repoclosure_cmd(arch=['x86_64', 'ppc64']),
|
||||
['/usr/bin/repoclosure', '--arch=x86_64', '--arch=ppc64'])
|
||||
['/usr/bin/repoclosure', '--tempcache', '--arch=x86_64', '--arch=ppc64'])
|
||||
|
||||
def test_full_command(self):
|
||||
repos = {'my-repo': '/mnt/koji/repo'}
|
||||
@ -39,11 +39,15 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase):
|
||||
six.assertCountEqual(
|
||||
self,
|
||||
cmd[1:],
|
||||
['--arch=x86_64',
|
||||
'--repofrompath=my-repo,file:///mnt/koji/repo',
|
||||
'--repofrompath=fedora,http://kojipkgs.fp.o/repo',
|
||||
'--repoid=my-repo',
|
||||
'--lookaside=fedora'])
|
||||
[
|
||||
'--tempcache',
|
||||
'--arch=x86_64',
|
||||
'--repofrompath=my-repo,file:///mnt/koji/repo',
|
||||
'--repofrompath=fedora,http://kojipkgs.fp.o/repo',
|
||||
'--repoid=my-repo',
|
||||
'--lookaside=fedora',
|
||||
]
|
||||
)
|
||||
|
||||
def test_full_dnf_command(self):
|
||||
repos = {'my-repo': '/mnt/koji/repo'}
|
||||
@ -72,10 +76,14 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase):
|
||||
six.assertCountEqual(
|
||||
self,
|
||||
cmd[1:],
|
||||
['--repofrompath=local,file:///mnt/koji/repo',
|
||||
'--repofrompath=remote,http://kojipkgs.fp.o/repo',
|
||||
'--repoid=local',
|
||||
'--repoid=remote'])
|
||||
[
|
||||
'--tempcache',
|
||||
'--repofrompath=local,file:///mnt/koji/repo',
|
||||
'--repofrompath=remote,http://kojipkgs.fp.o/repo',
|
||||
'--repoid=local',
|
||||
'--repoid=remote',
|
||||
]
|
||||
)
|
||||
|
||||
def test_expand_lookaside(self):
|
||||
repos = {
|
||||
@ -87,10 +95,14 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase):
|
||||
six.assertCountEqual(
|
||||
self,
|
||||
cmd[1:],
|
||||
['--repofrompath=local,file:///mnt/koji/repo',
|
||||
'--repofrompath=remote,http://kojipkgs.fp.o/repo',
|
||||
'--lookaside=local',
|
||||
'--lookaside=remote'])
|
||||
[
|
||||
'--tempcache',
|
||||
'--repofrompath=local,file:///mnt/koji/repo',
|
||||
'--repofrompath=remote,http://kojipkgs.fp.o/repo',
|
||||
'--lookaside=local',
|
||||
'--lookaside=remote',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class FusExtractorTestCase(helpers.PungiTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user