This commit is contained in:
Benjamin Gilbert 2021-12-17 14:39:16 -05:00
parent 3d9d0d1860
commit eb586006f0
4 changed files with 9 additions and 93 deletions

2
.gitignore vendored
View File

@ -16,3 +16,5 @@
/coreos-installer-0.11.0.crate
/coreos-installer-dracut-9332fe5.tar.gz
/coreos-installer-0.11.0-vendor.tar.gz
/coreos-installer-0.12.0.crate
/coreos-installer-0.12.0-vendor.tar.gz

View File

@ -1,87 +0,0 @@
From f8aee361291fc9505e62f9a75a60ae6e3905bcb6 Mon Sep 17 00:00:00 2001
From: Jonathan Lebon <jonathan@jlebon.com>
Date: Thu, 25 Nov 2021 11:39:39 -0500
Subject: [PATCH] miniso: handle hardlinked files
On ppc64le, some files are hardlinked. The way hardlinks are represented
in ISO9660 is simply that the dirents point to the same sector and have
identical sizes. So they show up as exact copies in the table. So we can
get rid of them by deduplicating. Rust's `Vec::dedup()` makes this easy.
See: https://github.com/coreos/coreos-assembler/issues/2583
---
src/iso9660.rs | 2 +-
src/miniso.rs | 14 +++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/iso9660.rs b/src/iso9660.rs
index 9f5482d..7b82fcf 100644
--- a/src/iso9660.rs
+++ b/src/iso9660.rs
@@ -221,7 +221,7 @@ pub struct File {
pub length: u32,
}
-#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
+#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
pub struct Address(u32);
impl Address {
diff --git a/src/miniso.rs b/src/miniso.rs
index 63bea6c..9d2ce0b 100644
--- a/src/miniso.rs
+++ b/src/miniso.rs
@@ -47,7 +47,7 @@ impl Table {
fn new(
full_files: &HashMap<String, iso9660::File>,
minimal_files: &HashMap<String, iso9660::File>,
- ) -> Result<Self> {
+ ) -> Result<(Self, usize)> {
let mut entries: Vec<TableEntry> = Vec::new();
for (path, minimal_entry) in minimal_files {
let full_entry = full_files
@@ -67,9 +67,13 @@ impl Table {
}
entries.sort_by_key(|e| e.minimal.as_sector());
+ // drop duplicate entries (hardlinks), and calculate how many there were for reporting
+ let size = entries.len();
+ entries.dedup();
+ let hardlinks = size - entries.len();
let table = Table { entries };
table.validate().context("validating table")?;
- Ok(table)
+ Ok((table, hardlinks))
}
fn validate(&self) -> Result<()> {
@@ -91,7 +95,7 @@ impl Table {
}
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
struct TableEntry {
minimal: iso9660::Address,
full: iso9660::Address,
@@ -148,7 +152,7 @@ impl Data {
full_files: &HashMap<String, iso9660::File>,
minimal_files: &HashMap<String, iso9660::File>,
) -> Result<(Self, usize, u64, u64, u64)> {
- let table = Table::new(full_files, minimal_files)?;
+ let (table, hardlinks) = Table::new(full_files, minimal_files)?;
// A `ReadHasher` here would let us wrap the miniso so we calculate the digest as we read.
let digest = Sha256Digest::from_file(miniso)?;
@@ -183,7 +187,7 @@ impl Data {
copy(miniso, &mut xzw).context("copying remaining miniso bytes")?;
xzw.try_finish().context("trying to finish xz stream")?;
- let matches = table.entries.len();
+ let matches = table.entries.len() + hardlinks;
let written = xzw.total_in();
let written_compressed = xzw.total_out();
Ok((
--
2.33.1

View File

@ -11,8 +11,8 @@
%global crate coreos-installer
Name: rust-%{crate}
Version: 0.11.0
Release: 3%{?dist}
Version: 0.12.0
Release: 1%{?dist}
Summary: Installer for Fedora CoreOS and RHEL CoreOS
# Upstream license specification: Apache-2.0
@ -23,8 +23,6 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{
Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz
Source2: https://github.com/coreos/coreos-installer-dracut/archive/%{dracutcommit}/coreos-installer-dracut-%{dracutshortcommit}.tar.gz
Patch0: 0001-miniso-handle-hardlinked-files.patch
ExclusiveArch: %{rust_arches}
%if 0%{?rhel} && !0%{?eln}
BuildRequires: rust-toolset
@ -192,6 +190,9 @@ from the initramfs.
%endif
%changelog
* Fri Dec 17 2021 Benjamin Gilbert <bgilbert@redhat.com> - 0.12.0-1
- New release
* Wed Dec 15 2021 Sohan Kunkerkar <skunkerk@redhat.com> - 0.11.0-3
- Remove conditional around sourcing the vendor tarball
- Fix inadvertent inclusion of coreos-installer-dracut in -bootinfra on RHEL

View File

@ -1,3 +1,3 @@
SHA512 (coreos-installer-0.11.0.crate) = a07d65b05ee25717dddccccb6c56367d1798f2e9c0c166ef4ffe42e2ecb9b246fd5bf2c4a0166f1908dd9a59d42db937a7bb3ba5f0a146e43882dea40df868db
SHA512 (coreos-installer-0.11.0-vendor.tar.gz) = e813994338d0212e4cddafc969f99f285c441353756bc3f214943513a7999177300539aa98209a3bfdc54e29e2d60775ab492da7c066f2072e7674c08478c22f
SHA512 (coreos-installer-0.12.0.crate) = f6e7c908d3207d1718830da6b83bb4d219e58680d2741f3e261ef4a1bbfa077f07e13e874b5a021f080ba0f64bebacc7ac2699d46e85ee6d9ad8248a0425cf34
SHA512 (coreos-installer-0.12.0-vendor.tar.gz) = b2a5f3cdc92b766778aa06ce22dd02f989d90605ea07cb3145b5e8f61f02bcf6fb13b1987d1d89418e9d129bc844713eb702df77775580abc735859e20a9b137
SHA512 (coreos-installer-dracut-9332fe5.tar.gz) = 2cd481c4aacddcb51726a2d7e84879e7cb7623b5d984b1bd496362bfb3dc7ea6fb232864d696b7b72900d797674d14754222532167da545f445d8092ec2fe6ea