Minor lint and pre-hook changes (#1349)

pull/1350/head
Gulshan Singh 3 years ago committed by GitHub
parent d0b14eea56
commit ac5a6ebe64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -ex
cat >$1.rst <<EOF
cat > $1.rst << EOF
:mod:\`pwndbg.$1\` --- pwndbg.$1
=============================================

@ -31,7 +31,7 @@ set -o xtrace
LINT_FILES="pwndbg tests *.py"
LINT_TOOLS="isort black flake8 vermin"
if ! type ${LINT_TOOLS} &>/dev/null; then
if ! type ${LINT_TOOLS} &> /dev/null; then
PIP_CMD="pip install -Ur dev-requirements.txt"
echo "Missing one of the following tools: ${LINT_TOOLS}"
echo "Running '${PIP_CMD}'"
@ -47,14 +47,15 @@ else
black --check --diff ${LINT_FILES}
fi
flake8 --show-source ${LINT_FILES}
if [ -x "$(command -v shfmt)" ]; then
# Indents are four spaces, binary ops can start a line, and indent switch cases
shfmt -i 4 -bn -ci -d .
# Indents are four spaces, binary ops can start a line, indent switch cases,
# and allow spaces following a redirect
shfmt -i 4 -bn -ci -sr -d .
else
echo "shfmt not installed, skipping"
fi
# Checking minimum python version
vermin -q -t=3.6 --violations ./pwndbg/
flake8 --show-source ${LINT_FILES}

@ -1,6 +1,6 @@
#!/bin/bash
# Benchmark context command
make test >/dev/null
make test > /dev/null
git log --abbrev-commit --pretty=oneline HEAD^..HEAD
gdb ./test \
-ex "source ../gdbinit.py" \

@ -1,7 +1,7 @@
#!/bin/bash
if ! (($#)); then
cat <<-_EOF_
cat <<- _EOF_
$0: [profile-script]
Example: $0 context.py
@ -13,7 +13,7 @@ module=$(basename "${1/.py/}")
basedir=$(dirname "$0")
# Quick and dirty script to profile pwndbg using cProfile.
make -C "${basedir}" test >/dev/null
make -C "${basedir}" test > /dev/null
gdb "${basedir}/test" \
-ex "source ${basedir}/../gdbinit.py" \
@ -32,7 +32,7 @@ p = pstats.Stats('${basedir}/stats')
p.strip_dirs().sort_stats('tottime').print_stats(20)
"
if command -v pyprof2calltree >/dev/null 2>&1 && command -v kcachegrind >/dev/null 2>&1; then
if command -v pyprof2calltree &> /dev/null && command -v kcachegrind &> /dev/null; then
pyprof2calltree -k -i "${basedir}/stats"
fi

@ -5,14 +5,35 @@ echo "# Install testing tools."
echo "# Only works with Ubuntu / APT."
echo "# --------------------------------------"
hook_script_name=".git/hooks/pre-push"
hook_script_path=".git/hooks/pre-push"
hook_script=$(
cat << 'EOF'
#!/bin/bash
diff_command="git diff --no-ext-diff --ignore-submodules"
old_diff=$($diff_command)
./lint.sh -f
exit_code=$?
new_diff=$($diff_command)
if [[ "$new_diff" != "$old_diff" ]]; then
echo "Files were modified by the linter, amend your commit and try again"
exit 1
fi
exit $exit_code
EOF
)
if [ -t 1 ]; then
echo "Install a git hook to automatically lint files before pushing? (y/N)"
read yn
if [[ "$yn" == [Yy]* ]]; then
echo "./lint.sh -f" >>$hook_script_name
echo "pre-push hook installed to $hook_script_name"
echo "$hook_script" > "$hook_script_path"
echo "pre-push hook installed to $hook_script_path"
fi
fi
@ -26,14 +47,14 @@ echo "ZIGPATH set to $ZIGPATH"
# If we are a root in a container and `sudo` doesn't exist
# lets overwrite it with a function that just executes things passed to sudo
# (yeah it won't work for sudo executed with flags)
if ! hash sudo 2>/dev/null && whoami | grep root; then
if ! hash sudo 2> /dev/null && whoami | grep root; then
sudo() {
${*}
}
fi
linux() {
uname | grep -i Linux &>/dev/null
uname | grep -i Linux &> /dev/null
}
install_apt() {
@ -69,7 +90,7 @@ install_apt() {
tar -C /tmp -xJf /tmp/zig.tar.xz
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} 2>/dev/null >/dev/null || true
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} &> /dev/null || true
echo "Zig installed to ${ZIGPATH}"
}

@ -4,7 +4,7 @@ set -ex
# If we are a root in a container and `sudo` doesn't exist
# lets overwrite it with a function that just executes things passed to sudo
# (yeah it won't work for sudo executed with flags)
if ! hash sudo 2>/dev/null && whoami | grep root; then
if ! hash sudo 2> /dev/null && whoami | grep root; then
sudo() {
${*}
}
@ -12,17 +12,17 @@ fi
# Helper functions
linux() {
uname | grep -i Linux &>/dev/null
uname | grep -i Linux &> /dev/null
}
osx() {
uname | grep -i Darwin &>/dev/null
uname | grep -i Darwin &> /dev/null
}
install_apt() {
sudo apt-get update || true
sudo apt-get install -y git gdb python3-dev python3-pip python3-setuptools libglib2.0-dev libc6-dbg
if uname -m | grep x86_64 >/dev/null; then
if uname -m | grep x86_64 > /dev/null; then
sudo dpkg --add-architecture i386 || true
sudo apt-get update || true
sudo apt-get install -y libc6-dbg:i386 || true
@ -51,7 +51,7 @@ install_zypper() {
sudo zypper refresh || true
sudo zypper install -y gdb gdbserver python-devel python3-devel python2-pip python3-pip glib2-devel make glibc-debuginfo
if uname -m | grep x86_64 >/dev/null; then
if uname -m | grep x86_64 > /dev/null; then
sudo zypper install -y glibc-32bit-debuginfo || true
fi
}
@ -109,7 +109,7 @@ if linux; then
;;
"gentoo")
install_emerge
if ! hash sudo 2>/dev/null && whoami | grep root; then
if ! hash sudo 2> /dev/null && whoami | grep root; then
sudo() {
${*}
}
@ -163,6 +163,6 @@ ${PYTHON} -m pip install ${INSTALLFLAGS} --upgrade pip
${PYTHON} -m pip install ${INSTALLFLAGS} -Ur requirements.txt
# Load Pwndbg into GDB on every launch.
if ! grep pwndbg ~/.gdbinit &>/dev/null; then
echo "source $PWD/gdbinit.py" >>~/.gdbinit
if ! grep pwndbg ~/.gdbinit &> /dev/null; then
echo "source $PWD/gdbinit.py" >> ~/.gdbinit
fi

Loading…
Cancel
Save