From 52529406cbfcdc28fd26400d7a06245c87984bbf Mon Sep 17 00:00:00 2001 From: Mike Abbott Date: Mon, 13 Mar 2023 13:24:59 -0600 Subject: [PATCH 1/3] Modifying the install script to default to /opt/pret This will allow for the decompilations to default to a system wide installation. --- install.sh | 59 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/install.sh b/install.sh index 637a21da..0dc344d7 100755 --- a/install.sh +++ b/install.sh @@ -1,34 +1,43 @@ #!/bin/sh set -e -if [ "$1" != "" ]; then - if [ -d "$1" ]; then - mkdir -p $1/tools/agbcc - mkdir -p $1/tools/agbcc/bin - mkdir -p $1/tools/agbcc/include - mkdir -p $1/tools/agbcc/lib - cp agbcc $1/tools/agbcc/bin/ - cp old_agbcc $1/tools/agbcc/bin/ - cp agbcc_arm $1/tools/agbcc/bin/ - cp -R libc/include $1/tools/agbcc/ #drop include, because we don't want include/include - cp ginclude/* $1/tools/agbcc/include/ - cp libgcc.a $1/tools/agbcc/lib/ - cp libc.a $1/tools/agbcc/lib/ - echo "agbcc successfully installed!" + +if [ "$1" = "-h" ]; then + echo "Usage: install.sh PATH" + exit 0 +fi + +if [ "$1" = "" ]; then + INSTALL_DIRECTORY=/opt/pret/ + mkdir -p $INSTALL_DIRECTORY +else + INSTALL_DIRECTORY=$1 +fi + +if [ -d "$INSTALL_DIRECTORY" ]; then + mkdir -p $INSTALL_DIRECTORY/tools/agbcc + mkdir -p $INSTALL_DIRECTORY/tools/agbcc/bin + mkdir -p $INSTALL_DIRECTORY/tools/agbcc/include + mkdir -p $INSTALL_DIRECTORY/tools/agbcc/lib + cp agbcc $INSTALL_DIRECTORY/tools/agbcc/bin/ + cp old_agbcc $INSTALL_DIRECTORY/tools/agbcc/bin/ + cp agbcc_arm $INSTALL_DIRECTORY/tools/agbcc/bin/ + cp -R libc/include $INSTALL_DIRECTORY/tools/agbcc/ #drop include, because we don't want include/include + cp ginclude/* $INSTALL_DIRECTORY/tools/agbcc/include/ + cp libgcc.a $INSTALL_DIRECTORY/tools/agbcc/lib/ + cp libc.a $INSTALL_DIRECTORY/tools/agbcc/lib/ + echo "agbcc successfully installed!" +else + if [ -d "../$INSTALL_DIRECTORY" ]; then + echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" else - if [ -d "../$1" ]; then - echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" + if case $INSTALL_DIRECTORY in ".."*) true;; *) false;; esac; then + echo "Target directory does not exist. If you aren't familiar with relative paths, make sure that agbcc and the repository are in the same directory, and run \"./install.sh $1\" again." else - if case $1 in ".."*) true;; *) false;; esac; then - echo "Target directory does not exist. If you aren't familiar with relative paths, make sure that agbcc and the repository are in the same directory, and run \"./install.sh $1\" again." + if echo "$INSTALL_DIRECTORY" | grep -qE '^[^/]*.$'; then + echo "Target directory does not exist. You probably meant to do \"./install.sh ../$1\", but agbcc and $1 do not exist in the same directory. Check your spelling, make sure that the repository has been cloned, ensure that agbcc and the repository are in the same directory, and run \"./install.sh ../$1\" again." else - if echo "$1" | grep -qE '^[^/]*.$'; then - echo "Target directory does not exist. You probably meant to do \"./install.sh ../$1\", but agbcc and $1 do not exist in the same directory. Check your spelling, make sure that the repository has been cloned, ensure that agbcc and the repository are in the same directory, and run \"./install.sh ../$1\" again." - else - echo "Target directory does not exist. Check your spelling, re-read the instructions, and try again." - fi + echo "Target directory does not exist. Check your spelling, re-read the instructions, and try again." fi fi fi -else - echo "Usage: install.sh PATH" fi From ee1420ffe9930542dfc3f7e455cfe78af22275a1 Mon Sep 17 00:00:00 2001 From: Mike Abbott Date: Mon, 13 Mar 2023 14:21:01 -0600 Subject: [PATCH 2/3] Modified the script so that the tools folder isn't part of the default install path. --- install.sh | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 0dc344d7..51353b1b 100755 --- a/install.sh +++ b/install.sh @@ -6,34 +6,40 @@ if [ "$1" = "-h" ]; then exit 0 fi +# If there's no installation directory specified, the install script will default to +# installing agbcc into /opt/pret/agbcc if [ "$1" = "" ]; then - INSTALL_DIRECTORY=/opt/pret/ + BASE_INSTALL_DIRECTORY=/opt/pret/ + INSTALL_DIRECTORY=$BASE_INSTALL_DIRECTORY mkdir -p $INSTALL_DIRECTORY else - INSTALL_DIRECTORY=$1 + BASE_INSTALL_DIRECTORY=$1 + INSTALL_DIRECTORY=$BASE_INSTALL_DIRECTORY/tools/ fi -if [ -d "$INSTALL_DIRECTORY" ]; then - mkdir -p $INSTALL_DIRECTORY/tools/agbcc - mkdir -p $INSTALL_DIRECTORY/tools/agbcc/bin - mkdir -p $INSTALL_DIRECTORY/tools/agbcc/include - mkdir -p $INSTALL_DIRECTORY/tools/agbcc/lib - cp agbcc $INSTALL_DIRECTORY/tools/agbcc/bin/ - cp old_agbcc $INSTALL_DIRECTORY/tools/agbcc/bin/ - cp agbcc_arm $INSTALL_DIRECTORY/tools/agbcc/bin/ - cp -R libc/include $INSTALL_DIRECTORY/tools/agbcc/ #drop include, because we don't want include/include - cp ginclude/* $INSTALL_DIRECTORY/tools/agbcc/include/ - cp libgcc.a $INSTALL_DIRECTORY/tools/agbcc/lib/ - cp libc.a $INSTALL_DIRECTORY/tools/agbcc/lib/ +# The BASE_INSTALL_DIRECTORY nomenclature is so that the check for the existence of the +# directory doesn't fail just because there's no tools directory yet. +if [ -d "$BASE_INSTALL_DIRECTORY" ]; then + mkdir -p $INSTALL_DIRECTORY/agbcc + mkdir -p $INSTALL_DIRECTORY/agbcc/bin + mkdir -p $INSTALL_DIRECTORY/agbcc/include + mkdir -p $INSTALL_DIRECTORY/agbcc/lib + cp agbcc $INSTALL_DIRECTORY/agbcc/bin/ + cp old_agbcc $INSTALL_DIRECTORY/agbcc/bin/ + cp agbcc_arm $INSTALL_DIRECTORY/agbcc/bin/ + cp -R libc/include $INSTALL_DIRECTORY/agbcc/ #drop include, because we don't want include/include + cp ginclude/* $INSTALL_DIRECTORY/agbcc/include/ + cp libgcc.a $INSTALL_DIRECTORY/agbcc/lib/ + cp libc.a $INSTALL_DIRECTORY/agbcc/lib/ echo "agbcc successfully installed!" else - if [ -d "../$INSTALL_DIRECTORY" ]; then + if [ -d "../$BASE_INSTALL_DIRECTORY" ]; then echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" else - if case $INSTALL_DIRECTORY in ".."*) true;; *) false;; esac; then + if case $BASE_INSTALL_DIRECTORY in ".."*) true;; *) false;; esac; then echo "Target directory does not exist. If you aren't familiar with relative paths, make sure that agbcc and the repository are in the same directory, and run \"./install.sh $1\" again." else - if echo "$INSTALL_DIRECTORY" | grep -qE '^[^/]*.$'; then + if echo "$BASE_INSTALL_DIRECTORY" | grep -qE '^[^/]*.$'; then echo "Target directory does not exist. You probably meant to do \"./install.sh ../$1\", but agbcc and $1 do not exist in the same directory. Check your spelling, make sure that the repository has been cloned, ensure that agbcc and the repository are in the same directory, and run \"./install.sh ../$1\" again." else echo "Target directory does not exist. Check your spelling, re-read the instructions, and try again." From 202cf10362306c2e1d4106141ad2e142c9988e0b Mon Sep 17 00:00:00 2001 From: Mike Abbott Date: Mon, 13 Mar 2023 14:22:00 -0600 Subject: [PATCH 3/3] Fixed double path separators (not that it matters) --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 51353b1b..ab305e9e 100755 --- a/install.sh +++ b/install.sh @@ -9,12 +9,12 @@ fi # If there's no installation directory specified, the install script will default to # installing agbcc into /opt/pret/agbcc if [ "$1" = "" ]; then - BASE_INSTALL_DIRECTORY=/opt/pret/ + BASE_INSTALL_DIRECTORY=/opt/pret INSTALL_DIRECTORY=$BASE_INSTALL_DIRECTORY mkdir -p $INSTALL_DIRECTORY else BASE_INSTALL_DIRECTORY=$1 - INSTALL_DIRECTORY=$BASE_INSTALL_DIRECTORY/tools/ + INSTALL_DIRECTORY=$BASE_INSTALL_DIRECTORY/tools fi # The BASE_INSTALL_DIRECTORY nomenclature is so that the check for the existence of the