pub fn verify(&self, golden_path: String) -> Result<HashSet<String>> {
        let build_path = PathBuf::from(self.build_path.clone());
        let config = Config::run_command_with_runtime(
            CommandBuilder::new("static.pkgs").build(),
            RuntimeConfig {
                model: ModelConfig {
                    build_path: build_path.clone(),
                    zbi_path: self.zbi_path.clone(),
                    blob_manifest_path: PathBuf::from(self.manifest_path.clone()),
                    ..ModelConfig::minimal()
                },
                logging: LoggingConfig { silent_mode: true, ..LoggingConfig::minimal() },
                plugin: PluginConfig {
                    plugins: vec!["DevmgrConfigPlugin".to_string(), "StaticPkgsPlugin".to_string()],
                },
                ..RuntimeConfig::minimal()
            },
        );

        let scrutiny_output =
            launcher::launch_from_config(config).context("Failed to run static.pkgs")?;
        let static_pkgs_result: StaticPkgsCollection = serde_json::from_str(&scrutiny_output)
            .context(format!(
                "Failed to parse static.pkgs JSON output as structured static packages list: {}",
                scrutiny_output
            ))?;
        if static_pkgs_result.errors.len() > 0 {
            return Err(anyhow!("static.pkgs reported errors: {:#?}", static_pkgs_result.errors));
        }
        if static_pkgs_result.static_pkgs.is_none() {
            return Err(anyhow!("static.pkgs returned empty result"));
        }
        let static_pkgs = static_pkgs_result.static_pkgs.unwrap();

        // Drop trailing "/0" from package URLs; skip any that do not follow this convention.
        let static_package_urls: Vec<String> = static_pkgs
            .into_iter()
            .filter_map(|(mut url, _)| {
                if url.ends_with("/0") {
                    url.truncate(url.len() - 2);
                    Some(url)
                } else {
                    None
                }
            })
            .collect();

        let mut golden_reader = FileArtifactReader::new(&build_path, &build_path);
        let golden_contents =
            golden_reader.read_raw(&golden_path).context("Failed to read golden file")?;
        let golden_file = GoldenFile::from_contents(golden_path.clone(), golden_contents)
            .context("Failed to parse golden file")?;
        match golden_file.compare(static_package_urls) {
            CompareResult::Matches => Ok(static_pkgs_result
                .deps
                .union(&golden_reader.get_deps())
                .map(String::from)
                .collect()),
            CompareResult::Mismatch { errors } => {
                println!("Static package file mismatch");
                println!("");
                for error in errors.iter() {
                    println!("{}", error);
                }
                println!("");
                println!("If you intended to change the static package contents, please acknowledge it by updating {} with the added or removed lines.", golden_path);
                println!("{}", SOFT_TRANSITION_MSG);
                Err(anyhow!("static file mismatch"))
            }
        }
    }
/// The static package verifier extracts the system_image_hash from the devmgr config
/// inside the ZBI. It uses this to extract the static_packages_hash which contains
/// the list of static_packages. This list is compared against the golden file.
The static package verifier extracts the system_image_hash from the devmgr config
inside the ZBI. It uses this to extract the static_packages_hash which contains
the list of static_packages. This list is compared against the golden file.
The static package verifier extracts the system_image_hash from the devmgr config inside the ZBI . It uses this to extract the static_packages_hash which contains the list of static_packages . This list is compared against the golden file .
pub fn verify(&self, golden_path: String) -> Result<HashSet<String>> {
        let build_path = PathBuf::from(self.build_path.clone());
        let config = Config::run_command_with_runtime(
            CommandBuilder::new("static.pkgs").build(),
            RuntimeConfig {
                model: ModelConfig {
                    build_path: build_path.clone(),
                    zbi_path: self.zbi_path.clone(),
                    blob_manifest_path: PathBuf::from(self.manifest_path.clone()),
                    ..ModelConfig::minimal()
                },
                logging: LoggingConfig { silent_mode: true, ..LoggingConfig::minimal() },
                plugin: PluginConfig {
                    plugins: vec!["DevmgrConfigPlugin".to_string(), "StaticPkgsPlugin".to_string()],
                },
                ..RuntimeConfig::minimal()
            },
        );
        let scrutiny_output =
            launcher::launch_from_config(config).context("Failed to run static.pkgs")?;
        let static_pkgs_result: StaticPkgsCollection = serde_json::from_str(&scrutiny_output)
            .context(format!(
                "Failed to parse static.pkgs JSON output as structured static packages list: {}",
                scrutiny_output
            ))?;
        if static_pkgs_result.errors.len() > 0 {
            return Err(anyhow!("static.pkgs reported errors: {:#?}", static_pkgs_result.errors));
        }
        if static_pkgs_result.static_pkgs.is_none() {
            return Err(anyhow!("static.pkgs returned empty result"));
        }
        let static_pkgs = static_pkgs_result.static_pkgs.unwrap();
        // Drop trailing "/0" from package URLs; skip any that do not follow this convention.
        let static_package_urls: Vec<String> = static_pkgs
            .into_iter()
            .filter_map(|(mut url, _)| {
                if url.ends_with("/0") {
                    url.truncate(url.len() - 2);
                    Some(url)
                } else {
                    None
                }
            })
            .collect();
        let mut golden_reader = FileArtifactReader::new(&build_path, &build_path);
        let golden_contents =
            golden_reader.read_raw(&golden_path).context("Failed to read golden file")?;
        let golden_file = GoldenFile::from_contents(golden_path.clone(), golden_contents)
            .context("Failed to parse golden file")?;
        match golden_file.compare(static_package_urls) {
            CompareResult::Matches => Ok(static_pkgs_result
                .deps
                .union(&golden_reader.get_deps())
                .map(String::from)
                .collect()),
            CompareResult::Mismatch { errors } => {
                println!("Static package file mismatch");
                println!("");
                for error in errors.iter() {
                    println!("{}", error);
                }
                println!("");
                println!("If you intended to change the static package contents, please acknowledge it by updating {} with the added or removed lines.", golden_path);
                println!("{}", SOFT_TRANSITION_MSG);
                Err(anyhow!("static file mismatch"))
            }
        }
    }
