Skip to content

Commit

Permalink
Large file packages need to declare rpmlib dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Jan 11, 2024
1 parent ca3d717 commit 807ed12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Using file capabilities now adds the appropriate rpmlib() dependency
- RPM packages that use large files (>4gb) now correctly declare rpmlib() dependency

## 0.13.1

Expand Down
37 changes: 22 additions & 15 deletions src/rpm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ impl PackageBuilder {
}
cpio::newc::trailer(&mut archive)?;

let large_package = combined_file_sizes > u32::MAX.into();

self.provides
.push(Dependency::eq(self.name.clone(), self.version.clone()));
self.provides.push(Dependency::eq(
Expand All @@ -842,6 +844,12 @@ impl PackageBuilder {
self.requires
.push(Dependency::rpmlib("FileCaps", "4.6.1-1".to_owned()));
}

if large_package {
self.requires
.push(Dependency::rpmlib("LargeFiles", "4.12.0-1".to_owned()));
}

// TODO: as per https://rpm-software-management.github.io/rpm/manual/users_and_groups.html,
// at some point in the future this might make sense as hard requirements, but since it's a new feature,
// they have to be weak requirements to avoid breaking things.
Expand Down Expand Up @@ -934,7 +942,6 @@ impl PackageBuilder {
}

let offset = 0;
let small_package = combined_file_sizes <= u32::MAX.into();

let mut actual_records = vec![
// Existence of this tag is how rpm decides whether or not a package is a source rpm or binary rpm
Expand Down Expand Up @@ -985,7 +992,13 @@ impl PackageBuilder {
offset,
IndexData::I18NString(vec![self.summary]),
),
if small_package {
if large_package {
IndexEntry::new(
IndexTag::RPMTAG_LONGSIZE,
offset,
IndexData::Int64(vec![combined_file_sizes]),
)
} else {
let combined_file_sizes = combined_file_sizes
.try_into()
.expect("combined_file_sizes should be smaller than 4 GiB");
Expand All @@ -994,12 +1007,6 @@ impl PackageBuilder {
offset,
IndexData::Int32(vec![combined_file_sizes]),
)
} else {
IndexEntry::new(
IndexTag::RPMTAG_LONGSIZE,
offset,
IndexData::Int64(vec![combined_file_sizes]),
)
},
IndexEntry::new(
IndexTag::RPMTAG_LICENSE,
Expand Down Expand Up @@ -1056,7 +1063,13 @@ impl PackageBuilder {

// if we have an empty RPM, we have to leave out all file related index entries.
if !self.files.is_empty() {
let size_entry = if small_package {
let size_entry = if large_package {
IndexEntry::new(
IndexTag::RPMTAG_LONGFILESIZES,
offset,
IndexData::Int64(file_sizes),
)
} else {
let file_sizes = file_sizes
.into_iter()
.map(u32::try_from)
Expand All @@ -1070,12 +1083,6 @@ impl PackageBuilder {
offset,
IndexData::Int32(file_sizes),
)
} else {
IndexEntry::new(
IndexTag::RPMTAG_LONGFILESIZES,
offset,
IndexData::Int64(file_sizes),
)
};
actual_records.extend([
size_entry,
Expand Down

0 comments on commit 807ed12

Please sign in to comment.