diff --git a/Cargo.lock b/Cargo.lock index b3a1682..d097c0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,13 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" -dependencies = [ - "gimli", -] +version = 3 [[package]] name = "adler" @@ -24,6 +17,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "anyhow" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" + [[package]] name = "atty" version = "0.2.14" @@ -41,20 +40,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "backtrace" -version = "0.3.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.13.0" @@ -142,9 +127,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.0.0-beta.2" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142" +checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123" dependencies = [ "atty", "bitflags", @@ -155,15 +140,13 @@ dependencies = [ "strsim", "termcolor", "textwrap", - "unicode-width", - "vec_map", ] [[package]] name = "clap_derive" -version = "3.0.0-beta.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1" +checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" dependencies = [ "heck", "proc-macro-error", @@ -230,28 +213,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - [[package]] name = "fake-simd" version = "0.1.2" @@ -379,12 +340,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" - [[package]] name = "h2" version = "0.3.2" @@ -412,12 +367,9 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" -dependencies = [ - "unicode-segmentation", -] +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" @@ -563,7 +515,7 @@ checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae" name = "libips" version = "0.1.2" dependencies = [ - "failure", + "anyhow", "maplit 0.1.6", "object", "pest", @@ -571,6 +523,7 @@ dependencies = [ "regex", "sha2", "sha3", + "thiserror", ] [[package]] @@ -602,9 +555,9 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "mime" @@ -744,9 +697,12 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "2.4.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] [[package]] name = "percent-encoding" @@ -843,9 +799,8 @@ version = "0.0.1-placeholder" name = "pkg6dev" version = "0.1.1" dependencies = [ + "anyhow", "clap", - "failure", - "failure_derive", "libips", "userland", ] @@ -886,9 +841,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] @@ -1012,12 +967,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "rustc-demangle" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" - [[package]] name = "ryu" version = "1.0.5" @@ -1179,27 +1128,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.70" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9505f307c872bab8eb46f77ae357c8eba1fdacead58ee5a850116b1d7f82883" +checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] -[[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - [[package]] name = "tempfile" version = "3.2.0" @@ -1225,11 +1162,28 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.12.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "thiserror" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ - "unicode-width", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1348,18 +1302,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" - -[[package]] -name = "unicode-width" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" - [[package]] name = "unicode-xid" version = "0.2.1" @@ -1382,7 +1324,7 @@ dependencies = [ name = "userland" version = "0.1.1" dependencies = [ - "failure", + "anyhow", "maplit 0.1.6", "pest", "pest_derive", @@ -1398,12 +1340,6 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.3" diff --git a/libips/Cargo.toml b/libips/Cargo.toml index d64beeb..7123011 100644 --- a/libips/Cargo.toml +++ b/libips/Cargo.toml @@ -17,7 +17,8 @@ keywords = ["packaging", "illumos"] [dependencies] regex = "1.3.7" -failure = "0.1.8" +anyhow = "1.0.56" +thiserror = "1.0.30" maplit = "0.1.6" object = "0.23.0" sha2 = "0.9.3" diff --git a/libips/src/actions/mod.rs b/libips/src/actions/mod.rs index 55b1bdb..b039bd4 100644 --- a/libips/src/actions/mod.rs +++ b/libips/src/actions/mod.rs @@ -12,9 +12,9 @@ use std::clone::Clone; use crate::digest::Digest; use std::str::FromStr; use std::path::{Path}; -use std::fmt; -use crate::errors::Result; +use anyhow::{anyhow, Result}; use pest::Parser; +use thiserror::Error; pub trait FacetedAction { // Add a facet to the action if the facet is already present the function returns false. @@ -220,9 +220,9 @@ impl FacetedAction for File { } } -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum FileError { - #[fail(display = "file path is not a string")] + #[error("file path is not a string")] FilePathIsNoStringError, } @@ -459,8 +459,8 @@ impl Manifest { } } - pub fn parse_file(f: String) -> Result { - let content = read_to_string(Path::new(&f))?; + pub fn parse_file>(f: P) -> Result { + let content = read_to_string(f)?; Manifest::parse_string(content) } @@ -544,14 +544,14 @@ impl Default for ActionKind { } //TODO Multierror and no failure for these cases -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum ManifestError { - #[fail(display = "unknown action {} at line {}", action, line)] + #[error("unknown action {action:?} at line {line:?}")] UnknownAction { line: usize, action: String, }, - #[fail(display = "action string \"{}\" at line {} is invalid: {}", action, line, message)] + #[error("action string \"{action:?}\" at line {line:?} is invalid: {message:?}")] InvalidAction { line: usize, action: String, @@ -615,6 +615,6 @@ fn string_to_bool(orig: &str) -> Result { "false" => Ok(false), "t" => Ok(true), "f" => Ok(false), - _ => Err(failure::err_msg("not a boolean like value")) + _ => Err(anyhow!("not a boolean like value")) } } diff --git a/libips/src/digest/mod.rs b/libips/src/digest/mod.rs index 3de2d59..04f6525 100644 --- a/libips/src/digest/mod.rs +++ b/libips/src/digest/mod.rs @@ -3,10 +3,14 @@ // MPL was not distributed with this file, You can // obtain one at https://mozilla.org/MPL/2.0/. +use thiserror::Error; +use anyhow::Result; use std::str::FromStr; use sha2::{Digest as Sha2Digest}; +#[allow(unused_imports)] use sha3::{Digest as Sha3Digest}; +#[allow(dead_code)] static DEFAULT_ALGORITHM: DigestAlgorithm = DigestAlgorithm::SHA512; #[derive(Debug, PartialEq, Clone)] @@ -90,7 +94,7 @@ impl FromStr for Digest { } impl Digest { - pub fn from_bytes(b: &[u8], algo: DigestAlgorithm, src: DigestSource) -> Result { + pub fn from_bytes(b: &[u8], algo: DigestAlgorithm, src: DigestSource) -> Result { let hash = match algo { DigestAlgorithm::SHA256=> { format!("{:x}", sha2::Sha256::digest(b)) @@ -136,13 +140,13 @@ impl Digest { } } -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum DigestError { - #[fail(display = "hashing algorithm {} is not known by this library", algorithm)] + #[error("hashing algorithm {algorithm:?} is not known by this library")] UnknownAlgorithm { algorithm: String, }, - #[fail(display = "digest {} is not formatted properly: {}", digest, details)] + #[error("digest {digest:?} is not formatted properly: {details:?}")] InvalidDigestFormat{ digest: String, details: String, diff --git a/libips/src/lib.rs b/libips/src/lib.rs index 8e19eda..231207e 100644 --- a/libips/src/lib.rs +++ b/libips/src/lib.rs @@ -7,16 +7,8 @@ pub mod actions; pub mod digest; pub mod payload; -mod errors { - use failure::Error; - use std::result::Result as StdResult; - - pub type Result = StdResult; -} - extern crate pest; #[macro_use] extern crate pest_derive; -#[macro_use] extern crate failure; extern crate maplit; #[cfg(test)] diff --git a/libips/src/payload/mod.rs b/libips/src/payload/mod.rs index 1eaa8db..ac9c5fe 100644 --- a/libips/src/payload/mod.rs +++ b/libips/src/payload/mod.rs @@ -4,7 +4,7 @@ // obtain one at https://mozilla.org/MPL/2.0/. use crate::digest::{Digest, DigestAlgorithm, DigestSource}; -use failure::Error; +use anyhow::Error; use object::Object; use std::path::Path; diff --git a/pkg6dev/Cargo.toml b/pkg6dev/Cargo.toml index a69f8a3..ce3a9ea 100644 --- a/pkg6dev/Cargo.toml +++ b/pkg6dev/Cargo.toml @@ -14,6 +14,5 @@ keywords = ["packaging", "illumos"] [dependencies] libips = {path = "../libips", version = "0.1.1"} userland = {path = "../userland", version = "0.1.1"} -failure = "0.1.8" -failure_derive = "0.1.8" -clap = "~3.0.0-beta.2" \ No newline at end of file +anyhow = "1.0.56" +clap = {version = "3.1.6", features = [ "derive" ] } \ No newline at end of file diff --git a/pkg6dev/src/main.rs b/pkg6dev/src/main.rs index 850c933..7d798ea 100644 --- a/pkg6dev/src/main.rs +++ b/pkg6dev/src/main.rs @@ -1,69 +1,58 @@ -//#[macro_use] -//extern crate failure_derive; - -use clap::{app_from_crate, ArgMatches}; -use clap::{Arg, App}; +use clap::{Parser, Subcommand}; use libips::actions::{File, Manifest}; -mod errors { - use failure::Error; - use std::result::Result as StdResult; - - pub type Result = StdResult; -} - -use errors::Result; +use anyhow::Result; use std::collections::HashMap; use std::fs::{read_dir}; use std::path::Path; use userland::Makefile; use userland::repology::{find_newest_version}; -fn main() { - let component_arg = Arg::new("component") - .takes_value(true) - .default_value("../sample_data/pkgs/golang-116"); - //.default_value("./"); - let opts = app_from_crate!().subcommand(App::new("diff-component") - .about("shows differences between sample-manifest and manifests") - .arg(&component_arg) - ).subcommand(App::new("show-component") - .about("Show informations about the component") - .arg(&component_arg) - ).get_matches(); - //.get_matches_from(vec!["pkg6dev", "diff-component"]); - - if let Some(diff_component_opts) = opts.subcommand_matches("diff-component") { - let res = diff_component(diff_component_opts); - if res.is_err() { - println!("error: {:?}", res.unwrap_err()) - } - } - - if let Some(show_component_opts) = opts.subcommand_matches("show-component") { - let res = show_component_info(show_component_opts); - if res.is_err() { - println!("error: {:?}", res.unwrap_err()) - } - } - +#[derive(Parser, Debug)] +#[clap(author, version, about, long_about = None)] +#[clap(propagate_version = true)] +struct App { + #[clap(subcommand)] + command: Commands } -fn diff_component(matches: &ArgMatches) -> Result<()> { - let component_path = matches.value_of("component").unwrap(); +#[derive(Subcommand, Debug)] +enum Commands { + DiffComponent{ + component: String, + }, + ShowComponent{ + component: String, + }, +} - let files = read_dir(component_path)?; +fn main() -> Result<()> { + let cli = App::parse(); + + match &cli.command { + Commands::ShowComponent{ component } => { + show_component_info(component) + } + Commands::DiffComponent{component} => { + diff_component(component) + } + } +} + +fn diff_component(component_path: impl AsRef) -> Result<()> { + let files = read_dir(&component_path)?; let manifest_files: Vec = files .filter_map(std::result::Result::ok) .filter(|d| if let Some(e) = d.path().extension() { e == "p5m" } else {false}) .map(|e| e.path().into_os_string().into_string().unwrap()).collect(); - let sample_manifest_file = component_path.to_string() + "/manifests/sample-manifest.p5m"; + let sample_manifest_file = &component_path.as_ref().join("/manifests/sample-manifest.p5m"); let manifests_res: Result> = manifest_files.iter().map(|f|{ Manifest::parse_file(f.to_string()) }).collect(); + let sample_manifest = Manifest::parse_file(sample_manifest_file)?; let manifests: Vec = manifests_res.unwrap(); @@ -74,7 +63,7 @@ fn diff_component(matches: &ArgMatches) -> Result<()> { println!("file {} is missing in the manifests", f.path); } - let removed_files = find_removed_files(&sample_manifest, manifests.clone(), component_path)?; + let removed_files = find_removed_files(&sample_manifest, manifests.clone(), &component_path)?; for f in removed_files { println!("file path={} has been removed from the sample-manifest", f.path); @@ -83,12 +72,12 @@ fn diff_component(matches: &ArgMatches) -> Result<()> { Ok(()) } -fn show_component_info(opts: &ArgMatches) -> Result<()> { - let component_path = opts.value_of("component").unwrap(); +fn show_component_info>(component_path: P) -> Result<()> { + let makefile_path = component_path.as_ref().join("Makefile"); - let makefile = Makefile::parse_file(Path::new(&(component_path.to_string() + "/Makefile")))?; + println!("{:?}", makefile_path); - //println!("{:#?}", makefile); + let makefile = Makefile::parse_file(&makefile_path)?; let mut name = String::new(); @@ -139,7 +128,7 @@ fn show_component_info(opts: &ArgMatches) -> Result<()> { } // Show all files that have been removed in the sample-manifest -fn find_removed_files(sample_manifest: &Manifest, manifests: Vec, component_path: &str) -> Result> { +fn find_removed_files>(sample_manifest: &Manifest, manifests: Vec, component_path: P) -> Result> { let f_map = make_file_map(sample_manifest.files.clone()); let all_files: Vec = manifests.iter().map(|m| m.files.clone()).flatten().collect(); @@ -149,7 +138,7 @@ fn find_removed_files(sample_manifest: &Manifest, manifests: Vec, comp match f.get_original_path() { Some(path) => { if !f_map.contains_key(path.as_str()) { - if !Path::new(&(component_path.to_string() + "/" + path.as_str())).exists() { + if !component_path.as_ref().join(path).exists() { removed_files.push(f) } } diff --git a/sample_data/pkgs/golang-116/Makefile b/sample_data/pkgs/golang-116/Makefile index 3d9f0c5..24d6dcd 100644 --- a/sample_data/pkgs/golang-116/Makefile +++ b/sample_data/pkgs/golang-116/Makefile @@ -57,8 +57,8 @@ COMPONENT_BUILD_ENV += GOEXPERIMENT="$(GOEXPERIMENT)" COMPONENT_BUILD_ENV += GOOS="illumos" COMPONENT_BUILD_ENV += GOCACHE="$(SOURCE_DIR)/gocache" COMPONENT_BUILD_ENV += GOPATH="$(SOURCE_DIR)/gopath" -COMPONENT_BUILD_ENV += \ - GOROOT_BOOTSTRAP="/usr/lib/golang/$(COMPONENT_MAJOR_VERSION)" +# COMPONENT_BUILD_ENV += \ +# GOROOT_BOOTSTRAP="/usr/lib/golang/$(COMPONENT_MAJOR_VERSION)" # For convenience during installation of supplementary packages. COMPONENT_INSTALL_ENV += PATH="$(PROTO_DIR)$(GOROOT_FINAL)/bin:$(PATH)" @@ -74,16 +74,16 @@ include $(WS_MAKE_RULES)/common.mk # We have to fiddle with the package archives to get them into the same source # directory so that we can use the standard build targets. We're effectively # building multiple components using a single target. -COMPONENT_POST_UNPACK_ACTION= \ - $(MV) go $(COMPONENT_SRC) +# COMPONENT_POST_UNPACK_ACTION= \ +# $(MV) go $(COMPONENT_SRC) # Go doesn't have a standard Makefile-based build process, so override the # default. -COMPONENT_BUILD_ACTION= \ - cd $(@D)/src; $(ENV) $(COMPONENT_BUILD_ENV) ./make.bash +# COMPONENT_BUILD_ACTION= \ +# cd $(@D)/src; $(ENV) $(COMPONENT_BUILD_ENV) ./make.bash -COMPONENT_TARGET_DIR= \ - $(PROTOUSRLIBDIR)/$(COMPONENT_NAME)/$(COMPONENT_MAJOR_VERSION) +# COMPONENT_TARGET_DIR= \ +# $(PROTOUSRLIBDIR)/$(COMPONENT_NAME)/$(COMPONENT_MAJOR_VERSION) # We can't do any ASLR'ing as the Go 6l linker has no understanding of the # -z aslr=... option. So just override where needed in the .p5m files. @@ -97,24 +97,24 @@ COMPONENT_TEST_TARGETS= # Use this Command to copy the Go Source tree into the proto area. In order to deliver the Go SDK under GOROOT # Additionally nuke all the funky binary files used for test suites. They keep bothering the packaging tools -define COMPONENT_INSTALL_ACTION= - ($(MKDIR) $(COMPONENT_TARGET_DIR)/src); \ - (cd $(SOURCE_DIR) && \ - /usr/gnu/bin/find . -maxdepth 1 -path "./$(COMPONENT_SRC_NAME)" \ - -prune -o \( ! -iname ".*" \) -print \ - -exec /usr/gnu/bin/cp -r \ - --parents {} $(COMPONENT_TARGET_DIR) \;); \ - (cd $(BUILD_DIR_64) && \ - /usr/gnu/bin/find src -type f \ - -exec /usr/gnu/bin/cp --parents {} $(COMPONENT_TARGET_DIR) \;); \ - (cd $(BUILD_DIR_64) && $(CP) -r bin $(COMPONENT_TARGET_DIR)/); \ - (cd $(BUILD_DIR_64) && $(CP) -r pkg $(COMPONENT_TARGET_DIR)/); \ - (rm -r $(COMPONENT_TARGET_DIR)/pkg/obj); \ - ($(MKDIR) -p $(MEDIATEDUSRSHAREMAN1DIR)); \ - /usr/gnu/bin/find $(COMPONENT_TARGET_DIR)/src -type f \ - | egrep -v '\.go|\.s|\.bash|\.txt|\.c|\.tmpl|\.h|\.pl|\.md|\.S|\.py|\.dist|\.rc|\.bat|README|Makefile|\.awk|\.rules|\.mod|\.json|LICENSE|PATENTS'\ - | xargs rm; -endef +#define COMPONENT_INSTALL_ACTION= +# ($(MKDIR) $(COMPONENT_TARGET_DIR)/src); \ +# (cd $(SOURCE_DIR) && \ +# /usr/gnu/bin/find . -maxdepth 1 -path "./$(COMPONENT_SRC_NAME)" \ +# -prune -o \( ! -iname ".*" \) -print \ +# -exec /usr/gnu/bin/cp -r \ +# --parents {} $(COMPONENT_TARGET_DIR) \;); \ +# (cd $(BUILD_DIR_64) && \ +# /usr/gnu/bin/find src -type f \ +# -exec /usr/gnu/bin/cp --parents {} $(COMPONENT_TARGET_DIR) \;); \ +# (cd $(BUILD_DIR_64) && $(CP) -r bin $(COMPONENT_TARGET_DIR)/); \ +# (cd $(BUILD_DIR_64) && $(CP) -r pkg $(COMPONENT_TARGET_DIR)/); \ +# (rm -r $(COMPONENT_TARGET_DIR)/pkg/obj); \ +# ($(MKDIR) -p $(MEDIATEDUSRSHAREMAN1DIR)); \ +# /usr/gnu/bin/find $(COMPONENT_TARGET_DIR)/src -type f \ +# | egrep -v '\.go|\.s|\.bash|\.txt|\.c|\.tmpl|\.h|\.pl|\.md|\.S|\.py|\.dist|\.rc|\.bat|README|Makefile|\.awk|\.rules|\.mod|\.json|LICENSE|PATENTS'\ +# | xargs rm; +#endef REQUIRED_PACKAGES += developer/golang-115 # Auto-generated dependencies diff --git a/userland/Cargo.toml b/userland/Cargo.toml index 675319b..8e9f25b 100644 --- a/userland/Cargo.toml +++ b/userland/Cargo.toml @@ -9,7 +9,7 @@ description = "Helper tool for IPS package development" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -failure = "0.1.8" +anyhow = "1.0.56" pest_derive = "2.1.0" maplit = "0.1.6" pest = "2.1.0" diff --git a/userland/src/lib.rs b/userland/src/lib.rs index 683fb28..ecbb850 100644 --- a/userland/src/lib.rs +++ b/userland/src/lib.rs @@ -1,22 +1,16 @@ pub mod repology; extern crate pest; -#[macro_use] extern crate pest_derive; -#[macro_use] extern crate failure; -#[macro_use] extern crate serde; extern crate maplit; -mod errors { - use failure::Error; - use std::result::Result as StdResult; +#[macro_use] +extern crate pest_derive; - pub type Result = StdResult; -} -use errors::Result; +use anyhow::Result; use std::collections::HashMap; use std::fs::read_to_string; -use pest::iterators::{Pair, Pairs}; +use pest::iterators::{Pairs}; use std::path::Path; use pest::Parser; diff --git a/userland/src/repology.rs b/userland/src/repology.rs index d3d333a..3b4868c 100644 --- a/userland/src/repology.rs +++ b/userland/src/repology.rs @@ -1,17 +1,12 @@ extern crate reqwest; use reqwest::*; -use crate::errors::Result as EResult; +use anyhow::Result; use semver::Version; use serde::{Serialize, Deserialize}; const BASE_URL: &str = "https://repology.org/api/v1/"; -#[derive(Debug, Clone)] -pub struct RepologyClient { - client: reqwest::Client, -} - #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Package { repo: String, @@ -31,7 +26,7 @@ pub struct Package { pub fn project(package: &str) -> Result> { - let url = Url::parse(&format!("{}/project/{}",BASE_URL, package)).unwrap(); + let url = Url::parse(&format!("{}/project/{}",BASE_URL, package))?; let json = reqwest::blocking::get(url)? .json::>()?; @@ -39,9 +34,9 @@ pub fn project(package: &str) -> Result> { return Ok(json); } -pub fn find_newest_version(package: &str) -> EResult { +pub fn find_newest_version(package: &str) -> Result { let pkgs = project(package)?; - let version_res: EResult> = pkgs.iter().map(|p| -> EResult { + let version_res: Result> = pkgs.iter().map(|p| -> Result { let v = Version::parse(&p.version); if v.is_ok() { return Ok(v?);