mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-24 05:44:17 +08:00
Fix web optional packages, sort file tree
This commit is contained in:
parent
34c62b53fe
commit
b113987aa7
@ -8,6 +8,7 @@ use pkgar::ext::PackageSrcExt;
|
||||
use pkgar_core::HeaderFlags;
|
||||
|
||||
use crate::{
|
||||
Error,
|
||||
config::CookConfig,
|
||||
cook::{cook_build::BuildResult, fetch, fs::*, pty::PtyOut},
|
||||
log_to_pty,
|
||||
@ -29,6 +30,7 @@ pub fn package(
|
||||
target_dir.join("stage.toml"),
|
||||
recipe,
|
||||
None,
|
||||
None,
|
||||
recipe.recipe.package.dependencies.clone(),
|
||||
&auto_deps,
|
||||
)?;
|
||||
@ -109,6 +111,7 @@ pub fn package(
|
||||
package_meta,
|
||||
recipe,
|
||||
Some((Path::new(public_path), &package_file)),
|
||||
package,
|
||||
package_deps,
|
||||
&deps,
|
||||
)?;
|
||||
@ -122,6 +125,7 @@ pub fn package_toml(
|
||||
toml_path: PathBuf,
|
||||
recipe: &CookRecipe,
|
||||
package_file: Option<(&Path, &PathBuf)>,
|
||||
package_suffix: Option<&OptionalPackageRecipe>,
|
||||
mut package_deps: Vec<PackageName>,
|
||||
auto_deps: &BTreeSet<PackageName>,
|
||||
) -> Result<(), String> {
|
||||
@ -149,9 +153,13 @@ pub fn package_toml(
|
||||
)
|
||||
})?;
|
||||
let package_size = mt.len();
|
||||
let storage_size = match package.header().flags.packaging() {
|
||||
let header = package.header();
|
||||
let storage_size = match header.flags.packaging() {
|
||||
pkgar_core::Packaging::LZMA2 => {
|
||||
let mut size = 0;
|
||||
let mut size = header
|
||||
.total_size()
|
||||
.map_err(|e| Error::Pkgar(pkgar::Error::Core(e)))?
|
||||
as u64;
|
||||
let entries = package
|
||||
.read_entries()
|
||||
.map_err(|e| format!("Unable to get lzma entry: {e}"))?;
|
||||
@ -183,7 +191,11 @@ pub fn package_toml(
|
||||
let ident_source = fetch::fetch_get_source_info(recipe)?;
|
||||
|
||||
let package = Package {
|
||||
name: recipe.name.with_prefix(PackagePrefix::Any),
|
||||
name: PackageName::new(get_package_name(
|
||||
recipe.name.without_prefix(),
|
||||
package_suffix,
|
||||
))
|
||||
.unwrap(),
|
||||
version: recipe.guess_version().unwrap_or("TODO".into()),
|
||||
target: recipe.target.to_string(),
|
||||
blake3: hash,
|
||||
|
||||
@ -149,7 +149,8 @@ pub fn walk_file_tree(dir: &PathBuf, prefix: &str, buffer: &mut String) -> std::
|
||||
return Ok(0);
|
||||
}
|
||||
let fmt_err = std::io::Error::other;
|
||||
let entries: Vec<_> = std::fs::read_dir(dir)?.filter_map(|e| e.ok()).collect();
|
||||
let mut entries: Vec<_> = std::fs::read_dir(dir)?.filter_map(|e| e.ok()).collect();
|
||||
entries.sort_by(|a, b| a.file_name().cmp(&b.file_name()));
|
||||
let mut total_size = 0;
|
||||
for (index, entry) in entries.iter().enumerate() {
|
||||
let path = entry.path();
|
||||
|
||||
@ -214,7 +214,7 @@ impl CookRecipe {
|
||||
pub fn new(name: PackageName, dir: PathBuf, mut recipe: Recipe) -> Result<Self, PackageError> {
|
||||
let target = cook_package::package_target(&name);
|
||||
if name.is_host() {
|
||||
let thisname = name.name();
|
||||
let thisname = name.without_host();
|
||||
let fn_map = |p: PackageName| {
|
||||
if p.is_host() {
|
||||
if p.name() == thisname { None } else { Some(p) }
|
||||
|
||||
@ -95,8 +95,8 @@ pub fn new_recursive(
|
||||
}
|
||||
}
|
||||
|
||||
// list ordered success packages and map of failed packages
|
||||
// a package can be both success and failed if dependencies aren't satistied
|
||||
/// List ordered success packages and map of failed packages.
|
||||
/// A package can be both success and failed if dependencies aren't satistied.
|
||||
pub fn new_recursive_nonstop(
|
||||
names: &[PackageName],
|
||||
recursion: usize,
|
||||
@ -137,7 +137,7 @@ pub fn new_recursive_nonstop(
|
||||
has_invalid_dependency = true;
|
||||
}
|
||||
}
|
||||
// TODO: this if check is redundant
|
||||
// TODO: this check is redundant
|
||||
if !packages_map.contains_key(name) {
|
||||
packages_map.insert(
|
||||
name.clone(),
|
||||
|
||||
@ -66,11 +66,11 @@ pub fn generate_web(all_packages: &Vec<String>, config: &CliWebConfig) {
|
||||
let Some(recipe_path) = staged_pkg::find(package_name.name()) else {
|
||||
continue;
|
||||
};
|
||||
let Ok(package) = staged_pkg::from_path(&recipe_path, package_name.suffix()) else {
|
||||
let Ok(mut package) = staged_pkg::from_path(&recipe_path, package_name.suffix()) else {
|
||||
// TODO: report failed build
|
||||
continue;
|
||||
};
|
||||
let Ok(recipe) = CookRecipe::from_path(&recipe_path, true, false) else {
|
||||
let Ok(mut recipe) = CookRecipe::from_path(&recipe_path, true, false) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -81,6 +81,11 @@ pub fn generate_web(all_packages: &Vec<String>, config: &CliWebConfig) {
|
||||
.insert(package.name.to_string());
|
||||
}
|
||||
|
||||
// TODO: temporary bug fix in the suffix lost
|
||||
package.name = package_name.clone();
|
||||
// CookRecipe::from_path always have no suffix
|
||||
recipe.name = package_name;
|
||||
|
||||
valid_packages.push((package, recipe));
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ pub fn generate_html_pkg(
|
||||
&config.this_repo,
|
||||
host,
|
||||
&package.commit_identifier,
|
||||
Some(&format!("recipes/{category}/{name}/recipe.toml")),
|
||||
Some(&format!("recipes/{category}/{}/recipe.toml", name.name())),
|
||||
);
|
||||
let short_commit = get_short_commit(&package.commit_identifier);
|
||||
source_html += &format!(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user