forked from m-ab-s/media-autobuild_suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media-suite_update.sh
149 lines (127 loc) · 5.65 KB
/
media-suite_update.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
echo -ne "\033]0;update autobuild suite\007"
while true; do
case $1 in
--build32=* ) build32="${1#*=}"; shift ;;
--build64=* ) build64="${1#*=}"; shift ;;
-- ) shift; break ;;
-* ) echo "Error, unknown option: '$1'."; exit 1 ;;
* ) break ;;
esac
done
# --------------------------------------------------
# packet update system
# --------------------------------------------------
if [[ -f "/etc/pac-base-old.pk" ]] && [[ -f "/etc/pac-mingw32-old.pk" ]] || [[ -f "/etc/pac-mingw64-old.pk" ]]; then
echo
echo "-------------------------------------------------------------------------------"
echo "check pacman packs..."
echo "-------------------------------------------------------------------------------"
echo
sed -i 's/ /\n/g' /etc/pac-base-old.pk
sed -i 's/ /\n/g' /etc/pac-base-new.pk
oldBase=/etc/pac-base-old.pk
newBase=/etc/pac-base-new.pk
installBasePacks=`diff $oldBase $newBase | grep ">" | sed "s/> //g" | tr '\n' ' '`
removeBasePacks=`diff $oldBase $newBase | grep "<" | sed "s/< //g" | tr '\n' ' '`
rm -f /etc/pac-base-old.pk
if [[ $build32 = "yes" ]]; then
sed -i 's/ /\n/g' /etc/pac-mingw32-old.pk
sed -i 's/ /\n/g' /etc/pac-mingw32-new.pk
oldMingw32=/etc/pac-mingw32-old.pk
newMingw32=/etc/pac-mingw32-new.pk
installMingw32Packs=`diff $oldMingw32 $newMingw32 | grep ">" | sed "s/> //g" | tr '\n' ' '`
removeMingw32Packs=`diff $oldMingw32 $newMingw32 | grep "<" | sed "s/< //g" | tr '\n' ' '`
rm -f /etc/pac-mingw32-old.pk
fi
if [[ $build64 = "yes" ]]; then
sed -i 's/ /\n/g' /etc/pac-mingw64-old.pk
sed -i 's/ /\n/g' /etc/pac-mingw64-new.pk
oldMingw64=/etc/pac-mingw64-old.pk
newMingw64=/etc/pac-mingw64-new.pk
installMingw64Packs=`diff $oldMingw64 $newMingw64 | grep ">" | sed "s/> //g" | tr '\n' ' '`
removeMingw64Packs=`diff $oldMingw64 $newMingw64 | grep "<" | sed "s/< //g" | tr '\n' ' '`
rm -f /etc/pac-mingw64-old.pk
fi
if [[ ! "$installBasePacks" == "" ]] || [[ ! "$installMingw32Packs" == "" ]] || [[ ! "$installMingw64Packs" == "" ]]; then
echo
echo "-------------------------------------------------------------------------------"
echo "You don't have the all the packs installed what the actual script need."
echo "Do you want to install them?"
echo "-------------------------------------------------------------------------------"
echo
while true; do
read -p "install packs: $installBasePacks $installMingw32Packs $installMingw64Packs:" yn
case $yn in
[Yy]* ) pacman --noconfirm -S $installBasePacks $installMingw32Packs $installMingw64Packs; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no";;
esac
done
fi
if [[ ! "$removeBasePacks" == "" ]] || [[ ! "$removeMingw32Packs" == "" ]] || [[ ! "$removeMingw64Packs" == "" ]]; then
echo
echo "-------------------------------------------------------------------------------"
echo "You have more base packs installed then the actual compiler script need."
echo "Do you want to remove them?"
echo "-------------------------------------------------------------------------------"
echo
while true; do
read -p "remove packs: $removeBasePacks $removeMingw32Packs $removeMingw64Packs:" yn
case $yn in
[Yy]* ) pacman --noconfirm -R $removeBasePacks $removeMingw32Packs $removeMingw64Packs; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no";;
esac
done
fi
fi
# --------------------------------------------------
# check profiles
# --------------------------------------------------
echo "-------------------------------------------------------------------------------"
echo "check profiles..."
echo "-------------------------------------------------------------------------------"
echo
iPath=`cygpath -w /`
cd $iPath/..
if [[ $build32 = "yes" ]]; then
if [ -f "/local32/etc/profile.local" ]; then
newProfiles32=`sed -n "/echo.# \/local32\/etc\/profile.local/,/echo.cross='i686-w64-mingw32-'/p" media-autobuild_suite.bat | sed "s/echo.//g"`
oldProfiles32=`sed -n "/# \/local32\/etc\/profile.local/,/cross='i686-w64-mingw32-'/p" /local32/etc/profile.local`
if ! cmp -s <(echo $newProfiles32) <(echo $oldProfiles32); then
echo
echo "-------------------------------------------------------------------------------"
echo "delete old 32 bit profile..."
echo "-------------------------------------------------------------------------------"
echo
rm -f /local32/etc/profile.local
fi
fi
fi
if [[ $build64 = "yes" ]]; then
if [ -f "/local64/etc/profile.local" ]; then
newProfiles64=`sed -n "/echo.# \/local64\/etc\/profile.local/,/echo.cross='x86_64-w64-mingw32-'/p" media-autobuild_suite.bat | sed "s/echo.//g"`
oldProfiles64=`sed -n "/# \/local64\/etc\/profile.local/,/cross='x86_64-w64-mingw32-'/p" /local64/etc/profile.local`
if ! cmp -s <(echo $newProfiles64) <(echo $oldProfiles64); then
echo
echo "-------------------------------------------------------------------------------"
echo "delete old 64 bit profile..."
echo "-------------------------------------------------------------------------------"
echo
rm -f /local64/etc/profile.local
fi
fi
fi
# --------------------------------------------------
# packet msys2 system
# --------------------------------------------------
echo "-------------------------------------------------------------------------------"
echo "updating msys2 system..."
echo "-------------------------------------------------------------------------------"
pacman --noconfirm -Syu --force --ignoregroup base
pacman --noconfirm -Su --force
echo "-------------------------------------------------------------------------------"
echo "updating msys2 done..."
echo "-------------------------------------------------------------------------------"
sleep 4
exit