From 584a6e41c039313430dcd5faf175cbceddbedbbc Mon Sep 17 00:00:00 2001 From: Ribbon Date: Thu, 15 Aug 2024 14:54:36 +0000 Subject: [PATCH] Add scripts --- scripts/cargo-update.sh | 10 +++++++ scripts/executables.sh | 62 +++++++++++++++++++++++++++++++++++++++++ scripts/print-recipe.sh | 7 +++++ scripts/recipe-match.sh | 5 ++++ scripts/recipe-path.sh | 8 ++++++ 5 files changed, 92 insertions(+) create mode 100644 scripts/cargo-update.sh create mode 100644 scripts/executables.sh create mode 100644 scripts/print-recipe.sh create mode 100644 scripts/recipe-match.sh create mode 100644 scripts/recipe-path.sh diff --git a/scripts/cargo-update.sh b/scripts/cargo-update.sh new file mode 100644 index 0000000..cf38f07 --- /dev/null +++ b/scripts/cargo-update.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# This script runs "make f.recipe" and "cargo update" in the specified recipe + +recipe_name="$1" +recipe_path=$(find cookbook/recipes -name "$recipe_name" -maxdepth 4) + +make f."$recipe_name" +cd "$recipe_path"/source +cargo update diff --git a/scripts/executables.sh b/scripts/executables.sh new file mode 100644 index 0000000..e8422ad --- /dev/null +++ b/scripts/executables.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# This script print all recipe executable names to find duplicates and verify executable name conflicts + +usage() { + echo "List executable names to find duplicates" + echo "Usage: $0 [-h] [-a] [-arm64 | -i686] [recipes]" + echo "Default architecture is x86_64, -arm64 is aarch64, -i686 is i686" + echo "Only duplicates are listed unless -a is specified" + echo "-h is this message" + exit +} + +cd cookbook + +recipes="" + +target="x86_64-unknown-redox" +uniq="uniq -D --skip-fields=1" + +for arg in "${@:1}" +do + if [ "$arg" == "-arm64" ] + then + target="aarch64-unknown-redox" + elif [ "$arg" == "-i686" ] + then + target="i686-unknown-redox" + elif [ "$arg" == "-a" ] + then + uniq="cat" + elif [ "$arg" == "-h" ] + then + usage + else + recipes+=" $arg" + fi +done + +if [ -z "$recipes" ] +then + recipes="$(target/release/list_recipes)" +fi + +for recipe in $recipes +do + if [[ "$recipe" == *\/* ]] + then + recipe_name="$(basename $recipe)" + recipe_path="recipes/$recipe" + else + recipe_name="$recipe" + recipe_path="$(target/release/find_recipe $recipe_name)" + fi + + for command in $(find "$recipe_path/target/$target/stage/usr/bin" -type f 2> /dev/null) \ + $(find "$recipe_path/target/$target/stage/bin" -type f 2> /dev/null) + do + shortname="$(basename $command)" + echo "$recipe_path $shortname" + done +done | sort | $uniq diff --git a/scripts/print-recipe.sh b/scripts/print-recipe.sh new file mode 100644 index 0000000..773d85e --- /dev/null +++ b/scripts/print-recipe.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# This script print the recipe configuration + +cd cookbook + +cat $(target/release/find_recipe "$1")/recipe.* diff --git a/scripts/recipe-match.sh b/scripts/recipe-match.sh new file mode 100644 index 0000000..5bda158 --- /dev/null +++ b/scripts/recipe-match.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# This script print the recipe configuration files with determined text + +bat --decorations=always $(rg "$1" -li --sort=path cookbook/recipes) diff --git a/scripts/recipe-path.sh b/scripts/recipe-path.sh new file mode 100644 index 0000000..ceacd5e --- /dev/null +++ b/scripts/recipe-path.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +FIND_RECIPE="find cookbook/recipes -maxdepth 4 -name" + +for recipe in $* +do + ${FIND_RECIPE} "${recipe}" +done