From cf9e909e7fa5d9ba88190669c2ef13ba6498e35a Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Wed, 19 Jun 2024 10:20:51 +0200 Subject: [PATCH] coreos-base/afterburn: apply flatcar patches * legacy feature * legacy provider (ec2, gce, virtualbox_vagrant) * use ignition.oem.id and flatcar.oem.id Signed-off-by: Mathieu Tortuyaux --- .../afterburn/afterburn-9999.ebuild | 2 +- ...0001-Revert-remove-cl-legacy-feature.patch | 113 ++++++++++-------- ...dle-the-cmdline-flags-as-list-of-sup.patch | 6 +- ...uce-binary-size-for-release-profile.patch} | 9 +- 4 files changed, 68 insertions(+), 62 deletions(-) rename sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/{0003-cargo-reduce-binary-size-for-release-profile.patch => 0003-Cargo-reduce-binary-size-for-release-profile.patch} (74%) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/afterburn-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/afterburn-9999.ebuild index 88682784b82..23c8ecee235 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/afterburn-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/afterburn-9999.ebuild @@ -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() { diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0001-Revert-remove-cl-legacy-feature.patch b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0001-Revert-remove-cl-legacy-feature.patch index efc9f41f850..04ec088057c 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0001-Revert-remove-cl-legacy-feature.patch +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0001-Revert-remove-cl-legacy-feature.patch @@ -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 -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 (dpark: Re-add hostname crate and its dependencies, as they are not included by default in 5.5.) +Signed-off-by: Mathieu Tortuyaux Signed-off-by: Dongsu Park --- - 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", @@ -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 @@ -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_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 Result 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_result!(OpenstackProviderNetwork::try_new()?), +@@ -71,6 +77,8 @@ pub fn fetch_metadata(provider: &str) -> Result 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 @@ -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}; @@ -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 { -- -2.34.1 +2.44.2 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0002-util-cmdline-Handle-the-cmdline-flags-as-list-of-sup.patch b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0002-util-cmdline-Handle-the-cmdline-flags-as-list-of-sup.patch index 3b682cbc960..65ee97e6df1 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0002-util-cmdline-Handle-the-cmdline-flags-as-list-of-sup.patch +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0002-util-cmdline-Handle-the-cmdline-flags-as-list-of-sup.patch @@ -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 Date: Tue, 29 Mar 2022 16:01:19 +0200 Subject: [PATCH 2/3] util/cmdline: Handle the cmdline flags as list of @@ -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; @@ -107,5 +107,5 @@ index e7b5550..5c1cfda 100644 } -- -2.34.1 +2.44.2 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0003-cargo-reduce-binary-size-for-release-profile.patch b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0003-Cargo-reduce-binary-size-for-release-profile.patch similarity index 74% rename from sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0003-cargo-reduce-binary-size-for-release-profile.patch rename to sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0003-Cargo-reduce-binary-size-for-release-profile.patch index 6fe1e6d433d..5eac2880870 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0003-cargo-reduce-binary-size-for-release-profile.patch +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/afterburn/files/0003-Cargo-reduce-binary-size-for-release-profile.patch @@ -1,8 +1,7 @@ -From c47aa98230e7b540c88a4551a54fd9348f60b6a9 Mon Sep 17 00:00:00 2001 -Message-Id: +From 91aad4160abe0482b215f198993b27382763806d Mon Sep 17 00:00:00 2001 From: Dongsu Park 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 @@ -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" @@ -29,5 +28,5 @@ index da74d909..1cf3213c 100644 [features] cl-legacy = [] -- -2.34.1 +2.44.2