From e6f34d3d2765a6feff95acb24f6edf3815d448b9 Mon Sep 17 00:00:00 2001 From: duyiwei Date: Wed, 5 Jun 2024 17:44:15 +0800 Subject: [PATCH] Block unsupported functions and modify the coreos to nestos --- ...ions-and-modify-the-coreos-to-nestos.patch | 383 ++++++++++++++++++ nestos-installer.spec | 6 +- 2 files changed, 388 insertions(+), 1 deletion(-) create mode 100644 0001-Block-unsupported-functions-and-modify-the-coreos-to-nestos.patch diff --git a/0001-Block-unsupported-functions-and-modify-the-coreos-to-nestos.patch b/0001-Block-unsupported-functions-and-modify-the-coreos-to-nestos.patch new file mode 100644 index 0000000..f1764a3 --- /dev/null +++ b/0001-Block-unsupported-functions-and-modify-the-coreos-to-nestos.patch @@ -0,0 +1,383 @@ +From bd4a07b5699079ca16a2a314badf3276b028b85a Mon Sep 17 00:00:00 2001 +From: duyiwei +Date: Mon, 20 May 2024 14:35:28 +0800 +Subject: [PATCH] Block unsupported functions and modify the coreos to nestos + +Signed-off-by: duyiwei +--- + man/coreos-installer-install.8 | 2 +- + man/coreos-installer-pxe-customize.8 | 2 +- + src/bin/rdcore/rootmap.rs | 2 +- + src/cmdline/install.rs | 19 +++++----- + src/cmdline/mod.rs | 54 ++++++++++++++-------------- + src/install.rs | 10 ++++++ + src/live/customize.rs | 4 +-- + src/live/embed.rs | 2 +- + src/live/mod.rs | 2 +- + src/main.rs | 5 +-- + src/source.rs | 6 ++-- + 11 files changed, 60 insertions(+), 48 deletions(-) + +diff --git a/man/coreos-installer-install.8 b/man/coreos-installer-install.8 +index 51905d8..25c9815 100644 +--- a/man/coreos-installer-install.8 ++++ b/man/coreos-installer-install.8 +@@ -101,7 +101,7 @@ Allow Ignition URL without HTTPS or hash + \fB\-\-stream\-base\-url\fR=\fIURL\fR + Base URL for nestos stream metadata + +-Override the base URL for fetching nestos stream metadata. The default is "https://builds.coreos.fedoraproject.org/streams/". ++Override the base URL for fetching nestos stream metadata. The default is "https://nestos.org.cn/NestOS-release/streams/". + .TP + \fB\-\-preserve\-on\-error\fR + Don\*(Aqt clear partition table on error +diff --git a/man/coreos-installer-pxe-customize.8 b/man/coreos-installer-pxe-customize.8 +index f1a81ff..654b19c 100644 +--- a/man/coreos-installer-pxe-customize.8 ++++ b/man/coreos-installer-pxe-customize.8 +@@ -4,7 +4,7 @@ + .SH NAME + nestos\-installer\-pxe\-customize \- Create a custom live PXE boot config + .SH SYNOPSIS +-\fBcoreos\-installer\-pxe\-customize\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fB\-\-dest\-ignition\fR] [\fB\-\-dest\-device\fR] [\fB\-\-dest\-console\fR] [\fB\-\-dest\-karg\-append\fR] [\fB\-\-dest\-karg\-delete\fR] [\fB\-\-network\-keyfile\fR] [\fB\-\-network\-nmstate\fR] [\fB\-\-ignition\-ca\fR] [\fB\-\-pre\-install\fR] [\fB\-\-post\-install\fR] [\fB\-\-installer\-config\fR] [\fB\-\-live\-ignition\fR] <\fB\-o\fR|\fB\-\-output\fR> <\fIpath\fR> ++\fBnestos\-installer\-pxe\-customize\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fB\-\-dest\-ignition\fR] [\fB\-\-dest\-device\fR] [\fB\-\-dest\-console\fR] [\fB\-\-dest\-karg\-append\fR] [\fB\-\-dest\-karg\-delete\fR] [\fB\-\-network\-keyfile\fR] [\fB\-\-network\-nmstate\fR] [\fB\-\-ignition\-ca\fR] [\fB\-\-pre\-install\fR] [\fB\-\-post\-install\fR] [\fB\-\-installer\-config\fR] [\fB\-\-live\-ignition\fR] <\fB\-o\fR|\fB\-\-output\fR> <\fIpath\fR> + .SH DESCRIPTION + Create a custom live PXE boot config + .SH OPTIONS +diff --git a/src/bin/rdcore/rootmap.rs b/src/bin/rdcore/rootmap.rs +index 7c404c9..c305f16 100644 +--- a/src/bin/rdcore/rootmap.rs ++++ b/src/bin/rdcore/rootmap.rs +@@ -292,4 +292,4 @@ fn write_boot_uuid_grub2_dropin>(uuid: &str, p: P) -> Result<()> + let p = p.as_ref(); + std::fs::write(p, format!("set BOOT_UUID=\"{}\"\n", uuid)) + .with_context(|| format!("writing {}", p.display())) +-} ++} +\ No newline at end of file +diff --git a/src/cmdline/install.rs b/src/cmdline/install.rs +index e04901e..692b3f2 100644 +--- a/src/cmdline/install.rs ++++ b/src/cmdline/install.rs +@@ -74,11 +74,11 @@ pub struct InstallConfig { + pub config_file: Vec, + + // ways to specify the image source +- /// Fedora CoreOS stream ++ /// NestOS release stream + /// +- /// The name of the Fedora CoreOS stream to install, such as "stable", +- /// "testing", or "next". +- #[clap(short, long, value_name = "name")] ++ /// The name of the NestOS release stream to install, ++ /// temporarily closed before NestOS Stream is ready. ++ #[clap(short, long, hide = true, value_name = "name")] + #[clap(conflicts_with = "image-file", conflicts_with = "image-url")] + pub stream: Option, + /// Manually specify the image URL +@@ -134,7 +134,7 @@ pub struct InstallConfig { + /// Additional kernel args for the first boot + // This used to be for configuring networking from the cmdline, but it has + // been obsoleted by the nicer `--copy-network` approach. We still need it +- // for now though. It's used at least by `coreos-installer.service`. ++ // for now though. It's used at least by `nestos-installer.service`. + #[serde(skip)] + #[clap(long, hide = true, value_name = "args")] + pub firstboot_args: Option, +@@ -200,16 +200,15 @@ pub struct InstallConfig { + #[serde(skip_serializing_if = "is_default")] + #[clap(long, help_heading = ADVANCED)] + pub insecure_ignition: bool, +- /// Base URL for CoreOS stream metadata ++ /// Base URL for NestOS release stream metadata + /// +- /// Override the base URL for fetching CoreOS stream metadata. +- /// The default is "https://builds.coreos.fedoraproject.org/streams/". ++ /// Temporarily closed before NestOS Stream is ready. + #[serde_as(as = "Option")] +- #[clap(long, value_name = "URL", help_heading = ADVANCED)] ++ #[clap(long, hide = true, value_name = "URL", help_heading = ADVANCED)] + pub stream_base_url: Option, + /// Don't clear partition table on error + /// +- /// If installation fails, coreos-installer normally clears the ++ /// If installation fails, nestos-installer normally clears the + /// destination's partition table to prevent booting from invalid + /// boot media. Skip clearing the partition table as a debugging aid. + #[serde(skip_serializing_if = "is_default")] +diff --git a/src/cmdline/mod.rs b/src/cmdline/mod.rs +index 6fcfe8f..0e6bff5 100644 +--- a/src/cmdline/mod.rs ++++ b/src/cmdline/mod.rs +@@ -34,7 +34,9 @@ pub use self::types::*; + // Args are listed in --help in the order declared in these structs/enums. + // Please keep the entire help text to 80 columns. + +-/// Installer for Fedora CoreOS and RHEL CoreOS ++/// Installer for NestOS ++/// ++/// NestOS is a Variant in openEuler from Fedora CoreOS. + #[derive(Debug, Parser)] + #[clap(version)] + #[clap(global_setting(AppSettings::DeriveDisplayOrder))] +@@ -42,16 +44,16 @@ pub use self::types::*; + #[clap(disable_help_subcommand = true)] + #[clap(help_expected = true)] + pub enum Cmd { +- /// Install Fedora CoreOS or RHEL CoreOS ++ /// Install NestOS + Install(InstallConfig), +- /// Download a CoreOS image +- Download(DownloadConfig), +- /// List available images in a Fedora CoreOS stream +- ListStream(ListStreamConfig), +- /// Commands to manage a CoreOS live ISO image ++ // Download a NestOS image ++ //Download(DownloadConfig), ++ // List available images in a NestOS release stream ++ //ListStream(ListStreamConfig), ++ /// Commands to manage a NestOS live ISO image + #[clap(subcommand)] + Iso(IsoCmd), +- /// Commands to manage a CoreOS live PXE image ++ /// Commands to manage a NestOS live PXE image + #[clap(subcommand)] + Pxe(PxeCmd), + /// Metadata packing commands used when building an OS image +@@ -76,21 +78,21 @@ pub enum IsoCmd { + // deprecated + #[clap(hide = true)] + Remove(IsoRemoveConfig), +- /// Customize a CoreOS live ISO image ++ /// Customize a NestOS live ISO image + Customize(IsoCustomizeConfig), +- /// Embed an Ignition config in a CoreOS live ISO image ++ /// Embed an Ignition config in a NestOS live ISO image + #[clap(subcommand)] + Ignition(IsoIgnitionCmd), +- /// Embed network settings in a CoreOS live ISO image ++ /// Embed network settings in a NestOS live ISO image + #[clap(subcommand)] + Network(IsoNetworkCmd), +- /// Modify kernel args in a CoreOS live ISO image ++ /// Modify kernel args in a NestOS live ISO image + #[clap(subcommand)] + Kargs(IsoKargsCmd), +- /// Commands to extract files from a CoreOS live ISO image ++ /// Commands to extract files from a NestOS live ISO image + #[clap(subcommand)] + Extract(IsoExtractCmd), +- /// Restore a CoreOS live ISO image to default settings ++ /// Restore a NestOS live ISO image to default settings + Reset(IsoResetConfig), + } + +@@ -128,7 +130,7 @@ pub enum IsoKargsCmd { + pub enum IsoExtractCmd { + /// Extract PXE files from an ISO image + Pxe(IsoExtractPxeConfig), +- /// Extract a minimal ISO from a CoreOS live ISO image ++ /// Extract a minimal ISO from a NestOS live ISO image + MinimalIso(IsoExtractMinimalIsoConfig), + } + +@@ -164,11 +166,11 @@ pub enum PxeNetworkCmd { + // users shouldn't be interacting with this command normally + #[clap(hide = true)] + pub enum PackCmd { +- /// Create osmet file from CoreOS block device ++ /// Create osmet file from NestOS block device + Osmet(PackOsmetConfig), +- /// Pack a minimal ISO into a CoreOS live ISO image ++ /// Pack a minimal ISO into a NestOS live ISO image + MinimalIso(PackMinimalIsoConfig), +- /// Generate man pages for coreos-installer ++ /// Generate man pages for nestos-installer + #[cfg(feature = "docgen")] + Man(PackManConfig), + /// Generate example config file for install subcommand +@@ -190,7 +192,7 @@ pub enum DevCmd { + + #[derive(Debug, Parser)] + pub enum DevShowCmd { +- /// Inspect the CoreOS live ISO image ++ /// Inspect the NestOS live ISO image + Iso(DevShowIsoConfig), + /// Show the contents of an initrd image + Initrd(DevShowInitrdConfig), +@@ -208,13 +210,13 @@ pub enum DevExtractCmd { + + #[derive(Debug, Parser)] + pub struct DownloadConfig { +- /// Fedora CoreOS stream ++ /// NestOS release stream + #[clap(short, long, value_name = "name", default_value = "stable")] + pub stream: String, + /// Target CPU architecture + #[clap(short, long, value_name = "name", default_value_t)] + pub architecture: DefaultedString, +- /// Fedora CoreOS platform name ++ /// NestOS platform name + #[clap(short, long, value_name = "name", default_value = "metal")] + pub platform: String, + /// Image format +@@ -232,7 +234,7 @@ pub struct DownloadConfig { + /// Skip signature verification + #[clap(long)] + pub insecure: bool, +- /// Base URL for Fedora CoreOS stream metadata ++ /// Base URL for NestOS release stream metadata + #[clap(long, value_name = "URL")] + pub stream_base_url: Option, + /// Fetch retries, or "infinite" +@@ -242,10 +244,10 @@ pub struct DownloadConfig { + + #[derive(Debug, Parser)] + pub struct ListStreamConfig { +- /// Fedora CoreOS stream ++ /// NestOS release stream + #[clap(short, long, value_name = "name", default_value = "stable")] + pub stream: String, +- /// Base URL for Fedora CoreOS stream metadata ++ /// Base URL for NestOS release stream metadata + #[clap(long, value_name = "URL")] + pub stream_base_url: Option, + } +@@ -326,7 +328,7 @@ pub struct CommonCustomizeConfig { + pub post_install: Vec, + /// Installer config file + /// +- /// Automatically run coreos-installer and apply the specified installer ++ /// Automatically run nestos-installer and apply the specified installer + /// config file. Config files are applied in the order that they are + /// specified. + #[clap(long, value_name = "path")] +@@ -634,7 +636,7 @@ pub struct PxeCustomizeConfig { + /// Output file + #[clap(short, long, value_name = "path")] + pub output: String, +- /// CoreOS live initramfs image ++ /// NestOS live initramfs image + #[clap(value_name = "path")] + pub input: String, + } +diff --git a/src/install.rs b/src/install.rs +index 745651d..c7206c5 100644 +--- a/src/install.rs ++++ b/src/install.rs +@@ -36,6 +36,14 @@ use crate::source::*; + const GRUB_CFG_CONSOLE_SETTINGS_RE: &str = r"(?P\n# CONSOLE-SETTINGS-START\n)(?P([^\n]*\n)*)(?P# CONSOLE-SETTINGS-END\n)"; + + pub fn install(config: InstallConfig) -> Result<()> { ++ // Temporarily closed before NestOS Stream is ready. ++ if config.stream.is_some() { ++ bail!("The --stream is not currently supported until NestOS release stream is ready."); ++ } ++ ++ if config.stream_base_url.is_some() { ++ bail!("The --stream-base-url is not currently supported until NestOS release stream is ready."); ++ } + // evaluate config files + let config = config.expand_config_files()?; + +@@ -133,6 +141,8 @@ pub fn install(config: InstallConfig) -> Result<()> { + if let Some(osmet) = maybe_osmet { + Box::new(osmet) + } else { ++ //Temporarily unsupported before NestOS Stream is ready. ++ bail!("Stream fetching of images is not supported. Ensure you are in a NestOS live environment or provide a valid image source."); + let format = match sector_size { + 4096 => "4k.raw.xz", + 512 => "raw.xz", +diff --git a/src/live/customize.rs b/src/live/customize.rs +index 5aee32b..5d03b13 100644 +--- a/src/live/customize.rs ++++ b/src/live/customize.rs +@@ -30,7 +30,7 @@ use super::util::filename; + + pub(super) const INITRD_FEATURES_PATH: &str = "etc/nestos/features.json"; + +-const COREOS_ISO_FEATURES_PATH: &str = "COREOS/FEATURES.JSO"; ++const COREOS_ISO_FEATURES_PATH: &str = "NESTOS/FEATURES.JSO"; + + /// CoreOS feature flags in /etc/coreos/features.json in the live initramfs + /// and /coreos/features.json in the live ISO. Written by +@@ -80,7 +80,7 @@ pub(super) struct LiveInitrd { + /// User-supplied Ignition configs for the dest system, which might be + /// merged into the dest config or might become the dest config + user_dest: Vec, +- /// The coreos-installer config for our own parameters, excluding custom ++ /// The nestos-installer config for our own parameters, excluding custom + /// configs supplied by the user + installer: Option, + /// Have the installer copy network configs, if we are running it +diff --git a/src/live/embed.rs b/src/live/embed.rs +index cbfdf95..334e860 100644 +--- a/src/live/embed.rs ++++ b/src/live/embed.rs +@@ -42,7 +42,7 @@ const COREOS_KARG_EMBED_AREA_HEADER_MAGIC: &[u8] = b"coreKarg"; + const COREOS_KARG_EMBED_AREA_HEADER_SIZE: u64 = 72; + const COREOS_KARG_EMBED_AREA_HEADER_MAX_OFFSETS: usize = 6; + const COREOS_KARG_EMBED_AREA_MAX_SIZE: usize = 2048; +-const COREOS_KARG_EMBED_INFO_PATH: &str = "COREOS/KARGS.JSO"; ++const COREOS_KARG_EMBED_INFO_PATH: &str = "NESTOS/KARGS.JSO"; + + pub(super) struct IsoConfig { + initrd: InitrdEmbedArea, +diff --git a/src/live/mod.rs b/src/live/mod.rs +index f80dcbc..051dae7 100644 +--- a/src/live/mod.rs ++++ b/src/live/mod.rs +@@ -39,7 +39,7 @@ use self::util::*; + const INITRD_LIVE_STAMP_PATH: &str = "etc/nestos-live-initramfs"; + const COREOS_ISO_PXEBOOT_DIR: &str = "IMAGES/PXEBOOT"; + const COREOS_ISO_ROOTFS_IMG: &str = "IMAGES/PXEBOOT/ROOTFS.IMG"; +-const COREOS_ISO_MINISO_FILE: &str = "COREOS/MINISO.DAT"; ++const COREOS_ISO_MINISO_FILE: &str = "NESTOS/MINISO.DAT"; + + lazy_static! { + static ref ALL_GLOB: GlobMatcher = GlobMatcher::new(&["*"]).unwrap(); +diff --git a/src/main.rs b/src/main.rs +index 539b121..09849f8 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -21,9 +21,10 @@ use cmdline::*; + + fn main() -> Result<()> { + match Cmd::parse() { +- Cmd::Download(c) => download::download(c), ++ //Temporarily closed Download and ListStream before NestOS Stream is ready. ++ //Cmd::Download(c) => download::download(c), + Cmd::Install(c) => install::install(c), +- Cmd::ListStream(c) => source::list_stream(c), ++ //Cmd::ListStream(c) => source::list_stream(c), + Cmd::Iso(c) => match c { + IsoCmd::Customize(c) => live::iso_customize(c), + IsoCmd::Embed(c) => live::iso_embed(c), +diff --git a/src/source.rs b/src/source.rs +index cef04ff..eb055e5 100644 +--- a/src/source.rs ++++ b/src/source.rs +@@ -32,8 +32,8 @@ use crate::util::set_die_on_sigpipe; + /// Completion timeout for HTTP requests (4 hours). + const HTTP_COMPLETION_TIMEOUT: Duration = Duration::from_secs(4 * 60 * 60); + +-/// Default base URL to Fedora CoreOS streams metadata. +-const DEFAULT_STREAM_BASE_URL: &str = "https://builds.coreos.fedoraproject.org/streams/"; ++/// Default base URL to NestOS streams metadata. ++const DEFAULT_STREAM_BASE_URL: &str = "https://nestos.org.cn/NestOS-release/streams/"; + + /// Directory in which we look for osmet files. + const OSMET_FILES_DIR: &str = "/run/nestos-installer/osmet"; +@@ -72,7 +72,7 @@ pub struct UrlLocation { + retries: FetchRetries, + } + +-// Remote image source specified by Fedora CoreOS stream metadata ++// Remote image source specified by NestOS stream metadata + #[derive(Debug)] + pub struct StreamLocation { + stream_base_url: Option, +-- +2.33.0 + diff --git a/nestos-installer.spec b/nestos-installer.spec index 5fb8e15..1b6108f 100644 --- a/nestos-installer.spec +++ b/nestos-installer.spec @@ -9,7 +9,7 @@ Name: rust-nestos-installer Version: 0.16.0 -Release: 4 +Release: 5 Summary: Installer for NestOS License: Apache-2.0 @@ -18,6 +18,7 @@ Source0: https://gitee.com/openeuler/nestos-installer/repository/archive/ Source1: %{crate}-%{version}-vendor.tar.gz Patch01: fix-nestos-installer-iso-command-error.patch Patch02: modify-coreos-rootflags-to-fix-nestos-install-problem.patch +Patch03: 0001-Block-unsupported-functions-and-modify-the-coreos-to-nestos.patch BuildRequires: rust-packaging openssl-devel zstd-devel BuildRequires: systemd @@ -110,6 +111,9 @@ This subpackage contains boot-time infrastructure for NestOS. It is not needed %changelog +* Wed Jun 05 2024 duyiwei - 0.16.0-5 +- Block unsupported functions and modify the coreos to nestos + * Fri Sep 22 2023 duyiwei7w - 0.16.0-4 - modify-coreos-rootflags-to-fix-nestos-install-problem