guowenxue
2023-07-10 5e9d03d507aad324a803eb8795e0eed6fb671761
tools/setup_systools.sh
@@ -1,7 +1,72 @@
#!/bin/bash
sudo apt update
# display in red
function pr_error() {
   echo ""
    echo -e "\033[40;31m --E-- $1 \033[0m"
   echo ""
}
sudo apt install -y make vim gawk wget curl unzip sed tree coreutils diffstat git subversion groff lzop \
make gcc g++ libtool automake autoconf autoconf-archive flex texinfo build-essential libelf-dev bison libssl-dev
# display in yellow
function pr_warn() {
   echo ""
    echo -e "\033[40;33m --W-- $1 \033[0m"
   echo ""
}
# display in green
function pr_info() {
   echo ""
    echo -e "\033[40;32m --I-- $1 \033[0m"
   echo ""
}
function update_source()
{
    APT_FILE=/etc/apt/sources.list
    pr_warn "start update apt source to ustc"
    if [ ! -f $APT_FILE.orig ] ; then
       mv $APT_FILE $APT_FILE.orig
    fi
cat > $APT_FILE <<EOF
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ bullseye main contrib non-free rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ bullseye main contrib non-free rpi
EOF
}
function apt_update()
{
    pr_warn "start update apt updata and upgrade"
    apt update
    apt upgrade -y
    apt autoremove -y
}
function apt_install()
{
    pr_warn "start apt install system tools"
    apt install -y make vim gawk wget curl unzip sed tree coreutils diffstat git subversion \
    groff lzop make gcc g++ libtool automake autoconf autoconf-archive flex texinfo bison \
    build-essential libelf-dev lrzsz
    # apt-cache policy libssl-dev
    apt install -y libssl-dev=1.1.1n-0+deb11u1 libssl1.1
}
if [ `id -u` != 0 ] ; then
    pr_error "This shell script must run as root."
   exit 1;
fi
update_source
apt_update
apt_install