From 309af2b824895db7f261000fd7413737de552f7e Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Tue, 12 Sep 2023 06:58:54 -0700 Subject: [PATCH] Make install scripts use the latest tag for scripted installation, not `main` --- scripts/gef-extras.sh | 6 ++++-- scripts/gef.sh | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/gef-extras.sh b/scripts/gef-extras.sh index 7a8d3bc4a..5cfdc278d 100755 --- a/scripts/gef-extras.sh +++ b/scripts/gef-extras.sh @@ -5,9 +5,11 @@ # set -e -usage() { echo "Usage: $0 [-b ] [-p ]" 1>&2; exit 1; } +usage() { echo "Usage: $0 [-b ] [-p ]" 1>&2; exit 1; } -branch="main" +latest_tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//') + +branch=${latest_tag} while getopts ":b:p:" o; do case "${o}" in b) diff --git a/scripts/gef.sh b/scripts/gef.sh index bc5b32ec6..de7c648aa 100755 --- a/scripts/gef.sh +++ b/scripts/gef.sh @@ -2,7 +2,6 @@ set -e -branch="main" curl_found=0 wget_found=0 @@ -22,13 +21,19 @@ if [ -f "${HOME}/.gdbinit" ]; then fi if [ $wget_found -eq 1 ]; then + latest_tag=$(wget -q -O- "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//') + # Get the hash of the commit + branch="${latest_tag}" ref=$(wget -q -O- https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"') # Download the file wget -q "https://github.com/hugsy/gef/raw/${branch}/gef.py" -O "${HOME}/.gef-${ref}.py" elif [ $curl_found -eq 1 ]; then + latest_tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//') + # Get the hash of the commit + branch="${latest_tag}" ref=$(curl --silent https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"') # Download the file