Skip to content

Instantly share code, notes, and snippets.

@Myralllka
Last active December 3, 2022 12:27
Show Gist options
  • Save Myralllka/e8f4e93e6bf0134b693371f1aad9d860 to your computer and use it in GitHub Desktop.
Save Myralllka/e8f4e93e6bf0134b693371f1aad9d860 to your computer and use it in GitHub Desktop.
Script for auto installation of PVS_Studio
#!/bin/env bash
# Installation script for students who dont want to do it by theirselves.
# PVS_Studio info is here:
# https://pvs-studio.com/en/
# set -o xtrace
set -e
trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR
MY_DISTRO=$(cat /etc/*-release | tr [:upper:] [:lower:] | grep -Poi '(debian|ubuntu|manjaro|arch)' | uniq | head -n 1)
# How to install the PVS studio: https://pvs-studio.com/en/docs/manual/0039/ . You can add your distros, I will update this script.
if [[ $MY_DISTRO == "arch" || $MY_DISTRO == "manjaro" ]]; then
echo "Distro is Manjaro or Arch Linux. Continuing..."
{ # try
yay -S pvs-studio --noconfirm
} || { # catch
echo "yay unavailable. installing manually..."
wget -O /tmp/pvs.tgz https://cdn.pvs-studio.com/pvs-studio-7.21.64848.262-x86_64.tgz
mkdir /tmp/pvs
tar -xzf /tmp/pvs.tgz -C /tmp/pvs
cd /tmp/pvs/$(ls /tmp/pvs)
{ #try
bash install.sh
} || { #catch
sudo bash install.sh
}
}
elif [[ $MY_DISTRO == "ubuntu" || $MY_DISTRO == "debian" ]]; then
echo "Distro is Ubuntu or Debian. Continuing...";
sudo apt-get install wget
wget -q -O - https://files.viva64.com/etc/pubkey.txt | \
sudo apt-key add -
sudo wget -O /etc/apt/sources.list.d/viva64.list \
https://files.viva64.com/etc/viva64.list
sudo apt-get update
sudo apt-get install pvs-studio
else
echo "Unimplemented OS. Exiting...";
exit 1;
fi
# Every student and teacher can use PVS-Studio for free...
# https://pvs-studio.com/en/order/for-students/
echo "\n\nPVS_Studio installed. Setting the students liscence...\n\n"
pvs-studio-analyzer credentials PVS-Studio Free FREE-FREE-FREE-FREE
echo "\n\nNow just add following lines to EVERY your C++ file, first two lines..."
echo "
// This is a personal academic project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment