Skip to content

Commit

Permalink
Merge pull request #7566 from uyuni-project/bsc1214982-uyuni
Browse files Browse the repository at this point in the history
generate the correct file path for deb repo metadata (bsc#1214982)
  • Loading branch information
lucidd authored Oct 5, 2023
2 parents 67c5856 + 72c8881 commit e696376
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.StringWriter;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;

/**
*
Expand All @@ -62,6 +63,19 @@ public DebPackageWriter(Channel channel, String prefix) throws IOException {
out = new BufferedWriter(new FileWriter(filenamePackages, true));
}

private String getFilename(PackageDto pkgDto) {
StringBuilder buf = new StringBuilder();
buf.append("Filename: ").append(channelLabel).append("/getPackage/")
.append(pkgDto.getName()).append("_");
String epoch = pkgDto.getEpoch();
if (epoch != null && !epoch.equalsIgnoreCase("")) {
buf.append(epoch).append(":");
}
buf.append(pkgDto.getVersion()).append("-").append(pkgDto.getRelease())
.append(".").append(pkgDto.getArchLabel()).append(".deb");
return buf.toString();
}

/**
* add package info to Packages file in repository
*
Expand All @@ -72,7 +86,21 @@ public void addPackage(PackageDto pkgDto) throws IOException {
// we use the primary xml cache for debian package entry
String pkgSnippet = pkgDto.getPrimaryXml();
if (ConfigDefaults.get().useDBRepodata() && !StringUtils.isBlank(pkgSnippet)) {
out.write(pkgSnippet);
// deb repos currently contain file path in the metadata specific to a channel which makes them
// unusable for cloned channels. With this we use most of the cached version to preserve speed while
// regenerating the file path.
String fixedSnippet = pkgSnippet.lines()
.map(line -> {
if (line.startsWith("Filename: ")) {
return getFilename(pkgDto);
}
else {
return line;
}
})
.collect(Collectors.joining(System.lineSeparator()));
out.write(fixedSnippet);
out.newLine();
out.newLine();
return;
}
Expand Down Expand Up @@ -145,13 +173,7 @@ public void addPackage(PackageDto pkgDto) throws IOException {
TaskConstants.TASK_QUERY_REPOMD_GENERATOR_CAPABILITY_BREAKS,
pkgDto.getId(), "Breaks");

buf.write("Filename: " + channelLabel + "/getPackage/");
buf.write(pkgDto.getName() + "_");
if (epoch != null && !epoch.equalsIgnoreCase("")) {
buf.write(epoch + ":");
}
buf.write(pkgDto.getVersion() + "-" + pkgDto.getRelease());
buf.write("." + pkgDto.getArchLabel() + ".deb");
buf.write(getFilename(pkgDto));
buf.newLine();

// size of package, is checked by apt
Expand Down
1 change: 1 addition & 0 deletions java/spacewalk-java.changes.kwalter.bsc1214982
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix token issue with cloned deb channels (bsc#1214982)

0 comments on commit e696376

Please sign in to comment.