mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-11-05 04:06:38 +08:00
Merge branch 'relibc-doc' into 'master'
Add a script for relibc documentation See merge request redox-os/redox!2209
This commit is contained in:
commit
9643e19446
@ -236,12 +236,11 @@ ucrp.%: $(FSTOOLS_TAG) FORCE
|
|||||||
$(MAKE) ucr.$*,--with-package-deps
|
$(MAKE) ucr.$*,--with-package-deps
|
||||||
$(MAKE) p.$*
|
$(MAKE) p.$*
|
||||||
|
|
||||||
ifeq ($(HOSTED_REDOX),1)
|
|
||||||
DESTDIR?=/
|
DESTDIR?=/
|
||||||
|
|
||||||
# Install all recipes specified by the filesystem config
|
# Install all recipes specified by the filesystem config
|
||||||
install:
|
install:
|
||||||
$(REPO_BIN) push $(COOKBOOK_OPTS) --with-package-deps "--sysroot=$(DESTDIR)"
|
$(REPO_BIN) push $(COOKBOOK_OPTS) --no-metadata --with-package-deps "--sysroot=$(DESTDIR)"
|
||||||
|
|
||||||
# Rebuild and install all recipes specified by the filesystem config
|
# Rebuild and install all recipes specified by the filesystem config
|
||||||
rebuild-install: $(FSTOOLS_TAG) FORCE
|
rebuild-install: $(FSTOOLS_TAG) FORCE
|
||||||
@ -250,7 +249,7 @@ rebuild-install: $(FSTOOLS_TAG) FORCE
|
|||||||
$(MAKE) install
|
$(MAKE) install
|
||||||
|
|
||||||
i.%: $(FSTOOLS_TAG) FORCE
|
i.%: $(FSTOOLS_TAG) FORCE
|
||||||
$(REPO_BIN) push $(COOKBOOK_OPTS) --with-package-deps "--sysroot=$(DESTDIR)"
|
$(REPO_BIN) push $* $(COOKBOOK_OPTS) --no-metadata --with-package-deps "--sysroot=$(DESTDIR)"
|
||||||
|
|
||||||
# Invoke rebuild and install for one of more targets separated by comma
|
# Invoke rebuild and install for one of more targets separated by comma
|
||||||
ri.%: $(FSTOOLS_TAG) FORCE
|
ri.%: $(FSTOOLS_TAG) FORCE
|
||||||
@ -266,7 +265,6 @@ cri.%: $(FSTOOLS_TAG) FORCE
|
|||||||
ucri.%: $(FSTOOLS_TAG) FORCE
|
ucri.%: $(FSTOOLS_TAG) FORCE
|
||||||
$(MAKE) ucr.$*,--with-package-deps
|
$(MAKE) ucr.$*,--with-package-deps
|
||||||
$(MAKE) i.$*
|
$(MAKE) i.$*
|
||||||
endif
|
|
||||||
|
|
||||||
# Set recipe rule to "binary" then invoke clean
|
# Set recipe rule to "binary" then invoke clean
|
||||||
bc.%: $(FSTOOLS_TAG) FORCE
|
bc.%: $(FSTOOLS_TAG) FORCE
|
||||||
|
|||||||
14
recipes/other/relibc-doc/recipe.toml
Normal file
14
recipes/other/relibc-doc/recipe.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[source]
|
||||||
|
same_as = "../../core/relibc"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
template = "custom"
|
||||||
|
script = """
|
||||||
|
cd "${COOKBOOK_SOURCE}${COOKBOOK_CARGO_PATH:+/$COOKBOOK_CARGO_PATH}"
|
||||||
|
export RUSTDOCFLAGS="--enable-index-page -Zunstable-options"
|
||||||
|
"${COOKBOOK_CARGO}" doc \
|
||||||
|
--target-dir "${COOKBOOK_BUILD}" --no-deps \
|
||||||
|
-j "${COOKBOOK_MAKE_JOBS}" ${COOKBOOK_CARGO_FLAGS[@]}
|
||||||
|
mkdir -p "${COOKBOOK_STAGE}/usr/share/doc/relibc"
|
||||||
|
cp -rv "${COOKBOOK_BUILD}/${TARGET}/doc"/* "${COOKBOOK_STAGE}/usr/share/doc/relibc/"
|
||||||
|
"""
|
||||||
7
scripts/relibc-doc.sh
Executable file
7
scripts/relibc-doc.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This script generates build/relibc-doc and build/relibc-doc.tar.gz
|
||||||
|
|
||||||
|
rm -rf build/relibc-doc build/relibc-doc.tar.gz
|
||||||
|
make ri.relibc-doc DESTDIR=./build/relibc-doc
|
||||||
|
tar -czvf ./build/relibc-doc.tar.gz ./build/relibc-doc/usr/share/doc/relibc/
|
||||||
@ -68,6 +68,7 @@ const REPO_HELP_STR: &str = r#"
|
|||||||
--filesystem=<filesystem> override recipes config using installer file
|
--filesystem=<filesystem> override recipes config using installer file
|
||||||
--repo-binary override recipes config to use repo_binary
|
--repo-binary override recipes config to use repo_binary
|
||||||
--sysroot=<sysroot_dir> used in "push", the "root" dir, default to $PWD/sysroot
|
--sysroot=<sysroot_dir> used in "push", the "root" dir, default to $PWD/sysroot
|
||||||
|
--no-metadata used in "push", do not write pkgar_head or etc dir
|
||||||
--set-rule=<rule> used in "change-rule", set wanted config rule
|
--set-rule=<rule> used in "change-rule", set wanted config rule
|
||||||
--rollback used in "capture-rev", allow git to rollback
|
--rollback used in "capture-rev", allow git to rollback
|
||||||
--unset used in "capture-rev" and "change-rule", unset locks
|
--unset used in "capture-rev" and "change-rule", unset locks
|
||||||
@ -97,6 +98,7 @@ struct CliConfig {
|
|||||||
filesystem: Option<redox_installer::Config>,
|
filesystem: Option<redox_installer::Config>,
|
||||||
set_rule: Option<String>,
|
set_rule: Option<String>,
|
||||||
unset: bool,
|
unset: bool,
|
||||||
|
no_metadata: bool,
|
||||||
with_rollback: bool,
|
with_rollback: bool,
|
||||||
with_package_deps: bool,
|
with_package_deps: bool,
|
||||||
all: bool,
|
all: bool,
|
||||||
@ -200,6 +202,7 @@ impl CliConfig {
|
|||||||
cook: get_config().cook.clone(),
|
cook: get_config().cook.clone(),
|
||||||
all: false,
|
all: false,
|
||||||
unset: false,
|
unset: false,
|
||||||
|
no_metadata: false,
|
||||||
filesystem: None,
|
filesystem: None,
|
||||||
with_rollback: false,
|
with_rollback: false,
|
||||||
set_rule: None,
|
set_rule: None,
|
||||||
@ -474,6 +477,7 @@ fn parse_args(args: Vec<String>) -> Result<(CliConfig, CliCommand, Vec<CookRecip
|
|||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--repo-binary" => override_filesystem_repo_binary = true,
|
"--repo-binary" => override_filesystem_repo_binary = true,
|
||||||
"--with-package-deps" => config.with_package_deps = true,
|
"--with-package-deps" => config.with_package_deps = true,
|
||||||
|
"--no-metadata" => config.no_metadata = true,
|
||||||
"--rollback" => config.with_rollback = true,
|
"--rollback" => config.with_rollback = true,
|
||||||
"--unset" => config.unset = true,
|
"--unset" => config.unset = true,
|
||||||
"--all" => config.all = true,
|
"--all" => config.all = true,
|
||||||
@ -855,7 +859,7 @@ fn handle_clean(recipe: &CookRecipe, _config: &CliConfig, command: &CliCommand)
|
|||||||
Ok(cached)
|
Ok(cached)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PUSH_SYSROOT_DIR: OnceLock<PathBuf> = OnceLock::new();
|
static PUSH_CONFIG: OnceLock<CliConfig> = OnceLock::new();
|
||||||
fn handle_push(recipes: &Vec<CookRecipe>, config: &CliConfig) -> Result<()> {
|
fn handle_push(recipes: &Vec<CookRecipe>, config: &CliConfig) -> Result<()> {
|
||||||
let recipe_map: HashMap<&PackageName, &CookRecipe> =
|
let recipe_map: HashMap<&PackageName, &CookRecipe> =
|
||||||
recipes.iter().map(|r| (&r.name, r)).collect();
|
recipes.iter().map(|r| (&r.name, r)).collect();
|
||||||
@ -863,7 +867,9 @@ fn handle_push(recipes: &Vec<CookRecipe>, config: &CliConfig) -> Result<()> {
|
|||||||
let mut total_count: u64 = 0;
|
let mut total_count: u64 = 0;
|
||||||
let mut visited: HashSet<PackageName> = HashSet::new();
|
let mut visited: HashSet<PackageName> = HashSet::new();
|
||||||
let num_recipes = recipes.len();
|
let num_recipes = recipes.len();
|
||||||
PUSH_SYSROOT_DIR.set(config.sysroot_dir.clone()).unwrap();
|
PUSH_CONFIG
|
||||||
|
.set(config.clone())
|
||||||
|
.unwrap_or_else(|_| panic!("PUSH_CONFIG is initialized"));
|
||||||
let handle_push_inner = move |package_name: &PackageName,
|
let handle_push_inner = move |package_name: &PackageName,
|
||||||
_prefix: &str,
|
_prefix: &str,
|
||||||
_is_last: bool,
|
_is_last: bool,
|
||||||
@ -874,11 +880,17 @@ fn handle_push(recipes: &Vec<CookRecipe>, config: &CliConfig) -> Result<()> {
|
|||||||
}
|
}
|
||||||
let r = match entry {
|
let r = match entry {
|
||||||
WalkTreeEntry::Built(archive_path, _) => {
|
WalkTreeEntry::Built(archive_path, _) => {
|
||||||
let install_path = PUSH_SYSROOT_DIR.get().unwrap();
|
let config = PUSH_CONFIG.get().unwrap();
|
||||||
let mut state = PackageState::from_sysroot(install_path).map_err(Error::from)?;
|
let install_path = &config.sysroot_dir;
|
||||||
let r = package_handle_push(&mut state, archive_path, &install_path, false);
|
let mut state = if !config.no_metadata {
|
||||||
if matches!(r, Ok(false)) {
|
Some(PackageState::from_sysroot(&install_path).map_err(Error::from)?)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let r = package_handle_push(state.as_mut(), archive_path, &install_path);
|
||||||
|
if matches!(r, Ok(false)) && state.is_some() {
|
||||||
state
|
state
|
||||||
|
.unwrap()
|
||||||
.to_sysroot(install_path)
|
.to_sysroot(install_path)
|
||||||
.map_err(|e| Error::from_io_error(e, "Extracting package"))?;
|
.map_err(|e| Error::from_io_error(e, "Extracting package"))?;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,18 +244,26 @@ fn get_package_name_inner(name: &str, package: Option<&str>) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn package_handle_push(
|
pub fn package_handle_push(
|
||||||
state: &mut PackageState,
|
state: Option<&mut PackageState>,
|
||||||
archive_path: &Path,
|
archive_path: &Path,
|
||||||
sysroot_dir: &Path,
|
sysroot_dir: &Path,
|
||||||
reinstall: bool,
|
|
||||||
) -> crate::Result<bool> {
|
) -> crate::Result<bool> {
|
||||||
let archive_toml = archive_path.with_extension("toml");
|
let archive_toml = archive_path.with_extension("toml");
|
||||||
let pkey_path = "build/id_ed25519.pub.toml";
|
let pkey_path = "build/id_ed25519.pub.toml";
|
||||||
let pkg_toml = Package::from_file(&archive_toml)?;
|
let pkg_toml = Package::from_file(&archive_toml)?;
|
||||||
// "local" is what remote name from installer is hardcoded into
|
// "local" is what remote name from installer is hardcoded into
|
||||||
let remote_name = "local".to_string();
|
let remote_name = "local".to_string();
|
||||||
|
let Some(state) = state else {
|
||||||
|
// Bare install without metadata, cache mechanism or anything
|
||||||
|
if archive_path.is_file() {
|
||||||
|
let pkey = PublicKeyFile::open(pkey_path)?.pkey;
|
||||||
|
let mut package = PackageFile::new(archive_path, &pkey)?;
|
||||||
|
Transaction::install(&mut package, sysroot_dir)?.commit()?;
|
||||||
|
}
|
||||||
|
return Ok(false);
|
||||||
|
};
|
||||||
let (cached, pstate) = match state.installed.get(&pkg_toml.name) {
|
let (cached, pstate) = match state.installed.get(&pkg_toml.name) {
|
||||||
Some(s) if !reinstall && pkg_toml.blake3 == s.blake3 => (true, None),
|
Some(s) if pkg_toml.blake3 == s.blake3 => (true, None),
|
||||||
Some(s) => (false, Some((s.manual, s.dependents.clone()))),
|
Some(s) => (false, Some((s.manual, s.dependents.clone()))),
|
||||||
None => {
|
None => {
|
||||||
// TODO: Handle manual & dependents
|
// TODO: Handle manual & dependents
|
||||||
@ -272,6 +280,10 @@ pub fn package_handle_push(
|
|||||||
"var/lib/packages/{}.pkgar_head",
|
"var/lib/packages/{}.pkgar_head",
|
||||||
pkg_toml.name.as_str()
|
pkg_toml.name.as_str()
|
||||||
));
|
));
|
||||||
|
let head_parent = head_path.parent();
|
||||||
|
if head_parent.is_some_and(|s| !s.is_dir()) {
|
||||||
|
create_dir(head_parent.unwrap())?;
|
||||||
|
}
|
||||||
package.split(&head_path, None::<&Path>)?;
|
package.split(&head_path, None::<&Path>)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user