Skip to content

Commit

Permalink
coreos-base/afterburn: apply flatcar patches
Browse files Browse the repository at this point in the history
* legacy feature
* legacy provider (ec2, gce, virtualbox_vagrant)
* use ignition.oem.id and flatcar.oem.id

Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Jun 19, 2024
1 parent 33066bb commit cf9e909
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ RDEPEND="
PATCHES=(
"${FILESDIR}"/0001-Revert-remove-cl-legacy-feature.patch
"${FILESDIR}"/0002-util-cmdline-Handle-the-cmdline-flags-as-list-of-sup.patch
"${FILESDIR}"/0003-cargo-reduce-binary-size-for-release-profile.patch
"${FILESDIR}"/0003-Cargo-reduce-binary-size-for-release-profile.patch
)

src_unpack() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
From cb9d27d40fe7b34bdabe846764c0290fd9d36b8c Mon Sep 17 00:00:00 2001
From 992e030fb76593eae6651e1b4b7535fe9dcd0578 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Wed, 30 Mar 2022 09:17:45 +0200
Date: Wed, 19 Jun 2024 09:05:12 +0200
Subject: [PATCH 1/3] Revert "*: remove cl-legacy feature"

This reverts commit 3e4b623b390ab756a6be963eec7198b3e7f44e20.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
(dpark: Re-add hostname crate and its dependencies, as they are not
included by default in 5.5.)
Signed-off-by: Mathieu Tortuyaux <[email protected]>
Signed-off-by: Dongsu Park <[email protected]>
---
Cargo.toml | 3 +
Cargo.lock | 33 ++++++++++-
Cargo.toml | 4 ++
src/metadata.rs | 8 +++
src/providers/mod.rs | 2 +
src/providers/vagrant_virtualbox/mod.rs | 79 +++++++++++++++++++++++++
src/util/cmdline.rs | 4 ++
5 files changed, 96 insertions(+)
6 files changed, 129 insertions(+), 1 deletion(-)
create mode 100644 src/providers/vagrant_virtualbox/mod.rs