pub fn verify ( & self , golden_path : String ) -> Result < HashSet < String > > { let build_path = PathBuf :: from ( self . build_path . clone ( ) ) ; let config = Config :: run_command_with_runtime ( CommandBuilder :: new ( " " ) . build ( ) , RuntimeConfig { model : ModelConfig { build_path : build_path . clone ( ) , zbi_path : self . zbi_path . clone ( ) , blob_manifest_path : PathBuf :: from ( self . manifest_path . clone ( ) ) , .. ModelConfig :: minimal ( ) } , logging : LoggingConfig { silent_mode : true , .. LoggingConfig :: minimal ( ) } , plugin : PluginConfig { plugins : vec ! [ " " to_string ( ) " " to_string ( ) ] , } , .. RuntimeConfig :: minimal ( ) } , ) ; let scrutiny_output = launcher :: launch_from_config ( config ) . context ( " " ) ? ; let static_pkgs_result : StaticPkgsCollection = serde_json :: from_str ( & scrutiny_output ) . context ( format ! ( " " scrutiny_output ) ) ? ; if static_pkgs_result . errors . len ( ) > 0 { return Err ( anyhow ! ( " " static_pkgs_result errors ) ) ; } if static_pkgs_result . static_pkgs . is_none ( ) { return Err ( anyhow ! ( " " ) ) ; } let static_pkgs = static_pkgs_result . static_pkgs . unwrap ( ) ; // Drop trailing "/0" from package URLs; skip any that do not follow this convention. let static_package_urls : Vec < String > = static_pkgs . into_iter ( ) . filter_map ( | ( mut url , _ ) | { if url . ends_with ( " " ) { url . truncate ( url . len ( ) - 2 ) ; Some ( url ) } else { None } } ) . collect ( ) ; let mut golden_reader = FileArtifactReader :: new ( & build_path , & build_path ) ; let golden_contents = golden_reader . read_raw ( & golden_path ) . context ( " " ) ? ; let golden_file = GoldenFile :: from_contents ( golden_path . clone ( ) , golden_contents ) . context ( " " ) ? ; match golden_file . compare ( static_package_urls ) { CompareResult :: Matches => Ok ( static_pkgs_result . deps . union ( & golden_reader . get_deps ( ) ) . map ( String :: from ) . collect ( ) ) , CompareResult :: Mismatch { errors } => { println ! ( " " ) ; println ! ( " " ) ; for error in errors . iter ( ) { println ! ( " " error ) ; } println ! ( " " ) ; println ! ( " " golden_path ) ; println ! ( " " SOFT_TRANSITION_MSG ) ; Err ( anyhow ! ( " " ) ) } } }
The static package verifier extracts the system_image_hash from the devmgr config
inside the ZBI.
The static package verifier extracts the system_image_hash from the devmgr config inside the ZBI .
&self
golden_path
String
&self
golden_path
String