Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate the correct file path for deb repo metadata (bsc#1214982) #7566

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)