From e1511b7a3fecc06a6d25f673c7d522c58efcff9a Mon Sep 17 00:00:00 2001 From: AndrewQuijano Date: Mon, 26 Aug 2024 19:22:43 -0400 Subject: [PATCH] Using host.json as project JSON to specificy docker container and whether docker, local, or remote --- scripts/competition.sh | 1 - scripts/docker-shell.sh | 18 ++++++++++-------- scripts/inject.sh | 2 +- scripts/lava.sh | 2 +- scripts/vars.sh | 14 ++++++-------- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/scripts/competition.sh b/scripts/competition.sh index 0a8756bf..f5f4df7b 100755 --- a/scripts/competition.sh +++ b/scripts/competition.sh @@ -4,7 +4,6 @@ # Json file required params # # lava: directory of lava repository -# pandahost: what remote host to run panda on trap '' PIPE set -e # Exit on error diff --git a/scripts/docker-shell.sh b/scripts/docker-shell.sh index ffef8cab..272c99d4 100755 --- a/scripts/docker-shell.sh +++ b/scripts/docker-shell.sh @@ -1,17 +1,19 @@ #!/bin/bash -# Single argument of project name will get container name +# Single argument of project name will get Docker name # from project config. Then 2nd optional argument is command to run # With no arguments, just give us a shell lava="$(dirname $(dirname $(readlink -f $0)))" +hostjson="$lava/host.json" +dockername="$(jq -r '.docker // "lava32"' $hostjson)" -if [ "$#" -eq 0 ]; then - container="lava32" -else +echo "You are connecting to the Docker container: ${dockername}" + +if [ "$#" -ne 0 ]; then project_name=$1 cmd="${@:2}" -#Container name (lava32 or lava32debug) comes from config + # Docker name (lava32 or lava32debug) comes from config . `dirname $0`/vars.sh docker_map_args="-v $tarfiledir:$tarfiledir" @@ -19,8 +21,8 @@ else docker_map_args="$docker_map_args -v $directory:$directory" fi - if ! ( docker images ${container} | grep -q ${container} ); then - docker build -t ${container} "$(dirname $(dirname $(readlink -f $0)))/docker/debug" + if ! ( docker images ${dockername} | grep -q ${dockername} ); then + docker build -t ${dockername} "$(dirname $(dirname $(readlink -f $0)))/docker/debug" fi [ "$extradockerargs" = "null" ] && extradockerargs=""; @@ -57,4 +59,4 @@ docker run --rm -it \ --cap-add=SYS_PTRACE \ $docker_map_args \ $extradockerargs \ - ${container} sh -c "trap '' PIPE; $cmd" + ${dockername} sh -c "trap '' PIPE; $cmd" diff --git a/scripts/inject.sh b/scripts/inject.sh index ae50e1e9..365fef03 100755 --- a/scripts/inject.sh +++ b/scripts/inject.sh @@ -4,7 +4,7 @@ # Json file required params # # lava: directory of lava repository -# pandahost: what remote host to run panda on + trap '' PIPE set -e # Exit on error diff --git a/scripts/lava.sh b/scripts/lava.sh index 583b9c46..f5bb9f16 100755 --- a/scripts/lava.sh +++ b/scripts/lava.sh @@ -27,7 +27,6 @@ # name: a name for this project (used to create directories) # inputs: a list of inputs that will be used to find potential bugs (think coverage) # buildhost: what remote host to build source on -# pandahost: what remote host to run panda and postgres on # testinghost: what host to test injected bugs on # fixupscript: script to run after add_query to fix up src before make # @@ -146,6 +145,7 @@ if [ $reset -eq 1 ]; then deldir "$directory/$name/"'*rr-*' # remove all plog files in the directory deldir "$directory/$name/*.plog" + deldir "$directory/$name/*.json" progress "everything" 0 "Truncating logs..." for i in $(ls "$logs" | grep '.log$'); do truncate "$logs/$i" diff --git a/scripts/vars.sh b/scripts/vars.sh index a8eebb95..2239abd6 100644 --- a/scripts/vars.sh +++ b/scripts/vars.sh @@ -25,6 +25,10 @@ output_dir="$(jq -r '.output_dir // ""' $hostjson)" config_dir="$(jq -r '.config_dir // ""' $hostjson)/$project_name" tar_dir="$(jq -r '.tar_dir // ""' $hostjson)" db_suffix="$(jq -r '.db_suffix // ""' $hostjson)" +buildhost="$(jq -r '.buildhost // "localhost"' $hostjson)" +testinghost="$(jq -r '.testinghost // "localhost"' $hostjson)" +dockername="$(jq -r '.docker // "lava32"' $hostjson)" + json="${config_dir}/$project_name.json" if [ ! -f $json ]; then @@ -66,10 +70,6 @@ if [ "$(jq -r .injfixupsscript $json)" != "null" ]; then injfixupsscript="${injfixupsscript/\{bug_build\}/$bug_build}" fi -buildhost="$(jq -r '.buildhost // "docker"' $json)" -# buildhost="localhost" -pandahost="$(jq -r '.pandahost // "docker"' $json)" -testinghost="$(jq -r '.testinghost // "docker"' $json)" logs="$output_dir/$name/logs" makecmd="$(jq -r .make $json)" @@ -78,13 +78,11 @@ install="${install/\{config_dir\}/$config_dir}" # Format string replacement for post_install="$(jq -r .post_install $json)" install_simple=$(jq -r .install_simple $json) configure_cmd=$(jq -r '.configure // "/bin/true"' $json) -container="$(jq -r '.docker // "lava32"' $json)" # Constants scripts="$lava/scripts" -python="/usr/bin/python3" -pdb="/usr/bin/python3 -m pdb " -dockername="lava32" +python="python3" +pdb="python3 -m pdb " dbhost="database" if [ "$buildhost" = "localhost" ]; then