-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_mingw.sh
161 lines (138 loc) · 3.54 KB
/
_mingw.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
. _util.sh
: ${MINGW_USE_MSYS2:="yes"}
: ${MINGW_CONFIRM:="no"}
if [ "$(getconf LONG_BIT)" == "64" ];then
: ${ARCH:="x86_64"}
else
: ${ARCH:="i686"}
fi
_regex_deal()
{
echo "${1//+/\\+}"
}
# $1 packages
# $2 confirm
_package_install()
{
local pkg
local ret
for pkg in $1
do
if [ "$2" == "yes" ];then
pacman -S --needed "pkg"
ret=$?
else
pacman -S --needed --noconfirm "$pkg"
ret=$?
fi
if [ $ret -eq 0 ];then
echo_color "green" "none" "install package[ OK ] $pkg"
else
echo_color "red" "none" "install package[FAIL] $pkg"
fi
done
}
# $1 group name
# $2 confirm
_group_install()
{
local ret
if [ "$2" == "yes" ];then
pacman -S --needed "$1"
ret=$?
else
pacman -S --needed --noconfirm "$1"
ret=$?
fi
if [ $ret -eq 0 ];then
echo_color "green" "none" "install group [ OK ] $1"
else
echo_color "red" "none" "install group [FAIL] ${1}"
fi
}
## $1 list
## $2 arch, i686 | x86_64 | cross | i686;x86_64;cross
## $3 install_msys2, yes: install msys program while no arch program; no: not install; true: allways install
## $4 confirm, yes: --confirm; no: --noconfirm
install_deps()
{
local _each
local _package
local _package_msys
local _search
local _search_ret
local _search_i
local _arch
local _guess
for _each in $1
do
_package=""
_package_msys=""
echo "installing $_each ..."
# whether it is a group
pacman -Qg "$_each" &> /dev/null
if [ $? -eq 0 ];then
_group_install "$_each" "$4"
continue
fi
# whether not begin with mingw
if [ "$(echo \"$_each\" | awk -F \- '{print $1}')" == "mingw" ];then
# mingw-xx-arch-name
_package+=" $_each"
else
_eash_regex=$(_regex_deal "$_each")
_search="$(pacman -Ssq ^${_eash_regex}$)\n " # gcc
_search+="$(pacman -Ssq ^mingw-w[0-9]+-[^-]+-${_eash_regex}$)" # mingw-w64-i686-gcc
_search_ret=$(echo -e "$_search" | grep ${_each})
if [ -z "$_search_ret" ];then
# not exist
echo_color "red" "none" "install package[FAIL] not exist: $_each"
continue
fi
for _search_i in $_search_ret
do
_arch="$(echo \"$_search_i\" | awk -F \- '{print $3}')"
_guess="mingw-w64-${_arch}-${_each}"
if [ -n "$(echo $2 | grep $_arch )" -a "$_guess" == "$_search_i" ];then
# _arch in ARCH
_package+=" $_search_i"
elif [ -z "$_arch" ];then
# install msys
_package_msys+=" $_search_i"
elif [ -n "$_arch" ];then
# ARCH i686, _arch x86_64
echo_color "blue" "none" "install package[IGNO] $_search_i"
else
echo_color "yellow" "none" "install package[WARN] unknow arch: $_search_i"
fi
done
fi
if [ -z "$_package" -a "$3" == "yes" -o "$3" == "true" ];then
_package+=" $_package_msys"
fi
if [ -n "$_package" ];then
_package_install "$_package" "$4"
else
echo_color "yellow" "none" "install package[WARN] package empty: $_each"
fi
done
}
upgrade_db()
{
pacman -Sy
}
upgrade_all()
{
pacman -Syu
}
upgrade_msys2()
{
pacman -Sy
pacman -S --needed filesystem msys2-runtime bash \
libreadline libiconv libarchive libgpgme libcurl pacman ncurses libintl
echo ""
echo_color "green" "none" " 1. Close all msys shell"
echo_color "green" "none" " 2. Run autorebase.bat by Double Click it "
echo_color "green" "none" " 3. \$pacman -Syu "
}