Skip to content

Commit

Permalink
obey baseurl when downloading packages
Browse files Browse the repository at this point in the history
Bug: 1448768
Change-Id: I859a13eed92e3e2b2402c10a2c8c1d9c89779a85
  • Loading branch information
danc86 committed May 26, 2017
1 parent 8fcc13a commit 481a6bf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
34 changes: 34 additions & 0 deletions acceptance_tests/test_check_conflicts.py
Expand Up @@ -5,6 +5,7 @@
# (at your option) any later version.

import shutil
import subprocess
import rpm
import rpmfluff
import os.path
Expand Down Expand Up @@ -298,3 +299,36 @@ def cleanUp():
assert exitcode == 0
assert err == ''
assert out == ''


# https://bugzilla.redhat.com/show_bug.cgi?id=1448768
def test_obeys_xml_base_when_downloading_packages(request, tmpdir, dir_server):
p2 = rpmfluff.SimpleRpmBuild('b', '0.1', '1', ['x86_64'])
p2.add_installed_file(installPath='usr/share/thing',
sourceFile=rpmfluff.SourceFile('thing', 'same content\n'))
p2.make()

# Set up a repo at http://$dirserver/therepo/ pointing at packages stored
# in http://$dirserver/thepackages/ using xml:base.
dir_server.basepath = tmpdir.strpath
shutil.copy(p2.get_built_rpm('x86_64'), tmpdir.mkdir('thepackages').strpath)
subprocess.check_output(['createrepo_c',
'--baseurl={}/thepackages'.format(dir_server.url),
'--outputdir=.',
'../thepackages'],
stderr=subprocess.STDOUT, cwd=tmpdir.mkdir('therepo').strpath)

p1 = rpmfluff.SimpleRpmBuild('a', '0.1', '1', ['x86_64'])
p1.add_installed_file(installPath='usr/share/thing',
sourceFile=rpmfluff.SourceFile('thing', 'same content\n'))
p1.make()

def cleanUp():
shutil.rmtree(p2.get_base_dir())
shutil.rmtree(p1.get_base_dir())
request.addfinalizer(cleanUp)

exitcode, out, err = run_rpmdeplint(['rpmdeplint', 'check-conflicts',
'--repo=base,{}/therepo'.format(dir_server.url),
p1.get_built_rpm('x86_64')])
assert exitcode == 0
3 changes: 2 additions & 1 deletion rpmdeplint/__init__.py
Expand Up @@ -165,7 +165,8 @@ def download_package(self, package):
repo = self.repos_by_name[package.reponame]
checksum_type = hawkey.chksum_name(package.chksum[0])
checksum = binascii.hexlify(package.chksum[1]).decode('ascii')
return repo.download_package(package.location, checksum_type=checksum_type, checksum=checksum)
return repo.download_package(package.location, package.baseurl,
checksum_type=checksum_type, checksum=checksum)

def try_to_install(self, *packages):
"""
Expand Down
3 changes: 2 additions & 1 deletion rpmdeplint/repodata.py
Expand Up @@ -209,13 +209,14 @@ def clean_expired_cache(self, root_path):
if os.path.isfile(file_path):
os.remove(file_path)

def download_package(self, location, checksum_type, checksum):
def download_package(self, location, baseurl, checksum_type, checksum):
if self.librepo_handle.local:
local_path = os.path.join(self._root_path, location)
logger.debug('Using package %s from local filesystem directly', local_path)
return local_path
logger.debug('Loading package %s from repo %s', location, self.name)
target = librepo.PackageTarget(location,
base_url=baseurl,
checksum_type=librepo.checksum_str_to_type(checksum_type),
checksum=checksum,
dest=self._root_path,
Expand Down

0 comments on commit 481a6bf

Please sign in to comment.