Skip to content

[🚀 Feature]: Configurable selenium-manager build  #15009

Open
@tjuhaszrh

Description

@tjuhaszrh

Feature and motivation

Hello,

To package selenium-manager for Fedora (and likely for other distributions), it is essential to download all dependencies from the distribution's repository. However, selenium-manager depends on packages such as debpkg or apple-flat-pkg, which are not available in Fedora and are unlikely to be included. This causes build failures due to missing dependencies.

It would be beneficial if the build process were more configurable to accommodate specific environments. Currently, the workaround involves manually patching and removing unnecessary dependencies and the functions that rely on them, which is not ideal.

Usage example

Configuring selenium-manager: Making Unavailable Dependencies Optional

[package]
name = "selenium-manager"
version = "1.0.0"
edition = "2021"

[dependencies]
clap = { version = "4.5.20", features = ["derive", "cargo"] }
log = "0.4.22"
env_logger = "0.11.5"
regex = "1.11.0"
tokio = { version = "1.40.0", default-features = false, features = ["macros", "net", "rt-multi-thread"] }
tempfile = "3.13.0"
reqwest = { version = "0.12.8", default-features = false, features = ["rustls-tls"] }
zip = { version = "2.2.0", default-features = false, features = ["deflate-zlib"] }
directories = "5.0.1"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
flate2 = "1.0.34"
tar = "0.4.42"
walkdir = "2.5.0"
exitcode = "1.1.2"
toml = "0.8.19"
bzip2 = "0.4.4"
anyhow = { version = "1.0.89", default-features = false, features = ["backtrace", "std"] }
which = "6.0.3"

# Optional dependencies (platform-specific)
sevenz-rust = { version = "0.6.1", optional = true }
infer = { version = "0.16.0", optional = true }
debpkg = { version = "0.6.0", optional = true }
apple-flat-package = { version = "0.18.0", optional = true }

// Making changes to files.rs to make it configurable
// Removing dependencies and logic related to optional packages

- use crate::{format_one_arg, format_three_args, run_shell_command_by_os, Command, Logger, CP_VOLUME_COMMAND, HDIUTIL_ATTACH_COMMAND, HDIUTIL_DETACH_COMMAND, MACOS, MSIEXEC_INSTALL_COMMAND};
+ use crate::{Logger};  // Keep only essential imports mandatory

use anyhow::anyhow;
use anyhow::Error;

// Removed dependencies that require optional features:
- use apple_flat_package::PkgReader;
use bzip2::read::BzDecoder;
use directories::BaseDirs;
use flate2::read::GzDecoder;

// Removed constants related to unsupported formats when optional dependencies aren't included:
- const ZIP: &str = "zip";
- const GZ: &str = "gz";
- const XML: &str = "xml";
- const HTML: &str = "html";
- const BZ2: &str = "bz2";
- const PKG: &str = "pkg";
- const DMG: &str = "dmg";
- const EXE: &str = "exe";
- const DEB: &str = "deb";
- const MSI: &str = "msi";
- const SEVEN_ZIP_HEADER: &[u8; 6] = b"7z\xBC\xAF\x27\x1C";
- const UNCOMPRESS_MACOS_ERR_MSG: &str = "{} files are only supported in macOS";

// Handling compression formats conditionally when dependencies are available
#[cfg(feature = "sevenz-rust")]
pub fn uncompress_sfx(compressed_file: &str, target: &Path, log: &Logger) -> Result<(), Error> {
    // Decompressing logic that requires 'sevenz-rust'
    sevenz_rust::decompress(...);
}

// Similarly for other dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-rustRust code is mostly Selenium ManagerI-enhancementSomething could be better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions