diff options
author | Leonardo Neumann <leonardo@neumann.dev.br> | 2021-08-14 17:03:22 -0300 |
---|---|---|
committer | Georgy Yakovlev <gyakovlev@gentoo.org> | 2021-08-26 00:40:32 -0700 |
commit | 4b0b01717cd58331181101a7d94cdba88a912237 (patch) | |
tree | 558c40677067dc070ef950c33b2e0e177ec01870 | |
parent | Cargo.toml: bump version, update deps, remove badges (diff) | |
download | cargo-ebuild-4b0b01717cd58331181101a7d94cdba88a912237.tar.gz cargo-ebuild-4b0b01717cd58331181101a7d94cdba88a912237.tar.bz2 cargo-ebuild-4b0b01717cd58331181101a7d94cdba88a912237.zip |
Remove cargo-lock dependency
Closes: https://github.com/gentoo/cargo-ebuild/pull/7
Signed-off-by: Leonardo Neumann <leonardo@neumann.dev.br>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | src/lib.rs | 46 |
2 files changed, 7 insertions, 43 deletions
@@ -349,9 +349,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8cddc8fbbee11227ef194b5317ed014b8acbf15139bd716a18ad3fe99ec5" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" [[package]] name = "log" @@ -12,40 +12,15 @@ mod license; mod metadata; use anyhow::{format_err, Context, Result}; -use cargo_lock::Lockfile; use cargo_metadata::CargoOpt; use cargo_metadata::MetadataCommand; use std::collections::BTreeSet; use std::fs::OpenOptions; use std::path::{Path, PathBuf}; -use std::process::Command; use license::{normalize_license, split_spdx_license}; use metadata::EbuildConfig; -fn generate_lockfile(manifest_path: Option<PathBuf>) -> Result<()> { - let cargo = std::env::var("CARGO") - .map(PathBuf::from) - .unwrap_or_else(|_| PathBuf::from("cargo")); - - let mut lock_cmd = Command::new(cargo); - lock_cmd.arg("generate-lockfile"); - - if let Some(path) = manifest_path.as_ref() { - lock_cmd.arg("--manifest-path"); - lock_cmd.arg(path.as_os_str()); - } - - let lock_output = lock_cmd.output()?; - - if !lock_output.status.success() { - let stderr = String::from_utf8_lossy(&lock_output.stderr); - return Err(format_err!("unable to generate lockfile:\n{}", stderr)); - } - - Ok(()) -} - pub fn gen_ebuild_data(manifest_path: Option<PathBuf>) -> Result<EbuildConfig> { let mut cmd = MetadataCommand::new(); @@ -97,29 +72,18 @@ pub fn gen_ebuild_data(manifest_path: Option<PathBuf>) -> Result<EbuildConfig> { if pkg.license_file.is_some() { println!("WARNING: {} uses a license-file, not handled", pkg.name); } - } - let root_pkg = root_pkg - .ok_or_else(|| format_err!("unable to determine package to generate ebuild for"))?; - - let lockfile_path = metadata.workspace_root.join("Cargo.lock"); - - // Generate lockfile if it doesn't exists - if std::fs::metadata(&lockfile_path).is_err() { - generate_lockfile(manifest_path)?; - } - - // Check for packages that must be fetched from default registry - let lockfile = Lockfile::load(lockfile_path)?; - - for pkg in lockfile.packages { if let Some(src) = pkg.source { - if src.is_default_registry() { + // Check if the crate is available at crates.io + if src.is_crates_io() { crates.push(format!("\t{}-{}\n", pkg.name, pkg.version)); } } } + let root_pkg = root_pkg + .ok_or_else(|| format_err!("unable to determine package to generate ebuild for"))?; + Ok(EbuildConfig::from_package(root_pkg, crates, licenses)) } |