Skip to content

Commit

Permalink
Merge pull request #13723 from adrianschroeter/sha512
Browse files Browse the repository at this point in the history
[backend] Add option to use sha512 for repomd metadata
  • Loading branch information
adrianschroeter authored Jan 18, 2023
2 parents 86b4a8b + 636d5a4 commit 32b14f2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/backend/bs_publish
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ sub addsizechecksum {
'sha' => 'SHA-1',
'sha1' => 'SHA-1',
'sha256' => 'SHA-256',
'sha512' => 'SHA-512',
);
if ($known{$sum}) {
my $ctx = Digest->new($known{$sum});
Expand Down Expand Up @@ -618,7 +619,9 @@ sub createrepo_rpmmd {
push @createrepoargs, '--content', 'update' if ($repoinfo->{'projectkind'} || '') eq 'maintenance_release';
push @createrepoargs, '--filelists_ext' if $options{'filelists_ext'};
my @legacyargs;
if ($options{'legacy'}) {
if ($options{'sha512'}) {
push @legacyargs, '--simple-md-filenames', '--checksum=sha512';
} elsif ($options{'legacy'}) {
push @legacyargs, '--simple-md-filenames', '--checksum=sha';
} else {
# the default in newer createrepos
Expand Down Expand Up @@ -702,7 +705,10 @@ sub createrepo_rpmmd {
# things are a bit complex, as we have to merge the deltas, and we also have to add the checksum
my %mergeddeltas;
for my $d (values(%{$data->{'deltainfos'}})) {
addsizechecksum("$extrep/$d->{'delta'}->[0]->{'filename'}", $d->{'delta'}->[0], $options{'legacy'} ? 'sha' : 'sha256');
my $checksum = 'sha256';
$checksum = 'sha' if $options{'legacy'};
$checksum = 'sha512' if $options{'sha512'};
addsizechecksum("$extrep/$d->{'delta'}->[0]->{'filename'}", $d->{'delta'}->[0], $checksum);
my $mkey = "$d->{'arch'}\0$d->{'name'}\0$d->{'epoch'}\0$d->{'version'}\0$d->{'release'}\0";
if ($mergeddeltas{$mkey}) {
push @{$mergeddeltas{$mkey}->{'delta'}}, $d->{'delta'}->[0];
Expand Down Expand Up @@ -1306,7 +1312,9 @@ sub createpatterns_rpmmd {
writexml("$extrep/repodata/patterns.xml", undef, $pats, $BSXML::patterns);
my @legacyargs;
my %options = map {$_ => 1} @{$options || []};
if ($options{'legacy'}) {
if ($options{'sha512'}) {
push @legacyargs, '--simple-md-filenames', '--checksum=sha512';
} elsif ($options{'legacy'}) {
push @legacyargs, '--simple-md-filenames', '--checksum=sha';
} else {
# the default in newer createrepos
Expand Down Expand Up @@ -1382,7 +1390,9 @@ sub createpatterns_comps {
writexml("$extrep/repodata/group.xml", undef, $comps, $BSXML::comps);
my @legacyargs;
my %options = map {$_ => 1} @{$options || []};
if ($options{'legacy'}) {
if ($options{'sha512'}) {
push @legacyargs, '--simple-md-filenames', '--checksum=sha512';
} elsif ($options{'legacy'}) {
push @legacyargs, '--simple-md-filenames', '--checksum=sha';
} else {
# the default in newer createrepos
Expand Down

0 comments on commit 32b14f2

Please sign in to comment.