pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pitchfork: fix build using upstream patch



Module Name:	pkgsrc-wip
Committed By:	Thomas Klausner <wiz%NetBSD.org@localhost>
Pushed By:	wiz
Date:		Thu May 7 10:14:34 2026 +0200
Changeset:	d4758345698555c43e7251d116e2ad27ec1f868e

Modified Files:
	pitchfork/PLIST
	pitchfork/distinfo
Added Files:
	pitchfork/patches/patch-src_boot__manager.rs
Removed Files:
	pitchfork/TODO

Log Message:
pitchfork: fix build using upstream patch

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=d4758345698555c43e7251d116e2ad27ec1f868e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 pitchfork/PLIST                              |   4 +-
 pitchfork/TODO                               | 104 ------
 pitchfork/distinfo                           |   1 +
 pitchfork/patches/patch-src_boot__manager.rs | 464 +++++++++++++++++++++++++++
 4 files changed, 466 insertions(+), 107 deletions(-)

diffs:
diff --git a/pitchfork/PLIST b/pitchfork/PLIST
index 92ba51a2d7..0163e63e3d 100644
--- a/pitchfork/PLIST
+++ b/pitchfork/PLIST
@@ -1,4 +1,2 @@
 @comment $NetBSD$
-@comment TODO: to fill this file with the file listing:
-@comment TODO: 1. run "/usr/bin/make package"
-@comment TODO: 2. run "/usr/bin/make print-PLIST"
+bin/pitchfork
diff --git a/pitchfork/TODO b/pitchfork/TODO
deleted file mode 100644
index 7a6b6479d3..0000000000
--- a/pitchfork/TODO
+++ /dev/null
@@ -1,104 +0,0 @@
-https://github.com/endevco/pitchfork/discussions/428
-
-error: pitchfork boot management is only supported on macOS, Linux, and Windows
-   --> src/boot_manager.rs:100:9
-    |
-100 |         compile_error!("pitchfork boot management is only supported on macOS, Linux, and Windows");
-    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0425]: cannot find value `current` in this scope
-   --> src/boot_manager.rs:110:19
-    |
- 32 |     current: AutoLaunch,
-    |     ------- a field by that name exists in `Self`
-...
-110 |         Ok(Self { current, other })
-    |                   ^^^^^^^
-    |
-help: consider importing this function
-    |
-  1 + use std::thread::current;
-    |
-
-error[E0425]: cannot find value `other` in this scope
-   --> src/boot_manager.rs:110:28
-    |
- 34 |     other: AutoLaunch,
-    |     ----- a field by that name exists in `Self`
-...
-110 |         Ok(Self { current, other })
-    |                            ^^^^^
-
-warning: unused import: `AutoLaunchBuilder`
- --> src/boot_manager.rs:6:33
-  |
-6 | use auto_launcher::{AutoLaunch, AutoLaunchBuilder};
-  |                                 ^^^^^^^^^^^^^^^^^
-  |
-  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:121:25
-    |
-121 |         Ok(self.current.is_enabled().into_diagnostic()?
-    |                         ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:122:27
-    |
-122 |             || self.other.is_enabled().into_diagnostic()?)
-    |                           ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:127:22
-    |
-127 |         self.current.is_enabled().into_diagnostic()
-    |                      ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:141:20
-    |
-141 |         self.other.is_enabled().into_diagnostic()
-    |                    ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:183:41
-    |
-183 |         let other_conflict = self.other.is_enabled().into_diagnostic()?;
-    |                                         ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `enable` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:193:22
-    |
-193 |         self.current.enable().into_diagnostic()?;
-    |                      ^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:207:25
-    |
-207 |         if self.current.is_enabled().into_diagnostic()? {
-    |                         ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `disable` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:208:26
-    |
-208 |             self.current.disable().into_diagnostic()?;
-    |                          ^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `is_enabled` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:210:23
-    |
-210 |         if self.other.is_enabled().into_diagnostic()? {
-    |                       ^^^^^^^^^^ method not found in `AutoLaunch`
-
-error[E0599]: no method named `disable` found for struct `AutoLaunch` in the current scope
-   --> src/boot_manager.rs:211:24
-    |
-211 |             self.other.disable().into_diagnostic()?;
-    |                        ^^^^^^^ method not found in `AutoLaunch`
-
-Some errors have detailed explanations: E0425, E0599.
-For more information about an error, try `rustc --explain E0425`.
-warning: `pitchfork-cli` (lib) generated 1 warning
-error: could not compile `pitchfork-cli` (lib) due to 13 previous errors; 1 warning emitted
-*** Error code 101
diff --git a/pitchfork/distinfo b/pitchfork/distinfo
index 751d3e3b7b..8830ac8813 100644
--- a/pitchfork/distinfo
+++ b/pitchfork/distinfo
@@ -1638,3 +1638,4 @@ Size (zerovec-derive-0.11.3.crate) = 22115 bytes
 BLAKE2s (zmij-1.0.21.crate) = a2d1e7214230c8f4e8c946d28215765c131da3aac89f1001daf534335307648e
 SHA512 (zmij-1.0.21.crate) = a488f11ec8721ddfe42e61d028a128818551de8fccd69d7824504e4ae2efccdc38f716fa5a10ef4de07a8a087e75e819c4a1e0790817e8539b5db697bde14585
 Size (zmij-1.0.21.crate) = 26665 bytes
+SHA1 (patch-src_boot__manager.rs) = e974c935de8fab547948c4a761d6e4ebaa4dafc8
diff --git a/pitchfork/patches/patch-src_boot__manager.rs b/pitchfork/patches/patch-src_boot__manager.rs
new file mode 100644
index 0000000000..90ea72e0a8
--- /dev/null
+++ b/pitchfork/patches/patch-src_boot__manager.rs
@@ -0,0 +1,464 @@
+$NetBSD$
+
+suit for non-Windows/MacOS/Linux build
+https://github.com/endevco/pitchfork/pull/429
+
+--- src/boot_manager.rs.orig	2026-05-05 14:39:28.000000000 +0000
++++ src/boot_manager.rs
+@@ -1,219 +1,279 @@
+-use crate::{Result, env};
+-#[cfg(target_os = "linux")]
+-use auto_launcher::LinuxLaunchMode;
+-#[cfg(target_os = "macos")]
+-use auto_launcher::MacOSLaunchMode;
+-use auto_launcher::{AutoLaunch, AutoLaunchBuilder};
+-use miette::IntoDiagnostic;
++// ─── Supported platforms (macOS, Linux, Windows) ──────────────────────────
+ 
+-#[cfg(any(target_os = "macos", target_os = "linux"))]
+-fn build_launcher(
+-    app_path: &str,
+-    #[cfg(target_os = "macos")] macos_mode: MacOSLaunchMode,
+-    #[cfg(target_os = "linux")] linux_mode: LinuxLaunchMode,
+-) -> Result<AutoLaunch> {
+-    let mut builder = AutoLaunchBuilder::new();
+-    builder
+-        .set_app_name("pitchfork")
+-        .set_app_path(app_path)
+-        .set_args(&["supervisor", "run", "--boot"]);
+-
++#[cfg(any(target_os = "macos", target_os = "linux", windows))]
++mod imp {
++    use crate::{Result, env};
++    #[cfg(target_os = "linux")]
++    use auto_launcher::LinuxLaunchMode;
+     #[cfg(target_os = "macos")]
+-    builder.set_macos_launch_mode(macos_mode);
++    use auto_launcher::MacOSLaunchMode;
++    use auto_launcher::{AutoLaunch, AutoLaunchBuilder};
++    use miette::IntoDiagnostic;
+ 
+-    #[cfg(target_os = "linux")]
+-    builder.set_linux_launch_mode(linux_mode);
++    #[cfg(any(target_os = "macos", target_os = "linux"))]
++    fn build_launcher(
++        app_path: &str,
++        #[cfg(target_os = "macos")] macos_mode: MacOSLaunchMode,
++        #[cfg(target_os = "linux")] linux_mode: LinuxLaunchMode,
++    ) -> Result<AutoLaunch> {
++        let mut builder = AutoLaunchBuilder::new();
++        builder
++            .set_app_name("pitchfork")
++            .set_app_path(app_path)
++            .set_args(&["supervisor", "run", "--boot"]);
+ 
+-    builder.build().into_diagnostic()
+-}
++        #[cfg(target_os = "macos")]
++        builder.set_macos_launch_mode(macos_mode);
+ 
+-pub struct BootManager {
+-    /// The launcher matching the current privilege level (used for enable).
+-    current: AutoLaunch,
+-    /// The other level's launcher (used to detect cross-level registrations).
+-    other: AutoLaunch,
+-    /// Legacy macOS LaunchAgentSystem entry (pre-1.0.3 used /Library/LaunchAgents/
+-    /// instead of /Library/LaunchDaemons/ for root). Kept only for migration/cleanup.
+-    #[cfg(target_os = "macos")]
+-    legacy: AutoLaunch,
+-}
++        #[cfg(target_os = "linux")]
++        builder.set_linux_launch_mode(linux_mode);
+ 
+-impl BootManager {
+-    pub fn new() -> Result<Self> {
+-        let app_path = env::PITCHFORK_BIN.to_string_lossy().to_string();
++        builder.build().into_diagnostic()
++    }
+ 
++    pub struct BootManager {
++        /// The launcher matching the current privilege level (used for enable).
++        current: AutoLaunch,
++        /// The other level's launcher (used to detect cross-level registrations).
++        other: AutoLaunch,
++        /// Legacy macOS LaunchAgentSystem entry (pre-1.0.3 used /Library/LaunchAgents/
++        /// instead of /Library/LaunchDaemons/ for root). Kept only for migration/cleanup.
+         #[cfg(target_os = "macos")]
+-        let (current, other, legacy) = {
+-            let is_root = nix::unistd::Uid::effective().is_root();
+-            let (current_mode, other_mode) = if is_root {
++        legacy: AutoLaunch,
++    }
++
++    impl BootManager {
++        pub fn new() -> Result<Self> {
++            let app_path = env::PITCHFORK_BIN.to_string_lossy().to_string();
++
++            #[cfg(target_os = "macos")]
++            let (current, other, legacy) = {
++                let is_root = nix::unistd::Uid::effective().is_root();
++                let (current_mode, other_mode) = if is_root {
++                    (
++                        MacOSLaunchMode::LaunchDaemonSystem,
++                        MacOSLaunchMode::LaunchAgentUser,
++                    )
++                } else {
++                    (
++                        MacOSLaunchMode::LaunchAgentUser,
++                        MacOSLaunchMode::LaunchDaemonSystem,
++                    )
++                };
+                 (
+-                    MacOSLaunchMode::LaunchDaemonSystem,
+-                    MacOSLaunchMode::LaunchAgentUser,
++                    build_launcher(&app_path, current_mode)?,
++                    build_launcher(&app_path, other_mode)?,
++                    build_launcher(&app_path, MacOSLaunchMode::LaunchAgentSystem)?,
+                 )
+-            } else {
++            };
++
++            #[cfg(target_os = "linux")]
++            let (current, other) = {
++                let is_root = nix::unistd::Uid::effective().is_root();
++                let (current_mode, other_mode) = if is_root {
++                    (LinuxLaunchMode::SystemdSystem, LinuxLaunchMode::SystemdUser)
++                } else {
++                    (LinuxLaunchMode::SystemdUser, LinuxLaunchMode::SystemdSystem)
++                };
+                 (
+-                    MacOSLaunchMode::LaunchAgentUser,
+-                    MacOSLaunchMode::LaunchDaemonSystem,
++                    build_launcher(&app_path, current_mode)?,
++                    build_launcher(&app_path, other_mode)?,
+                 )
+             };
+-            (
+-                build_launcher(&app_path, current_mode)?,
+-                build_launcher(&app_path, other_mode)?,
+-                build_launcher(&app_path, MacOSLaunchMode::LaunchAgentSystem)?,
+-            )
+-        };
+ 
+-        #[cfg(target_os = "linux")]
+-        let (current, other) = {
+-            let is_root = nix::unistd::Uid::effective().is_root();
+-            let (current_mode, other_mode) = if is_root {
+-                (LinuxLaunchMode::SystemdSystem, LinuxLaunchMode::SystemdUser)
+-            } else {
+-                (LinuxLaunchMode::SystemdUser, LinuxLaunchMode::SystemdSystem)
+-            };
+-            (
+-                build_launcher(&app_path, current_mode)?,
+-                build_launcher(&app_path, other_mode)?,
+-            )
+-        };
++            // On Windows there is no root/user distinction; build two identical
++            // launchers (AutoLaunch does not implement Clone).
++            #[cfg(windows)]
++            let (current, other) = (
++                AutoLaunchBuilder::new()
++                    .set_app_name("pitchfork")
++                    .set_app_path(&app_path)
++                    .set_args(&["supervisor", "run", "--boot"])
++                    .build()
++                    .into_diagnostic()?,
++                AutoLaunchBuilder::new()
++                    .set_app_name("pitchfork")
++                    .set_app_path(&app_path)
++                    .set_args(&["supervisor", "run", "--boot"])
++                    .build()
++                    .into_diagnostic()?,
++            );
+ 
+-        // On Windows there is no root/user distinction; build two identical
+-        // launchers (AutoLaunch does not implement Clone).
+-        #[cfg(windows)]
+-        let (current, other) = (
+-            AutoLaunchBuilder::new()
+-                .set_app_name("pitchfork")
+-                .set_app_path(&app_path)
+-                .set_args(&["supervisor", "run", "--boot"])
+-                .build()
+-                .into_diagnostic()?,
+-            AutoLaunchBuilder::new()
+-                .set_app_name("pitchfork")
+-                .set_app_path(&app_path)
+-                .set_args(&["supervisor", "run", "--boot"])
+-                .build()
+-                .into_diagnostic()?,
+-        );
++            #[cfg(target_os = "macos")]
++            return Ok(Self {
++                current,
++                other,
++                legacy,
++            });
+ 
+-        // Unsupported platforms: auto_launcher only supports macOS, Linux, and Windows.
+-        #[cfg(not(any(target_os = "macos", target_os = "linux", windows)))]
+-        compile_error!("pitchfork boot management is only supported on macOS, Linux, and Windows");
++            #[cfg(not(target_os = "macos"))]
++            Ok(Self { current, other })
++        }
+ 
+-        #[cfg(target_os = "macos")]
+-        return Ok(Self {
+-            current,
+-            other,
+-            legacy,
+-        });
++        /// Whether any registration (user- or system-level) exists.
++        pub fn is_enabled(&self) -> Result<bool> {
++            #[cfg(target_os = "macos")]
++            return Ok(self.current.is_enabled().into_diagnostic()?
++                || self.other.is_enabled().into_diagnostic()?
++                || self.legacy.is_enabled().into_diagnostic()?);
+ 
+-        #[cfg(not(target_os = "macos"))]
+-        Ok(Self { current, other })
+-    }
++            #[cfg(not(target_os = "macos"))]
++            Ok(self.current.is_enabled().into_diagnostic()?
++                || self.other.is_enabled().into_diagnostic()?)
++        }
+ 
+-    /// Whether any registration (user- or system-level) exists.
+-    pub fn is_enabled(&self) -> Result<bool> {
+-        #[cfg(target_os = "macos")]
+-        return Ok(self.current.is_enabled().into_diagnostic()?
+-            || self.other.is_enabled().into_diagnostic()?
+-            || self.legacy.is_enabled().into_diagnostic()?);
++        /// Whether a registration at the *current* privilege level exists.
++        pub fn is_current_level_enabled(&self) -> Result<bool> {
++            self.current.is_enabled().into_diagnostic()
++        }
+ 
+-        #[cfg(not(target_os = "macos"))]
+-        Ok(self.current.is_enabled().into_diagnostic()?
+-            || self.other.is_enabled().into_diagnostic()?)
+-    }
++        /// Whether a registration at the *other* privilege level exists.
++        /// Used to warn the user about cross-level mismatches.
++        /// On macOS, includes legacy entries for non-root callers (they are at a
++        /// different privilege level) but not for root callers (legacy is same level).
++        pub fn is_other_level_enabled(&self) -> Result<bool> {
++            #[cfg(target_os = "macos")]
++            return Ok(self.other.is_enabled().into_diagnostic()?
++                || (!nix::unistd::Uid::effective().is_root()
++                    && self.legacy.is_enabled().into_diagnostic()?));
+ 
+-    /// Whether a registration at the *current* privilege level exists.
+-    pub fn is_current_level_enabled(&self) -> Result<bool> {
+-        self.current.is_enabled().into_diagnostic()
+-    }
++            #[cfg(not(target_os = "macos"))]
++            self.other.is_enabled().into_diagnostic()
++        }
+ 
+-    /// Whether a registration at the *other* privilege level exists.
+-    /// Used to warn the user about cross-level mismatches.
+-    /// On macOS, includes legacy entries for non-root callers (they are at a
+-    /// different privilege level) but not for root callers (legacy is same level).
+-    pub fn is_other_level_enabled(&self) -> Result<bool> {
++        /// Remove legacy macOS LaunchAgentSystem entry if present and caller is root.
++        /// Idempotent — safe to call on every enable path, including retries after
++        /// partial migration (new entry written but legacy removal failed).
++        ///
++        /// `migrated`: true when called after writing a new LaunchDaemonSystem entry
++        /// (full migration); false when just removing a stale leftover.
+         #[cfg(target_os = "macos")]
+-        return Ok(self.other.is_enabled().into_diagnostic()?
+-            || (!nix::unistd::Uid::effective().is_root()
+-                && self.legacy.is_enabled().into_diagnostic()?));
++        pub fn cleanup_legacy(&self, migrated: bool) -> Result<()> {
++            if nix::unistd::Uid::effective().is_root()
++                && self.legacy.is_enabled().into_diagnostic()?
++            {
++                self.legacy.disable().into_diagnostic()?;
++                if migrated {
++                    info!(
++                        "migrated legacy system-level launch entry from /Library/LaunchAgents/ to /Library/LaunchDaemons/"
++                    );
++                } else {
++                    info!("removed legacy system-level launch entry from /Library/LaunchAgents/");
++                }
++            }
++            Ok(())
++        }
+ 
+-        #[cfg(not(target_os = "macos"))]
+-        self.other.is_enabled().into_diagnostic()
+-    }
++        /// Register at the current privilege level.
++        ///
++        /// Returns an error if a registration at the other privilege level already
++        /// exists, preventing user-level and system-level entries from coexisting.
++        ///
++        /// On macOS, migrates any legacy LaunchAgentSystem entry (from pre-1.0.3)
++        /// to the correct LaunchDaemonSystem entry.
++        pub fn enable(&self) -> Result<()> {
++            // For root, legacy will be migrated so only check non-legacy other level.
++            // For non-root, legacy cannot be migrated and is also a conflict.
++            #[cfg(target_os = "macos")]
++            let other_conflict = if nix::unistd::Uid::effective().is_root() {
++                self.other.is_enabled().into_diagnostic()?
++            } else {
++                self.is_other_level_enabled()?
++            };
+ 
+-    /// Remove legacy macOS LaunchAgentSystem entry if present and caller is root.
+-    /// Idempotent — safe to call on every enable path, including retries after
+-    /// partial migration (new entry written but legacy removal failed).
+-    ///
+-    /// `migrated`: true when called after writing a new LaunchDaemonSystem entry
+-    /// (full migration); false when just removing a stale leftover.
+-    #[cfg(target_os = "macos")]
+-    pub fn cleanup_legacy(&self, migrated: bool) -> Result<()> {
+-        if nix::unistd::Uid::effective().is_root() && self.legacy.is_enabled().into_diagnostic()? {
+-            self.legacy.disable().into_diagnostic()?;
+-            if migrated {
+-                info!(
+-                    "migrated legacy system-level launch entry from /Library/LaunchAgents/ to /Library/LaunchDaemons/"
++            #[cfg(not(target_os = "macos"))]
++            let other_conflict = self.other.is_enabled().into_diagnostic()?;
++
++            if other_conflict {
++                miette::bail!(
++                    "boot start is already registered at the other privilege level; \
++                    run `pitchfork boot disable` (with appropriate privileges) to remove \
++                    it first"
+                 );
+-            } else {
+-                info!("removed legacy system-level launch entry from /Library/LaunchAgents/");
+             }
++
++            self.current.enable().into_diagnostic()?;
++
++            #[cfg(target_os = "macos")]
++            self.cleanup_legacy(true)?;
++
++            Ok(())
+         }
+-        Ok(())
++
++        /// Remove registrations at *both* levels so cross-level leftovers are also
++        /// cleaned up. Also removes legacy macOS LaunchAgentSystem entries when
++        /// running as root. Returns Ok even if some entries could not be removed
++        /// due to insufficient privileges — callers should check is_enabled()
++        /// afterwards to detect incomplete cleanup.
++        pub fn disable(&self) -> Result<()> {
++            if self.current.is_enabled().into_diagnostic()? {
++                self.current.disable().into_diagnostic()?;
++            }
++            if self.other.is_enabled().into_diagnostic()? {
++                self.other.disable().into_diagnostic()?;
++            }
++            #[cfg(target_os = "macos")]
++            if nix::unistd::Uid::effective().is_root()
++                && self.legacy.is_enabled().into_diagnostic()?
++            {
++                self.legacy.disable().into_diagnostic()?;
++            }
++            Ok(())
++        }
+     }
++}
+ 
+-    /// Register at the current privilege level.
+-    ///
+-    /// Returns an error if a registration at the other privilege level already
+-    /// exists, preventing user-level and system-level entries from coexisting.
+-    ///
+-    /// On macOS, migrates any legacy LaunchAgentSystem entry (from pre-1.0.3)
+-    /// to the correct LaunchDaemonSystem entry.
+-    pub fn enable(&self) -> Result<()> {
+-        // For root, legacy will be migrated so only check non-legacy other level.
+-        // For non-root, legacy cannot be migrated and is also a conflict.
+-        #[cfg(target_os = "macos")]
+-        let other_conflict = if nix::unistd::Uid::effective().is_root() {
+-            self.other.is_enabled().into_diagnostic()?
+-        } else {
+-            self.is_other_level_enabled()?
+-        };
++// ─── Unsupported platforms ────────────────────────────────────────────────
+ 
+-        #[cfg(not(target_os = "macos"))]
+-        let other_conflict = self.other.is_enabled().into_diagnostic()?;
++#[cfg(not(any(target_os = "macos", target_os = "linux", windows)))]
++mod imp {
++    use crate::Result;
+ 
+-        if other_conflict {
++    pub struct BootManager;
++
++    impl BootManager {
++        pub fn new() -> Result<Self> {
+             miette::bail!(
+-                "boot start is already registered at the other privilege level; \
+-                run `pitchfork boot disable` (with appropriate privileges) to remove \
+-                it first"
+-            );
++                "boot management is not supported on this platform; \
++                only macOS, Linux, and Windows are supported"
++            )
+         }
+ 
+-        self.current.enable().into_diagnostic()?;
++        pub fn is_enabled(&self) -> Result<bool> {
++            miette::bail!(
++                "boot management is not supported on this platform; \
++                only macOS, Linux, and Windows are supported"
++            )
++        }
+ 
+-        #[cfg(target_os = "macos")]
+-        self.cleanup_legacy(true)?;
++        pub fn is_current_level_enabled(&self) -> Result<bool> {
++            miette::bail!(
++                "boot management is not supported on this platform; \
++                only macOS, Linux, and Windows are supported"
++            )
++        }
+ 
+-        Ok(())
+-    }
++        pub fn is_other_level_enabled(&self) -> Result<bool> {
++            miette::bail!(
++                "boot management is not supported on this platform; \
++                only macOS, Linux, and Windows are supported"
++            )
++        }
+ 
+-    /// Remove registrations at *both* levels so cross-level leftovers are also
+-    /// cleaned up. Also removes legacy macOS LaunchAgentSystem entries when
+-    /// running as root. Returns Ok even if some entries could not be removed
+-    /// due to insufficient privileges — callers should check is_enabled()
+-    /// afterwards to detect incomplete cleanup.
+-    pub fn disable(&self) -> Result<()> {
+-        if self.current.is_enabled().into_diagnostic()? {
+-            self.current.disable().into_diagnostic()?;
++        pub fn enable(&self) -> Result<()> {
++            miette::bail!(
++                "boot management is not supported on this platform; \
++                only macOS, Linux, and Windows are supported"
++            )
+         }
+-        if self.other.is_enabled().into_diagnostic()? {
+-            self.other.disable().into_diagnostic()?;
++
++        pub fn disable(&self) -> Result<()> {
++            miette::bail!(
++                "boot management is not supported on this platform; \
++                only macOS, Linux, and Windows are supported"
++            )
+         }
+-        #[cfg(target_os = "macos")]
+-        if nix::unistd::Uid::effective().is_root() && self.legacy.is_enabled().into_diagnostic()? {
+-            self.legacy.disable().into_diagnostic()?;
+-        }
+-        Ok(())
+     }
+ }
++
++pub use imp::BootManager;


Home | Main Index | Thread Index | Old Index