Skip to content

Commit

Permalink
[Bug] Fix broken install script after #1053.
Browse files Browse the repository at this point in the history
We now stop using 3rd party tool, only rely on bash and python3.
  • Loading branch information
hugsy committed Feb 1, 2024
1 parent 32d1e91 commit 06478bd
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions scripts/gef.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

set -e

curl_found=0
wget_found=0

# check dependencies
if [ "$(command -v curl)" ]; then
curl_found=1
elif [ "$(command -v wget)" ]; then
wget_found=1
else
echo "The installer requires cURL or wget installed."
if [ ! "$(command -v python3)" ]; then
echo "GEF requires Python3 installed."
exit 1
fi

Expand All @@ -20,24 +13,13 @@ if [ -f "${HOME}/.gdbinit" ]; then
mv "${HOME}/.gdbinit" "${HOME}/.gdbinit.old"
fi

if [ $wget_found -eq 1 ]; then
# Get the tag of the latest stable
tag=$(wget -q -O- "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/ *//')

# Download the file
wget -q "https://github.com/hugsy/gef/raw/${tag}/gef.py" -O "${HOME}/.gef-${tag}.py"
elif [ $curl_found -eq 1 ]; then
# Get the tag of the latest stable
tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/ *//')

# Download the file
curl --silent --location --output "${HOME}/.gef-${tag}.py" "https://github.com/hugsy/gef/raw/${tag}/gef.py"
fi
tag=$(python3 -c 'import urllib.request as r,json as j; x=j.loads(r.urlopen("https://api.github.com/repos/hugsy/gef/tags").read()); print(x[0]["name"])')
python3 -c "import urllib.request as r; x=r.urlopen('https://github.com/hugsy/gef/raw/${tag}/gef.py').read(); print(x.decode('utf-8'))" > ${HOME}/.gef-${tag}.py

if [ -f "${HOME}/.gef-${tag}.py" ]; then
echo "source ~/.gef-${tag}.py" > ~/.gdbinit
exit 0
else
echo "GEF was not properly downloaded"
exit 1
exit 2
fi

0 comments on commit 06478bd

Please sign in to comment.