From 91ed850f66b2d2e80aa43118bc3970a4d224d273 Mon Sep 17 00:00:00 2001 From: Ryan Goodfellow Date: Sun, 27 Feb 2022 13:45:14 -0800 Subject: [PATCH 1/2] add p5p archive publisher command --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main.rs b/src/main.rs index 2f5cb78..3467d7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2519,6 +2519,27 @@ fn run_steps(ib: &mut ImageBuilder) -> Result<()> { &a.publisher, ])?; } + "pkg_set_p5p_publisher" => { + #[derive(Deserialize)] + struct PkgSetP5PPublisherArgs { + archive: String, + publisher: String, + } + + let a: PkgSetP5PPublisherArgs = step.args()?; + let mp = ib.root()?; + + pkg(log, &["-R", &mp.to_str().unwrap(), + "set-publisher", "-p", &a.archive, "--search-first", + ])?; + pkg(log, &["-R", &mp.to_str().unwrap(), "set-publisher", + "--no-refresh", + "--non-sticky", + &a.publisher, + ])?; + pkg(log, &["-R", &mp.to_str().unwrap(), "refresh", "--full"])?; + pkg(log, &["-R", &mp.to_str().unwrap(), "update"])?; + } "pkg_approve_ca_cert" => { #[derive(Deserialize)] struct PkgApproveCaCertArgs { From a8528194862aaea4fe33c6ec65e694aa16e95798 Mon Sep 17 00:00:00 2001 From: Ryan Goodfellow Date: Thu, 17 Mar 2022 12:13:58 -0700 Subject: [PATCH 2/2] review feedback updates --- src/main.rs | 54 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3467d7a..75fc503 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2507,23 +2507,58 @@ fn run_steps(ib: &mut ImageBuilder) -> Result<()> { #[derive(Deserialize)] struct PkgSetPublisherArgs { publisher: String, - uri: String, + uri: Option, + sticky: Option, } let a: PkgSetPublisherArgs = step.args()?; let mp = ib.root()?; - pkg(log, &["-R", &mp.to_str().unwrap(), "set-publisher", + let mut args = vec![ + "-R", &mp.to_str().unwrap(), "set-publisher", "--no-refresh", - "-O", &a.uri, - &a.publisher, - ])?; + ]; + + if let Some(ref uri) = a.uri { + args.push("-O"); + args.push(uri); + } + + if let Some(sticky) = a.sticky { + match sticky { + true => args.push("--sticky"), + false => args.push("--non-sticky"), + } + } + + args.push(&a.publisher); + + pkg(log, &args)?; + } + "pkg_refresh" => { + #[derive(Deserialize)] + struct PkgRefreshArgs { + full: bool, + } + + let a: PkgRefreshArgs = step.args()?; + let mp = ib.root()?; + + let mut args = vec!["-R", &mp.to_str().unwrap(), "refresh"]; + if a.full { + args.push("--full") + } + + pkg(log, &args)?; + } + "pkg_update" => { + let mp = ib.root()?; + pkg(log, &["-R", &mp.to_str().unwrap(), "update"])?; } "pkg_set_p5p_publisher" => { #[derive(Deserialize)] struct PkgSetP5PPublisherArgs { archive: String, - publisher: String, } let a: PkgSetP5PPublisherArgs = step.args()?; @@ -2532,13 +2567,6 @@ fn run_steps(ib: &mut ImageBuilder) -> Result<()> { pkg(log, &["-R", &mp.to_str().unwrap(), "set-publisher", "-p", &a.archive, "--search-first", ])?; - pkg(log, &["-R", &mp.to_str().unwrap(), "set-publisher", - "--no-refresh", - "--non-sticky", - &a.publisher, - ])?; - pkg(log, &["-R", &mp.to_str().unwrap(), "refresh", "--full"])?; - pkg(log, &["-R", &mp.to_str().unwrap(), "update"])?; } "pkg_approve_ca_cert" => { #[derive(Deserialize)]