Skip to content

Commit

Permalink
Merge 902b83d into 41ab619
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Mar 29, 2016
2 parents 41ab619 + 902b83d commit 5c816a5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
38 changes: 38 additions & 0 deletions reprounzip/reprounzip/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,44 @@ def get_parameter(section):
' },\n'
' "name": "Debian 8 \'Jessie\'"\n'
' }\n'
' },\n'
' "centos": {\n'
' "versions": [\n'
' {\n'
' "version": "^5\\\\.",\n'
' "distribution": "centos",\n'
' "architectures": {\n'
' "i686": "bento/centos-5.11-i386",\n'
' "x86_64": "bento/centos-5.11"\n'
' },\n'
' "name": "CentOS 5.11"\n'
' },\n'
' {\n'
' "version": "^6\\\\.",\n'
' "distribution": "centos",\n'
' "architectures": {\n'
' "i686": "bento/centos-6.7-i386",\n'
' "x86_64": "bento/centos-6.7"\n'
' },\n'
' "name": "CentOS 6.7"\n'
' },\n'
' {\n'
' "version": "^7\\\\.",\n'
' "distribution": "centos",\n'
' "architectures": {\n'
' "x86_64": "bento/centos-7.2"\n'
' },\n'
' "name": "CentOS 7.2"\n'
' }\n'
' ],\n'
' "default": {\n'
' "distribution": "centos",\n'
' "architectures": {\n'
' "i686": "bento/centos-6.7-i386",\n'
' "x86_64": "bento/centos-6.7"\n'
' },\n'
' "name": "CentOS 6.7"\n'
' }\n'
' }\n'
' }\n'
' }\n'
Expand Down
33 changes: 30 additions & 3 deletions reprozip/reprozip/tracer/linux_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,41 @@ def _create_package(self, pkgname):
return Package(pkgname, version, size=size)


class RpmManager(PkgManager):
"""Package identifier for rpm-based systems (Fedora, CentOS).
"""
def _get_package_for_file(self, filename):
p = subprocess.Popen(['rpm', '-qf', filename.path,
'--qf', '%{NAME}'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
return None
return out.strip().decode('iso-8859-1')

def _create_package(self, pkgname):
p = subprocess.Popen(['rpm', '-q', pkgname,
'--qf', '%{VERSION}-%{RELEASE} %{SIZE}'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
assert p.returncode == 0
version, size = out.strip().decode('iso-8859-1').rsplit(' ', 1)
size = int(size)
return Package(pkgname, version, size=size)


def identify_packages(files):
"""Organizes the files, using the distribution's package manager.
"""
distribution = platform.linux_distribution()[0].lower()
if distribution == 'ubuntu':
manager = DpkgManager()
elif distribution == 'debian':
if distribution in ('debian', 'ubuntu'):
manager = DpkgManager()
elif (distribution in ('centos', 'centos linux',
'fedora', 'scientific linux') or
distribution.startswith('red hat')):
manager = RpmManager()
else:
return files, []

Expand Down

0 comments on commit 5c816a5

Please sign in to comment.