GuoWenxue
2022-04-29 665e1b5cb16d058f478867d0e8a4f8632e2cb02e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
 
# display in red
function pr_error() {
    echo ""
    echo -e "\033[40;31m --E-- $1 \033[0m"
    echo ""
}
 
# 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