mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-20 20:04:19 +08:00
Initial self-hosting support
This commit is contained in:
parent
0e3209c1ad
commit
0d307fa4e7
4
clean.sh
4
clean.sh
@ -5,14 +5,14 @@ source config.sh
|
||||
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
recipes="$(target/release/list_recipes --short)"
|
||||
recipes="$(list_recipes --short)"
|
||||
else
|
||||
recipes="$@"
|
||||
fi
|
||||
|
||||
for recipe_name in $recipes
|
||||
do
|
||||
recipe_path=`target/release/find_recipe $recipe_name`
|
||||
recipe_path=`find_recipe $recipe_name`
|
||||
|
||||
echo -e "\033[01;38;5;215mcook - clean $recipe_name\033[0m"
|
||||
rm -rf "${ROOT}/$recipe_path/target/${TARGET}"
|
||||
|
||||
20
config.sh
20
config.sh
@ -6,6 +6,11 @@ if [ -z "${TARGET}" ]
|
||||
then
|
||||
export TARGET=x86_64-unknown-redox
|
||||
fi
|
||||
if [ $(uname -s) = 'Redox' ]
|
||||
then
|
||||
export IS_REDOX="1"
|
||||
fi
|
||||
|
||||
ARCH="${TARGET%%-*}"
|
||||
HOST="$TARGET"
|
||||
if [ x"${HOST}" == x"riscv64gc-unknown-redox" ] ; then
|
||||
@ -14,7 +19,6 @@ fi
|
||||
|
||||
# Automatic variables
|
||||
ROOT="$(cd `dirname "$0"` && pwd)"
|
||||
export PATH="${ROOT}/bin:$PATH"
|
||||
|
||||
export AR="${HOST}-gcc-ar"
|
||||
export AS="${HOST}-as"
|
||||
@ -48,9 +52,21 @@ fi
|
||||
|
||||
export FIND
|
||||
|
||||
if [ ! "$(uname -s)" = "Redox" ]
|
||||
if [ -z "${IS_REDOX}" ]
|
||||
then
|
||||
function pkgar {
|
||||
"$ROOT/pkgar/target/release/pkgar" "$@"
|
||||
}
|
||||
function cook {
|
||||
"$ROOT/target/release/cook" "$@"
|
||||
}
|
||||
function repo_builder {
|
||||
"$ROOT/target/release/repo_builder" "$@"
|
||||
}
|
||||
function list_recipes {
|
||||
"$ROOT/target/release/list_recipes" "$@"
|
||||
}
|
||||
function find_recipe {
|
||||
"$ROOT/target/release/find_recipe" "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
2
fetch.sh
2
fetch.sh
@ -3,4 +3,4 @@ set -e
|
||||
|
||||
source config.sh
|
||||
|
||||
target/release/cook --fetch-only ${@:1}
|
||||
cook --fetch-only ${@:1}
|
||||
|
||||
@ -41,6 +41,7 @@ BINS=(
|
||||
hashsum
|
||||
head
|
||||
join
|
||||
install
|
||||
link
|
||||
ln
|
||||
ls
|
||||
|
||||
28
recipes/other/cookbook/recipe.toml
Normal file
28
recipes/other/cookbook/recipe.toml
Normal file
@ -0,0 +1,28 @@
|
||||
[source]
|
||||
git = "https://gitlab.redox-os.org/redox-os/cookbook.git"
|
||||
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
cookbook_cargo
|
||||
|
||||
mkdir -pv "${COOKBOOK_STAGE}/home/user/cookbook"
|
||||
cp -rv "${COOKBOOK_SOURCE}"/* "${COOKBOOK_STAGE}/home/user/cookbook"
|
||||
"""
|
||||
|
||||
[package]
|
||||
dependencies = [
|
||||
# TODO: When rust working, use this
|
||||
# "dev-essential",
|
||||
"autoconf",
|
||||
"automake",
|
||||
"gcc13",
|
||||
"git",
|
||||
"gnu-make",
|
||||
"libtool",
|
||||
"patch",
|
||||
"pkg-config",
|
||||
"pkgar",
|
||||
"sed",
|
||||
"wget",
|
||||
]
|
||||
@ -1,5 +1,14 @@
|
||||
#TODO finish libtool setup
|
||||
#TODO can build, not tested
|
||||
[source]
|
||||
tar = "https://ftpmirror.gnu.org/libtool/libtool-2.5.4.tar.gz"
|
||||
git = "https://gitlab.redox-os.org/redox-os/libtool"
|
||||
branch = "v2.5.4-redox"
|
||||
shallow_clone = true
|
||||
script = """
|
||||
./bootstrap \
|
||||
--skip-po \
|
||||
--force \
|
||||
--gnulib-srcdir=./gnulib
|
||||
"""
|
||||
|
||||
[build]
|
||||
template = "configure"
|
||||
|
||||
4
repo.sh
4
repo.sh
@ -26,9 +26,9 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
target/release/cook $COOK_OPT $recipes
|
||||
cook $COOK_OPT $recipes
|
||||
|
||||
repo="$ROOT/repo/$TARGET"
|
||||
mkdir -p "$repo"
|
||||
|
||||
target/release/repo_builder "$repo" $recipes
|
||||
repo_builder "$repo" $recipes
|
||||
|
||||
@ -17,7 +17,7 @@ use std::{
|
||||
use termion::{color, style};
|
||||
use walkdir::{DirEntry, WalkDir};
|
||||
|
||||
use cookbook::WALK_DEPTH;
|
||||
use cookbook::{is_redox, WALK_DEPTH};
|
||||
|
||||
fn remove_all(path: &Path) -> Result<(), String> {
|
||||
if path.is_dir() {
|
||||
@ -417,8 +417,9 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
|
||||
command.arg("-C").arg(&source_dir);
|
||||
command.arg("checkout").arg(rev);
|
||||
run_command(command)?;
|
||||
} else if !shallow_clone {
|
||||
} else if !shallow_clone && !is_redox() {
|
||||
//TODO: complicated stuff to check and reset branch to origin
|
||||
//TODO: redox can't undestand this (got exit status 1)
|
||||
let mut command = Command::new("bash");
|
||||
command.arg("-c").arg(
|
||||
r#"
|
||||
@ -556,9 +557,14 @@ fi"#,
|
||||
// Extract tar to source.tmp
|
||||
//TODO: use tar crate (how to deal with compression?)
|
||||
let mut command = Command::new("tar");
|
||||
command.arg("--extract");
|
||||
command.arg("--verbose");
|
||||
command.arg("--file").arg(&source_tar);
|
||||
if is_redox() {
|
||||
command.arg("xvf");
|
||||
} else {
|
||||
command.arg("--extract");
|
||||
command.arg("--verbose");
|
||||
command.arg("--file");
|
||||
}
|
||||
command.arg(&source_tar);
|
||||
command.arg("--directory").arg(&source_dir_tmp);
|
||||
command.arg("--strip-components").arg("1");
|
||||
run_command(command)?;
|
||||
@ -843,7 +849,10 @@ fn build(
|
||||
|
||||
let pre_script = r#"# Common pre script
|
||||
# Add cookbook bins to path
|
||||
if [ -z "${IS_REDOX}" ]
|
||||
then
|
||||
export PATH="${COOKBOOK_ROOT}/bin:${PATH}"
|
||||
fi
|
||||
|
||||
# This puts cargo build artifacts in the build directory
|
||||
export CARGO_TARGET_DIR="${COOKBOOK_BUILD}/target"
|
||||
@ -929,7 +938,12 @@ COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--enable-static
|
||||
)
|
||||
COOKBOOK_MAKE="make"
|
||||
if [ -z "${IS_REDOX}" ]
|
||||
then
|
||||
COOKBOOK_MAKE_JOBS="$(nproc)"
|
||||
else
|
||||
COOKBOOK_MAKE_JOBS="1"
|
||||
fi
|
||||
function cookbook_configure {
|
||||
"${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}" "$@"
|
||||
"${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}"
|
||||
@ -1128,22 +1142,29 @@ done
|
||||
//TODO: remove unwraps
|
||||
let cookbook_build = build_dir.canonicalize().unwrap();
|
||||
let cookbook_recipe = recipe_dir.canonicalize().unwrap();
|
||||
let cookbook_redoxer = Path::new("target/release/cookbook_redoxer")
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let cookbook_root = Path::new(".").canonicalize().unwrap();
|
||||
let cookbook_stage = stage_dir_tmp.canonicalize().unwrap();
|
||||
let cookbook_source = source_dir.canonicalize().unwrap();
|
||||
let cookbook_sysroot = sysroot_dir.canonicalize().unwrap();
|
||||
|
||||
let mut command = Command::new(&cookbook_redoxer);
|
||||
command.arg("env");
|
||||
command.arg("bash").arg("-ex");
|
||||
let mut command = if is_redox() {
|
||||
let mut command = Command::new("bash");
|
||||
command.arg("-ex");
|
||||
command.env("COOKBOOK_REDOXER", "cargo");
|
||||
command
|
||||
} else {
|
||||
let cookbook_redoxer = Path::new("target/release/cookbook_redoxer")
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let mut command = Command::new(&cookbook_redoxer);
|
||||
command.arg("env").arg("bash").arg("-ex");
|
||||
command.env("COOKBOOK_REDOXER", &cookbook_redoxer);
|
||||
command
|
||||
};
|
||||
command.current_dir(&cookbook_build);
|
||||
command.env("COOKBOOK_BUILD", &cookbook_build);
|
||||
command.env("COOKBOOK_NAME", name.as_str());
|
||||
command.env("COOKBOOK_RECIPE", &cookbook_recipe);
|
||||
command.env("COOKBOOK_REDOXER", &cookbook_redoxer);
|
||||
command.env("COOKBOOK_ROOT", &cookbook_root);
|
||||
command.env("COOKBOOK_STAGE", &cookbook_stage);
|
||||
command.env("COOKBOOK_SOURCE", &cookbook_source);
|
||||
|
||||
10
src/lib.rs
10
src/lib.rs
@ -5,3 +5,13 @@ mod progress_bar;
|
||||
|
||||
/// Default for maximum number of levels to descend down dependencies tree.
|
||||
pub const WALK_DEPTH: usize = 16;
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
pub fn is_redox() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
pub fn is_redox() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@ -5,14 +5,14 @@ source config.sh
|
||||
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
recipes="$(target/release/list_recipes --short)"
|
||||
recipes="$(list_recipes --short)"
|
||||
else
|
||||
recipes="$@"
|
||||
fi
|
||||
|
||||
for recipe_name in $recipes
|
||||
do
|
||||
recipe_path=`target/release/find_recipe $recipe_name`
|
||||
recipe_path=`find_recipe $recipe_name`
|
||||
|
||||
echo -e "\033[01;38;5;215mcook - unfetch $recipe_name\033[0m"
|
||||
rm -rfv "$recipe_path"/source "$recipe_path"/source.tar
|
||||
|
||||
Loading…
Reference in New Issue
Block a user