From 0d307fa4e7bea0a51110f28b9bed94220569fbc6 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 12 Sep 2025 21:39:51 +0000 Subject: [PATCH] Initial self-hosting support --- clean.sh | 4 +- config.sh | 20 +++++++++- fetch.sh | 2 +- recipes/core/uutils/recipe.toml | 1 + recipes/other/cookbook/recipe.toml | 28 ++++++++++++++ recipes/wip/libs/other/libtool/recipe.toml | 13 ++++++- repo.sh | 4 +- src/bin/cook.rs | 45 ++++++++++++++++------ src/lib.rs | 10 +++++ unfetch.sh | 4 +- 10 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 recipes/other/cookbook/recipe.toml diff --git a/clean.sh b/clean.sh index e26dba32..6f7d0b0f 100755 --- a/clean.sh +++ b/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}" diff --git a/config.sh b/config.sh index 71131eb8..c3eccb17 100755 --- a/config.sh +++ b/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 diff --git a/fetch.sh b/fetch.sh index 2a1e87a9..73da2648 100755 --- a/fetch.sh +++ b/fetch.sh @@ -3,4 +3,4 @@ set -e source config.sh -target/release/cook --fetch-only ${@:1} +cook --fetch-only ${@:1} diff --git a/recipes/core/uutils/recipe.toml b/recipes/core/uutils/recipe.toml index 56fcb14d..2f2d8573 100644 --- a/recipes/core/uutils/recipe.toml +++ b/recipes/core/uutils/recipe.toml @@ -41,6 +41,7 @@ BINS=( hashsum head join + install link ln ls diff --git a/recipes/other/cookbook/recipe.toml b/recipes/other/cookbook/recipe.toml new file mode 100644 index 00000000..9b24639a --- /dev/null +++ b/recipes/other/cookbook/recipe.toml @@ -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", +] diff --git a/recipes/wip/libs/other/libtool/recipe.toml b/recipes/wip/libs/other/libtool/recipe.toml index 9086e63c..4788b7a5 100644 --- a/recipes/wip/libs/other/libtool/recipe.toml +++ b/recipes/wip/libs/other/libtool/recipe.toml @@ -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" diff --git a/repo.sh b/repo.sh index f2458005..ddc0e779 100755 --- a/repo.sh +++ b/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 diff --git a/src/bin/cook.rs b/src/bin/cook.rs index a5d60997..945df17d 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -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) -> Result bool { + true +} + +#[cfg(not(target_os = "redox"))] +pub fn is_redox() -> bool { + false +} diff --git a/unfetch.sh b/unfetch.sh index 6763ff82..ba273e87 100755 --- a/unfetch.sh +++ b/unfetch.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 - unfetch $recipe_name\033[0m" rm -rfv "$recipe_path"/source "$recipe_path"/source.tar