diff --git a/Cargo.lock b/Cargo.lock
index edb7819c..8bf34440 100644
index dbcffc6..3704b6a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -31,13 +31,14 @@ dependencies = [
"base64 0.21.5",
"base64 0.22.1",
"cfg-if",
"clap",
+ "hostname",
Expand All @@ -37,43 +38,56 @@ index edb7819c..8bf34440 100644
+ "nix 0.27.1",
"openssh-keys",
"openssl",
"pnet_base",
@@ -901,6 +902,17 @@ dependencies = [
"pnet_base 0.34.0",
@@ -917,6 +918,17 @@ dependencies = [
"digest",
]

+[[package]]
+name = "hostname"
+version = "0.3.1"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
+checksum = "f9c7c7c8ac16c798734b8a24560c1362120597c40d5e1459f09498f8f6c8f2ba"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "match_cfg",
+ "winapi",
+ "windows",
+]
+
[[package]]
name = "http"
version = "0.2.11"
@@ -1159,6 +1171,12 @@ version = "1.0.2"
version = "0.2.12"
@@ -2842,6 +2854,25 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

+[[package]]
+name = "match_cfg"
+version = "0.1.0"
+name = "windows"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
+dependencies = [
+ "windows-core",
+ "windows-targets 0.52.5",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
+checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
+dependencies = [
+ "windows-targets 0.52.5",
+]
+
[[package]]
name = "md-5"
version = "0.10.6"
name = "windows-sys"
version = "0.48.0"
diff --git a/Cargo.toml b/Cargo.toml
index e5b3dc3..f9b3e46 100644
index cfa2e6e..6710293 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,11 +26,15 @@ lto = true
@@ -33,11 +33,15 @@ path = "src/main.rs"
# We assume we're being delivered via e.g. RPM which supports split debuginfo
debug = true

Expand All @@ -82,66 +96,59 @@ index e5b3dc3..f9b3e46 100644
+
[dependencies]
anyhow = "1.0"
base64 = "0.21"
base64 = "0.22"
cfg-if = "1.0"
clap = { version = "4", "default_features" = false, "features" = ["std", "cargo", "derive", "error-context", "help", "suggestions", "usage", "wrap_help"] }
+hostname = "0.3.1"
clap = { version = "4", "default-features" = false, "features" = ["std", "cargo", "derive", "error-context", "help", "suggestions", "usage", "wrap_help"] }
+hostname = "0.4.0"
ipnetwork = ">= 0.17, < 0.21"
libflate = "1.3"
libflate = "2.1"
libsystemd = ">= 0.2.1, < 0.8.0"
diff --git a/src/metadata.rs b/src/metadata.rs
index 758bb1e..8544de9 100644
index b89bf5b..1b4da36 100644
--- a/src/metadata.rs
+++ b/src/metadata.rs
@@ -30,6 +30,8 @@ use crate::providers::openstack;
use crate::providers::openstack::network::OpenstackProviderNetwork;
@@ -34,6 +34,8 @@ use crate::providers::openstack::network::OpenstackProviderNetwork;
use crate::providers::packet::PacketProvider;
use crate::providers::powervs::PowerVSProvider;
use crate::providers::scaleway::ScalewayProvider;
+#[cfg(feature = "cl-legacy")]
+use crate::providers::vagrant_virtualbox::VagrantVirtualboxProvider;
use crate::providers::scaleway::ScalewayProvider;
use crate::providers::vmware::VmwareProvider;
use crate::providers::vultr::VultrProvider;
@@ -48,6 +50,8 @@ pub fn fetch_metadata(provider: &str) -> Result<Box<dyn providers::MetadataProvi
match provider {
"aliyun" => box_result!(AliyunProvider::try_new()?),
"aws" => box_result!(AwsProvider::try_new()?),
+ #[cfg(feature = "cl-legacy")]
+ "ec2" => box_result!(AwsProvider::try_new()?),
"azure" => box_result!(Azure::try_new()?),
"azurestack" => box_result!(AzureStack::try_new()?),
"cloudstack-metadata" => box_result!(CloudstackNetwork::try_new()?),
@@ -55,6 +59,8 @@ pub fn fetch_metadata(provider: &str) -> Result<Box<dyn providers::MetadataProvi

@@ -59,6 +61,10 @@ pub fn fetch_metadata(provider: &str) -> Result<Box<dyn providers::MetadataProvi
"cloudstack-configdrive" => box_result!(ConfigDrive::try_new()?),
"digitalocean" => box_result!(DigitalOceanProvider::try_new()?),
"exoscale" => box_result!(ExoscaleProvider::try_new()?),
"gcp" => box_result!(GcpProvider::try_new()?),
+ #[cfg(feature = "cl-legacy")]
+ "ec2" => box_result!(AwsProvider::try_new()?),
+ #[cfg(feature = "cl-legacy")]
+ "gce" => box_result!(GcpProvider::try_new()?),
"gcp" => box_result!(GcpProvider::try_new()?),
"hetzner" => box_result!(HetznerProvider::try_new()?),
// IBM Cloud - VPC Generation 2.
"ibmcloud" => box_result!(IBMGen2Provider::try_new()?),
@@ -63,6 +69,8 @@ pub fn fetch_metadata(provider: &str) -> Result<Box<dyn providers::MetadataProvi
"openstack-metadata" => box_result!(OpenstackProviderNetwork::try_new()?),
@@ -71,6 +77,8 @@ pub fn fetch_metadata(provider: &str) -> Result<Box<dyn providers::MetadataProvi
"packet" => box_result!(PacketProvider::try_new()?),
"powervs" => box_result!(PowerVSProvider::try_new()?),
"scaleway" => box_result!(ScalewayProvider::try_new()?),
+ #[cfg(feature = "cl-legacy")]
+ "vagrant-virtualbox" => box_result!(VagrantVirtualboxProvider::new()),
"scaleway" => box_result!(ScalewayProvider::try_new()?),
"vmware" => box_result!(VmwareProvider::try_new()?),
"vultr" => box_result!(VultrProvider::try_new()?),
_ => bail!("unknown provider '{}'", provider),
diff --git a/src/providers/mod.rs b/src/providers/mod.rs
index f684d22..a67546c 100644
index ab9698a..c9338b4 100644
--- a/src/providers/mod.rs
+++ b/src/providers/mod.rs
@@ -35,6 +35,8 @@ pub mod microsoft;
pub mod openstack;
@@ -39,6 +39,8 @@ pub mod openstack;
pub mod packet;
pub mod powervs;
pub mod scaleway;
+#[cfg(feature = "cl-legacy")]
+pub mod vagrant_virtualbox;
pub mod scaleway;
pub mod vmware;
pub mod vultr;

diff --git a/src/providers/vagrant_virtualbox/mod.rs b/src/providers/vagrant_virtualbox/mod.rs
new file mode 100644
index 0000000..d7a9e0e
Expand Down Expand Up @@ -228,7 +235,7 @@ index 0000000..d7a9e0e
+ }
+}
diff --git a/src/util/cmdline.rs b/src/util/cmdline.rs
index 8821265..e7b5550 100644
index d07cfeb..2e96ce4 100644
--- a/src/util/cmdline.rs
+++ b/src/util/cmdline.rs
@@ -23,7 +23,11 @@ use anyhow::{bail, Context, Result};
Expand All @@ -241,8 +248,8 @@ index 8821265..e7b5550 100644
+#[cfg(feature = "cl-legacy")]
+const CMDLINE_PLATFORM_FLAG: &str = "coreos.oem.id";

/// Get platform/OEM value from cmdline file.
/// Get platform value from cmdline file.
pub fn get_platform(fpath: &str) -> Result<String> {
--
2.34.1
2.44.2

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 4ba9549019683e4ece7bd1ddb27da67f8b260ea7 Mon Sep 17 00:00:00 2001
From 82dd31e721ea568416f0e5d4a894bd76d4da93fb Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Tue, 29 Mar 2022 16:01:19 +0200
Subject: [PATCH 2/3] util/cmdline: Handle the cmdline flags as list of
Expand All @@ -14,7 +14,7 @@ list takes precedence, any other present names are ignored.
1 file changed, 36 insertions(+), 28 deletions(-)

diff --git a/src/util/cmdline.rs b/src/util/cmdline.rs
index e7b5550..5c1cfda 100644
index 2e96ce4..89e85d4 100644
--- a/src/util/cmdline.rs
+++ b/src/util/cmdline.rs
@@ -24,29 +24,36 @@ use slog_scope::trace;
Expand Down Expand Up @@ -107,5 +107,5 @@ index e7b5550..5c1cfda 100644
}

--
2.34.1
2.44.2

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
From c47aa98230e7b540c88a4551a54fd9348f60b6a9 Mon Sep 17 00:00:00 2001
Message-Id: <c47aa98230e7b540c88a4551a54fd9348f60b6a9.1701862700.git.dpark@linux.microsoft.com>
From 91aad4160abe0482b215f198993b27382763806d Mon Sep 17 00:00:00 2001
From: Dongsu Park <[email protected]>
Date: Wed, 6 Dec 2023 12:36:24 +0100
Subject: [PATCH] Cargo: reduce binary size for release profile
Subject: [PATCH 3/3] Cargo: reduce binary size for release profile

In the release profile of Cargo.toml, add `codegen-units = 1`,
`strip = true`, and remove `debug = true`, to reduce binary size of
Expand All @@ -12,7 +11,7 @@ afterburn included in production images.
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index da74d909..1cf3213c 100644
index 6710293..db9f64f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,8 +30,10 @@ name = "afterburn"
Expand All @@ -29,5 +28,5 @@ index da74d909..1cf3213c 100644
[features]
cl-legacy = []
--
2.34.1
2.44.2

0 comments on commit cf9e909

Please sign in to comment.