Skip to content

Commit

Permalink
Update installation
Browse files Browse the repository at this point in the history
  • Loading branch information
lebr0nli committed May 6, 2024
1 parent 8c33a41 commit 0212f75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ And also, GEP has some awesome features already, you can directly use it!

Make sure you have GDB 8.0 or higher compiled with Python3.7+ bindings, then:

1. Install git and curl (or wget)
1. Install git
2. Make sure you have [virtualenv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv) installed
3. Install fzf: [Installation](https://github.com/junegunn/fzf#installation) (Optional, but GEP works better with fzf)
4. Install this plug-in by:

```shell
# via the install script
## using curl
$ bash -c "$(curl -fsSL https://raw.githubusercontent.com/lebr0nli/GEP/main/install.sh)"

## using wget
$ bash -c "$(wget https://raw.githubusercontent.com/lebr0nli/GEP/main/install.sh -O -)"
# You could also choose other directories to install GEP if you want
git clone --depth 1 https://github.com/lebr0nli/GEP.git ~/.local/share/GEP
~/.local/share/GEP/install.sh
```

5. Enjoy!
Expand All @@ -53,7 +50,13 @@ $ bash -c "$(wget https://raw.githubusercontent.com/lebr0nli/GEP/main/install.sh
## How to update the version of GEP?

You can re-run the install script to update the version of GEP.
If your `~/.gdbinit` is something like this: `source ~/.local/share/GEP/gdbinit-gep.py`, then you can update GEP by:

```shell
cd ~/.local/share/GEP
git pull
./install.sh
```

## For more configuration

Expand Down
32 changes: 13 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
#!/bin/bash
set -ex

# create a folder for GEP
INSTALL_PATH=${XDG_DATA_HOME:-$HOME/.local/share}/GEP
mkdir -p "$INSTALL_PATH"
GDBINIT_GEP_PY=$INSTALL_PATH/gdbinit-gep.py
echo "Installing GEP to $INSTALL_PATH ..."

if [ -d "$INSTALL_PATH/.git" ]; then
# git pull if exists
cd "$INSTALL_PATH"
git pull
else
# git clone the repo if not exists
git clone https://github.com/lebr0nli/GEP.git --depth=1 "$INSTALL_PATH"
fi
cd "$(dirname "${BASH_SOURCE[0]}")"
GEP_BASE=$(pwd)
GDBINIT_GEP_PY=$GEP_BASE/gdbinit-gep.py
echo "GEP installation path: $GEP_BASE"

# find python path
PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))')
Expand All @@ -24,19 +14,23 @@ if ! uname -a | grep -q Darwin > /dev/null; then
fi

# create venv and install prompt_toolkit
VENV_PATH=$INSTALL_PATH/.venv
VENV_PATH=$GEP_BASE/.venv
echo "Creating virtualenv in path: ${VENV_PATH}"
"$PYTHON" -m venv "$VENV_PATH"
PYTHON=$VENV_PATH/bin/python
echo "Installing prompt_toolkit"
"$PYTHON" -m pip install -U pip
"$VENV_PATH/bin/pip" install --no-cache-dir prompt_toolkit==3.0.40

# copy example config to INSTALL_PATH if not exists
cp -n "$INSTALL_PATH"/example/* "$INSTALL_PATH"
# copy example config to GEP_BASE if not exists
echo "Copying default config to $GEP_BASE if not exists"
cp -n "$GEP_BASE"/example/* "$GEP_BASE"

# append gep to gdbinit
# append GEP to gdbinit if not exists
if ! grep -q '^[^#]*source.*/gdbinit-gep.py' ~/.gdbinit; then
printf '\nsource %s\n' "$GDBINIT_GEP_PY" >> ~/.gdbinit
echo "Appending GEP to ~/.gdbinit"
printf '\n# Please make sure the following line is always the last in this file\n' >> ~/.gdbinit
printf 'source %s\n' "$GDBINIT_GEP_PY" >> ~/.gdbinit
fi

exit 0

0 comments on commit 0212f75

Please sign in to comment.