You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pwndbg/setup-test-tools.sh

50 lines
1.3 KiB
Bash

#!/bin/bash -e
echo "# --------------------------------------"
echo "# Install testing tools."
echo "# Only works with Ubuntu / APT."
echo "# --------------------------------------"
# 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
sudo() {
${*}
}
fi
linux() {
uname | grep -i Linux &>/dev/null
}
install_apt() {
sudo apt-get update || true
sudo apt-get install -y \
nasm \
gcc \
libc6-dev
test -f /usr/bin/go || sudo apt-get install -y golang
# We use zig to compile some test binaries as it is much easier than with gcc
sudo snap install zig --classic --edge
}
if linux; then
distro=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | sed -e 's/"//g')
case $distro in
"ubuntu")
install_apt
;;
*) # we can add more install command for each distros.
echo "\"$distro\" is not supported distro. Will search for 'apt' or 'dnf' package managers."
if hash apt; then
install_apt
else
echo "\"$distro\" is not supported and your distro don't have apt or dnf that we support currently."
exit
fi
;;
esac
fi