From b57551a9feb507f92cc611432974580cd780dd9a Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 4 Oct 2019 13:28:58 +0200 Subject: [PATCH] :fire: help => scripts --- docs.mk | 2 +- {help => scripts}/afl-dict/keyword.dict | 0 {help => scripts}/afl-dict/sum | 0 {help => scripts}/afl-dict/symbol.dict | 0 {help => scripts}/afl.sh | 0 {help => scripts}/doc-config.sh | 0 scripts/gwion-pkg | 71 +++++++++++++++++++++++++ {help => scripts}/opcode.sh | 0 {help => scripts}/struct_check.sh | 0 {help => scripts}/supp | 0 {help => scripts}/test.sh | 2 +- tests/sh/plugin.sh | 2 +- tests/sh/test.sh | 2 +- 13 files changed, 75 insertions(+), 4 deletions(-) rename {help => scripts}/afl-dict/keyword.dict (100%) rename {help => scripts}/afl-dict/sum (100%) rename {help => scripts}/afl-dict/symbol.dict (100%) rename {help => scripts}/afl.sh (100%) rename {help => scripts}/doc-config.sh (100%) create mode 100644 scripts/gwion-pkg rename {help => scripts}/opcode.sh (100%) rename {help => scripts}/struct_check.sh (100%) rename {help => scripts}/supp (100%) rename {help => scripts}/test.sh (99%) diff --git a/docs.mk b/docs.mk index 6461e166..0bd17945 100644 --- a/docs.mk +++ b/docs.mk @@ -6,7 +6,7 @@ include docs/config.mk mdr_list = $(filter-out docs/09_Benchmarks.mdr, $(shell find docs -type f -name "*.mdr")) md_list = $(mdr_list:.mdr=.md) -_docserver_config = bash help/doc-config.sh > mkdocs.yml +_docserver_config = bash scripts/doc-config.sh > mkdocs.yml _docserver_serve = $(call _docserver_config); $(DOCTOOL) -q serve _docserver_launch = $(call _docserver_serve)& echo $$! > .server_pid _docserver_kill = [ -f .server_pid ] && (kill $$(cat .server_pid); rm .server_pid) || true diff --git a/help/afl-dict/keyword.dict b/scripts/afl-dict/keyword.dict similarity index 100% rename from help/afl-dict/keyword.dict rename to scripts/afl-dict/keyword.dict diff --git a/help/afl-dict/sum b/scripts/afl-dict/sum similarity index 100% rename from help/afl-dict/sum rename to scripts/afl-dict/sum diff --git a/help/afl-dict/symbol.dict b/scripts/afl-dict/symbol.dict similarity index 100% rename from help/afl-dict/symbol.dict rename to scripts/afl-dict/symbol.dict diff --git a/help/afl.sh b/scripts/afl.sh similarity index 100% rename from help/afl.sh rename to scripts/afl.sh diff --git a/help/doc-config.sh b/scripts/doc-config.sh similarity index 100% rename from help/doc-config.sh rename to scripts/doc-config.sh diff --git a/scripts/gwion-pkg b/scripts/gwion-pkg new file mode 100644 index 00000000..a8033996 --- /dev/null +++ b/scripts/gwion-pkg @@ -0,0 +1,71 @@ +: "${GWION_PLUG_PATH:=$PWD}" +declare -A magic_variable=() + +read_manifest() { + name=$(basename $1 .manifest) + magic_variable[$name]=$((magic_variable[$name])) + [ -f $1 ] || return + while read LINE + do + [ "${LINE:0:1}" = "#" ] && continue + magic_variable[$LINE]=$((magic_variable[$LINE] + 1)) + find_manifest $LINE.manifest + done < $1 +} + +find_manifest() { + for DIR in $GWION_PLUG_PATH + do + [ -f DIR/$1 ] || continue + read_manifest $1 + return + done +} + +install_plug() { + [ -d .gwion-pkg ] || mkdir .gwion-pkg + echo "installing $2 $3" + index=$(printf "%04i" $3) + [ -f .gwion-pkg/${index}_$(basename $1 .manifest).so ] && rm .gwion-pkg/${index}_$(basename $1 .manifest).so + ln $PLUG .gwion-pkg/${index}_$(basename $1 .manifest).so +} + +install_manifest() { + for DIR in $GWION_PLUG_PATH + do + [ -d $DIR ] || continue + PLUG=$DIR/$(basename $1 .manifest).so + if [ -f $PLUG ] + then + install_plug "$1" "$PLUG" $2 + return + fi + done +} + +if [ "$1" = "list" ] +then # clear + [ -d .gwion-pkg ] && ls .gwion-pkg | sort -u | cut -d_ -f 2 +elif [ "$1" = "run" ] +then # run + shift + gwion -p .gwion-pkg $@ +elif [ "$1" = "clear" ] +then rm -rf .gwion-pkg +else +for FILE in *.manifest +do read_manifest $FILE +done + +MAX=0 +for i in "${!magic_variable[@]}" +do [ "${magic_variable[$i]}" -gt "$MAX" ] && MAX="${magic_variable[$i]}" +done + + +for i in "${!magic_variable[@]}" +do + install_manifest "$i" $(( MAX - ${magic_variable[$i]})) +done +fi + diff --git a/help/opcode.sh b/scripts/opcode.sh similarity index 100% rename from help/opcode.sh rename to scripts/opcode.sh diff --git a/help/struct_check.sh b/scripts/struct_check.sh similarity index 100% rename from help/struct_check.sh rename to scripts/struct_check.sh diff --git a/help/supp b/scripts/supp similarity index 100% rename from help/supp rename to scripts/supp diff --git a/help/test.sh b/scripts/test.sh similarity index 99% rename from help/test.sh rename to scripts/test.sh index cfb2ad08..c996e29c 100644 --- a/help/test.sh +++ b/scripts/test.sh @@ -184,7 +184,7 @@ test_gw(){ if [ "$VALGRIND" == "NO_VALGRIND" ] then LANG=C ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: else - LANG=C "$VALGRIND" --suppressions=help/supp --log-file="$vlog" \ + LANG=C "$VALGRIND" --suppressions=scripts/supp --log-file="$vlog" \ ./"$PRG" "$GWOPT" -d "$DRIVER" "$file" > "$slog" 2>"$elog" |: fi ret=$? diff --git a/tests/sh/plugin.sh b/tests/sh/plugin.sh index 55b0d43a..93616113 100644 --- a/tests/sh/plugin.sh +++ b/tests/sh/plugin.sh @@ -14,7 +14,7 @@ export GWION_ADD_DIR test_plugin() { export NAME=$"$1" export PRG=$"../../gwion" - export SUPP=$"../../help/supp" + export SUPP=$"../../scripts/supp" make if [ -f "$NAME.gw" ] then GWOPT+=-p. test_gw "$NAME.gw" "$n" diff --git a/tests/sh/test.sh b/tests/sh/test.sh index 353e7b6d..98d4e764 100644 --- a/tests/sh/test.sh +++ b/tests/sh/test.sh @@ -15,7 +15,7 @@ : "${DRIVER:=dummy}" : "${MODULE:=dummy}" -: "${SUPP:=help/supp}" +: "${SUPP:=scripts/supp}" : "${ASYNC:=4}" : "${async:=$ASYNC}" -- 2.43.0