pwndbg/setup-dev.sh

175 lines
4.2 KiB
Bash
Raw Normal View History

Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
#!/bin/bash -e
echo "# --------------------------------------"
echo "# Install testing tools."
echo "# Only works with Ubuntu / APT or Arch / Pacman."
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
echo "# --------------------------------------"
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 "$hook_script" > "$hook_script_path"
echo "pre-push hook installed to $hook_script_path"
fi
fi
# If we are a root in a container and `sudo` doesn't exist
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
# 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
sudo() {
${*}
}
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
fi
linux() {
uname | grep -i Linux &> /dev/null
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
}
set_zigpath() {
if [[ -z "$ZIGPATH" ]]; then
# If ZIGPATH is not set, set it
# In Docker environment this should by default be set to /opt/zig (APT) or /usr/bin (Pacman)
export ZIGPATH="$1"
fi
echo "ZIGPATH set to $ZIGPATH"
}
download_zig_binary() {
# Install zig to current directory
# We use zig to compile some test binaries as it is much easier than with gcc
ZIG_TAR_URL="https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3685+dae7aeb33.tar.xz"
ZIG_TAR_SHA256="dfc8f5ecb651342f1fc2b2828362b62f74fadac9931bda785b80bf7ecfcfabb2"
curl --output /tmp/zig.tar.xz "${ZIG_TAR_URL}"
ACTUAL_SHA256=$(sha256sum /tmp/zig.tar.xz | cut -d' ' -f1)
if [ "${ACTUAL_SHA256}" != "${ZIG_TAR_SHA256}" ]; then
echo "Zig binary checksum mismatch"
echo "Expected: ${ZIG_TAR_SHA256}"
echo "Actual: ${ACTUAL_SHA256}"
exit 1
fi
tar -C /tmp -xJf /tmp/zig.tar.xz
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} &> /dev/null || true
echo "Zig installed to ${ZIGPATH}"
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
}
install_apt() {
set_zigpath "$(pwd)/.zig"
sudo apt-get update || true
sudo apt-get install -y \
nasm \
gcc \
libc6-dev \
curl \
build-essential \
gdb \
2023-01-19 10:58:28 +08:00
gdb-multiarch \
parallel \
2023-01-19 10:58:28 +08:00
netcat-openbsd \
qemu-system-x86 \
qemu-system-arm
if [[ "$1" == "22.04" ]]; then
sudo apt install shfmt
fi
test -f /usr/bin/go || sudo apt-get install -y golang
download_zig_binary
}
install_pacman() {
set_zigpath "$(pwd)/.zig"
# add debug repo for glibc-debug
cat << EOF | sudo tee -a /etc/pacman.conf
[core-debug]
Include = /etc/pacman.d/mirrorlist
[extra-debug]
Include = /etc/pacman.d/mirrorlist
[community-debug]
Include = /etc/pacman.d/mirrorlist
[multilib-debug]
Include = /etc/pacman.d/mirrorlist
EOF
sudo pacman -Syu --noconfirm || true
sudo pacman -S --noconfirm \
nasm \
gcc \
glibc-debug \
curl \
base-devel \
gdb \
parallel \
gnu-netcat
test -f /usr/bin/go || sudo pacman -S --noconfirm go
download_zig_binary
}
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
if linux; then
distro=$(
. /etc/os-release
echo ${ID}
)
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
case $distro in
"ubuntu")
ubuntu_version=$(
. /etc/os-release
echo ${VERSION_ID}
)
install_apt $ubuntu_version
;;
"arch")
install_pacman
;;
*) # we can add more install command for each distros.
echo "\"$distro\" is not supported distro. Will search for 'apt' or 'pacman' package managers."
if hash apt; then
install_apt
elif hash pacman; then
install_pacman
else
echo "\"$distro\" is not supported and your distro don't have apt or pacman that we support currently."
exit
fi
;;
esac
python3 -m pip install -r dev-requirements.txt
Unit test fix (#868) * Fixed the failed unit testing; Improved the Dockerfile, again. * Fixed missing new line joiner in the Dockerfile. * Fixed the default Python version from 2 to 3. * Moved the installation of the nasm and golang packages to the setup script. * Fixed the extra quotes which fails the sudo check. * Added to the Git ignore file the output files assembled and linked in the test binaries. * Removed the output files from test binaries. * Added to the Git ignore file the virtual environment directory. * Added sudo to the remove and link the Python3 binary. * Added commands related to GO, to check why is failing. * Fixed the installation of GO, only install if not exists in Ubuntu. * Fixed the first test built in Assembler. Checks if it is working in GitHub. * Fixed the problem with all the assembler tests; Extracted the asserts into methods, avoiding duplicates. * Fixed some test, should be fail the Travis tests. * Fixed one test for Travis. * Fixed the asserts, now find all ecpected items into the output. * Fixed the split message, joined again. * Fixed the last error test for loads binary. * Fixed one missing number in the comparison. * Fixed the first Lint errors. * Added comment in the Dockerfile. The commented line about `git submodule`. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075767 * Removed NASM and Go from the setup. Created a new bash script to install them and added to the Dockerfile. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Added the setup script in the GitHub test workflow. https://github.com/pwndbg/pwndbg/pull/868/files#r549075931 https://github.com/pwndbg/pwndbg/pull/868/files#r549076078 * Testing the emulate cases. It should be fail. I commented the emulation for the address 0x401000. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 * Fixed the different start addresses in the assembler test. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549111511 https://github.com/pwndbg/pwndbg/pull/868#discussion_r549075485 * Experimenting with the python location. Commented the remove python binary and added some logs. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170 * Removed the commands about delete Python and link the Python3. https://github.com/pwndbg/pwndbg/pull/868#discussion_r549076170
2020-12-31 11:35:52 +08:00
fi