Skip to content

Commit

Permalink
Drop cpio-rs, replace with vendored code
Browse files Browse the repository at this point in the history
This is necessary because RPM uses a modified CPIO format to support
>4gb file sizes. To maximize similarity and avoid producing nonsensical
RPM payloads, we should do the same.
  • Loading branch information
dralley committed Mar 23, 2023
1 parent 64f1cb0 commit a4d965a
Show file tree
Hide file tree
Showing 5 changed files with 577 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ num-derive = "0.3"
num = "0.4"
enum-primitive-derive = "0.2"
enum-display-derive = "0.1"
cpio = "0.2"

# consider migrating to flate2
libflate = "1"
sha2 = "0.10"
Expand Down
5 changes: 3 additions & 2 deletions src/rpm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::errors::*;
use super::compressor::Compressor;
use super::headers::*;
use super::Lead;
use super::payload;
use crate::constants::*;

#[cfg(feature = "signature-meta")]
Expand Down Expand Up @@ -554,7 +555,7 @@ impl RPMBuilder {
base_names.push(entry.base_name.to_owned());
file_verify_flags.push(u32::MAX); // @todo: <https://github.com/rpm-rs/rpm/issues/52>
let content = entry.content.to_owned();
let mut writer = cpio::newc::Builder::new(cpio_path)
let mut writer = payload::Builder::new(cpio_path)
.mode(entry.mode.into())
.ino(ino_index)
.uid(self.uid.unwrap_or(0))
Expand Down Expand Up @@ -971,7 +972,7 @@ impl RPMBuilder {
}

let header = Header::from_entries(actual_records, IndexTag::RPMTAG_HEADERIMMUTABLE);
self.compressor = cpio::newc::trailer(self.compressor)?;
self.compressor = payload::trailer(self.compressor)?;
let content = self.compressor.finish_compression()?;

Ok((lead, header, content))
Expand Down
1 change: 1 addition & 0 deletions src/rpm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod builder;
mod compressor;
mod headers;
mod package;
mod payload;

#[cfg(feature = "signature-meta")]
pub mod signature;
Expand Down
9 changes: 9 additions & 0 deletions src/rpm/payload/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2016 Jonathan Creekmore

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit a4d965a

Please sign in to comment.