Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,9 @@ TDNFAddCmdLinePackages(
queue_push(pQueueGoal, id);
}

repo_internalize(pTdnf->pSolvCmdLineRepo);
pool_addfileprovides(pSack->pPool);
pool_createwhatprovides(pSack->pPool);
repo_internalize(pTdnf->pSolvCmdLineRepo);

cleanup:
TDNF_SAFE_FREE_MEMORY(pszRPMPath);
Expand Down
1 change: 1 addition & 0 deletions pytests/config.json.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"packages_server": "packages.broadcom.com",
"project_name": "@PROJECT_NAME@",
"project_version": "@VERSION@",
"specs_dir": "@CMAKE_SOURCE_DIR@/pytests/repo",
Expand Down
9 changes: 9 additions & 0 deletions pytests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ def get_cached_package_sizes(self, cache_dir):
def floats_approx_equal(self, x, y, tol=500):
return abs(x - y) <= tol

def server_reachable(self, host, port=443, timeout=5):
try:
addr = socket.gethostbyname(host)
sock = socket.create_connection((addr, port), timeout)
sock.close()
return True
except (socket.gaierror, OSError, TimeoutError):
return False


@pytest.fixture(scope='session')
def utils():
Expand Down
49 changes: 49 additions & 0 deletions pytests/tests/test_installroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
#

import os
import glob
import shutil
import pytest
import fnmatch
import tempfile
import platform

INSTALLROOT = '/root/installroot'
REPOFILENAME = 'photon-test.repo'
RELEASE_VER = '5.0'

REPODIR = '/root/yum.repos.d'
REPONAME = 'reposdir-test'
Expand Down Expand Up @@ -128,3 +132,48 @@ def test_setopt_reposdir_with_installroot(utils):
assert REPONAME in "\n".join(ret['stdout'])

shutil.rmtree(INSTALLROOT)


def test_installroot_local_rpms_disablerepo_after_download(utils):
repo_server = utils.config["packages_server"]
assert repo_server

if not utils.server_reachable(repo_server):
pytest.skip('Package repo server unavailable')

workdir = tempfile.mkdtemp(prefix='test-tdnf-')
try:
installroot = os.path.join(workdir, 'installroot')
rpm_repo = os.path.join(workdir, 'rpm-repo')
os.makedirs(rpm_repo, exist_ok=True)
os.makedirs(installroot, exist_ok=True)

arch = platform.machine()
repo_url = f"https://{repo_server}/photon/{RELEASE_VER}/photon_updates_{RELEASE_VER}_{arch}"

ret = utils.run(
['tdnf', 'install', '-y', 'bash',
'--refresh', '--downloadonly',
'--releasever', RELEASE_VER,
'--installroot', installroot,
'--downloaddir', rpm_repo,
'--nogpgcheck',
'--disablerepo=*', '--enablerepo=pkgs',
f'--repofrompath=pkgs,{repo_url}'],
cwd=workdir
)
assert ret['retval'] == 0, 'downloadonly bash failed: {}'.format(ret.get('stderr', []))

rpms = glob.glob(os.path.join(rpm_repo, '*.rpm'))
assert len(rpms) >= 1, 'no RPMs downloaded into rpm-repo'

ret = utils.run(
['tdnf', 'install', '-y', '--refresh', '--releasever', RELEASE_VER,
'--installroot', installroot, '--disablerepo=*', '--nogpgcheck'] + rpms,
cwd=workdir
)
assert ret['retval'] == 0, (
'install from local RPMs into installroot with --disablerepo=* failed: {}'
).format(ret.get('stderr', []))
finally:
shutil.rmtree(workdir, ignore_errors=True)
Loading