From b8d105ce8d903343d7f5a0c727aab37a528d7417 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Feb 21 2017 12:55:14 +0000 Subject: Use createrepo_c for "current", declare old createrepo as "legacy" What is new is old again. Declare createrepo python module as legacy and use "current" for createrepo_c. Signed-off-by: Neal Gompa --- diff --git a/mash.spec b/mash.spec index 0f60f2b..dffee68 100644 --- a/mash.spec +++ b/mash.spec @@ -9,8 +9,13 @@ License: GPLv2 URL: https://pagure.io/mash Source0: http://fedorahosted.org/releases/m/a/mash/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Requires: yum, createrepo, koji +Requires: yum, koji Requires: python2-multilib +%if 0%{?rhel} >= 6 || 0%{?fedora} +Requires: %{_bindir}/createrepo_c +%else +Requires: createrepo +%endif Conflicts: pungi < 1.0.0 BuildRequires: python-devel BuildArch: noarch diff --git a/mash/metadata.py b/mash/metadata.py index de5050b..4d58871 100644 --- a/mash/metadata.py +++ b/mash/metadata.py @@ -9,11 +9,12 @@ import rpm import rpmUtils import rpmUtils.miscutils -usenew = True -try: +uselegacy = True +if os.path.isfile("/usr/bin/createrepo_c"): + uselegacy = False +else: import createrepo -except: - usenew = False + uselegacy = True def _make_ancient(path, excludes, previous, logger): @@ -34,10 +35,10 @@ def _make_ancient(path, excludes, previous, logger): return status -class MetadataOld: +class MetadataCurrent: def __init__(self, logger): - self.args = ['createrepo', '--update', '-q'] + self.args = ['createrepo_c', '--update', '-q'] self.previous = None self.logger = logger self.excludes = [] @@ -67,27 +68,36 @@ class MetadataOld: self.args.append(compress_type) def set_hash(self, hashtype): - # Sorry, can't do that here. - pass + self.args.append('--checksum') + self.args.append(hashtype) def set_skipstat(self, skip): if skip: self.args.append('--skip-stat') def set_delta(self, deltapaths, max_delta_rpm_size, max_delta_rpm_age, delta_workers): - # Sorry, can't do that here. + #self.args.append('--deltas') + #self.args.append('--max-delta-rpm-size') + #self.args.append(max_delta_rpm_size) + # FIXME: Following is not yet implemented + #self.args.append('--max-delta-rpm-age') + #self.args.append(max_delta_rpm_age) + # FIXME: Following is not yet implemented + #self.args.append('--delta-workers') + #self.args.append(delta_workers) + ## Sorry, can't do that here. pass def set_previous(self, previous): self.previous = previous def set_distro_tags(self, distro_tags): - # Sorry, can't do that here. - pass + self.args.append('--distro') + self.args.append(distro_tags) def set_content_tags(self, content_tags): - # Sorry, can't do that here. - pass + self.args.append('--content') + self.args.append(content_tags) def run(self, path): self.args.append(path) @@ -100,14 +110,14 @@ class MetadataOld: "Couldn't copy repodata from %s" % (self.previous,)) pid = os.fork() if not pid: - os.execv("/usr/bin/createrepo", self.args) + os.execv("/usr/bin/createrepo_c", self.args) else: (p, status) = os.waitpid(pid, 0) if self.ancient: _make_ancient(path, self.excludes, self.previous, self.logger) -class MetadataNew: +class MetadataLegacy: def __init__(self, logger): self.conf = createrepo.MetaDataConfig() @@ -238,10 +248,10 @@ class MetadataNew: class Metadata: def __init__(self, logger): - if usenew: - self.obj = MetadataNew(logger) + if uselegacy: + self.obj = MetadataLegacy(logger) else: - self.obj = MetadataOld(logger) + self.obj = MetadataCurrent(logger) def set_ancient(self, ancient): self.obj.set_ancient(ancient)