Skip to content

Commit

Permalink
Merge pull request #2116 from lethliel/createrepo_c-integration
Browse files Browse the repository at this point in the history
[backend] bs_publish: integrate createrepo_c / modifyrepo_c
  • Loading branch information
mlschroe committed Sep 9, 2016
2 parents 0f9603c + 6dcd3dc commit 557fc52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/backend/BSConfig.pm.template
Expand Up @@ -220,4 +220,9 @@ if (-r $hostconfig) {
# return 1;
#}

# use createrepo_c instead of createrepo
#our $createrepo = '/usr/bin/createrepo_c';
# use modifyrepo_c instead of modifyrepo
#our $modifyrepo = '/usr/bin/modifyrepo_c';

1;
24 changes: 15 additions & 9 deletions src/backend/bs_publish
Expand Up @@ -371,6 +371,8 @@ sub createrepo_rpmmd {
my $prp_ext = "$projid/$repoid";
$prp_ext =~ s/:/:\//g;
print " running createrepo\n";
my $createrepo_bin = $BSConfig::createrepo ? $BSConfig::createrepo : 'createrepo';
my $modifyrepo_bin = $BSConfig::modifyrepo ? $BSConfig::modifyrepo : 'modifyrepo';
# cleanup files
unlink("$extrep/repodata/repomd.xml.asc");
unlink("$extrep/repodata/repomd.xml.key");
Expand Down Expand Up @@ -403,11 +405,11 @@ sub createrepo_rpmmd {
if (-f "$extrep/repodata/repomd.xml") {
push @updateargs, '--update';
}
if (qsystem('createrepo', '-q', '-c', "$extrep/repocache", @updateargs, @createrepoargs, @legacyargs, $extrep)) {
if (qsystem($createrepo_bin, '-q', '-c', "$extrep/repocache", @updateargs, @createrepoargs, @legacyargs, $extrep)) {
die(" createrepo failed: $?\n") unless @updateargs;
print(" createrepo failed: $?\n");
print " re-running without extra options\n";
qsystem('createrepo', '-q', '-c', "$extrep/repocache", @createrepoargs, @legacyargs, $extrep) && die(" createrepo failed again: $?\n");
qsystem($createrepo_bin, '-q', '-c', "$extrep/repocache", @createrepoargs, @legacyargs, $extrep) && die(" createrepo failed again: $?\n");
}
unlink("$extrep/repodata/$_") for grep {/updateinfo\.xml/} @oldrepodata;
if (@{$data->{'updateinfos'} || []}) {
Expand All @@ -421,20 +423,20 @@ sub createrepo_rpmmd {
}
}
writexml("$extrep/repodata/updateinfo.xml", undef, {'update' => $updateinfos}, $BSXML::updateinfo);
qsystem('modifyrepo', "$extrep/repodata/updateinfo.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/updateinfo.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/updateinfo.xml");
}
unlink("$extrep/repodata/$_") for grep {/appdata\.xml/ || /app-icons/} @oldrepodata;
if (%{$data->{'appdatas'} || {}}) {
create_appdata_files("$extrep/repodata", $data->{'appdatas'});
if (-e "$extrep/repodata/appdata.xml") {
print " adding appdata.xml to repodata\n";
qsystem('modifyrepo', "$extrep/repodata/appdata.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/appdata.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/appdata.xml");
}
if (-e "$extrep/repodata/app-icons.tar") {
print " adding app-icons.tar to repodata\n";
qsystem('modifyrepo', "$extrep/repodata/app-icons.tar", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/app-icons.tar", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/app-icons.tar");
}
}
Expand All @@ -457,12 +459,12 @@ sub createrepo_rpmmd {
my @mergeddeltas = map {$mergeddeltas{$_}} sort keys %mergeddeltas;
if ($options{'deltainfo'}) {
writexml("$extrep/repodata/deltainfo.xml", undef, {'newpackage' => \@mergeddeltas}, $BSXML::deltainfo);
qsystem('modifyrepo', "$extrep/repodata/deltainfo.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/deltainfo.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/deltainfo.xml");
}
if ($options{'prestodelta'}) {
writexml("$extrep/repodata/prestodelta.xml", undef, {'newpackage' => \@mergeddeltas}, $BSXML::prestodelta);
qsystem('modifyrepo', "$extrep/repodata/prestodelta.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/prestodelta.xml", "$extrep/repodata", @legacyargs) && die(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/prestodelta.xml");
}
}
Expand Down Expand Up @@ -864,6 +866,8 @@ sub createpatterns_rpmmd {
my $patterns = $data->{'patterns'};
return unless @{$patterns || []};

my $modifyrepo_bin = $BSConfig::modifyrepo ? $BSConfig::modifyrepo : 'modifyrepo';

# create patterns data structure
my @pats;
for my $pattern (@$patterns) {
Expand All @@ -880,7 +884,7 @@ sub createpatterns_rpmmd {
# the default in newer createrepos
push @legacyargs, '--unique-md-filenames', '--checksum=sha256';
}
qsystem('modifyrepo', "$extrep/repodata/patterns.xml", "$extrep/repodata", @legacyargs) && print(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/patterns.xml", "$extrep/repodata", @legacyargs) && print(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/patterns.xml");

# for my $pattern (@{$patterns || []}) {
Expand Down Expand Up @@ -916,6 +920,8 @@ sub createpatterns_comps {
my $patterns = $data->{'patterns'};
return unless @{$patterns || []};

my $modifyrepo_bin = $BSConfig::modifyrepo ? $BSConfig::modifyrepo : 'modifyrepo';

# create comps data structure
my @grps;
for my $pattern (@$patterns) {
Expand Down Expand Up @@ -953,7 +959,7 @@ sub createpatterns_comps {
# the default in newer createrepos
push @legacyargs, '--unique-md-filenames', '--checksum=sha256';
}
qsystem('modifyrepo', "$extrep/repodata/group.xml", "$extrep/repodata", @legacyargs) && print(" modifyrepo failed: $?\n");
qsystem($modifyrepo_bin, "$extrep/repodata/group.xml", "$extrep/repodata", @legacyargs) && print(" modifyrepo failed: $?\n");
unlink("$extrep/repodata/group.xml");

# re-sign changed repomd.xml file
Expand Down

0 comments on commit 557fc52

Please sign in to comment.