-
Notifications
You must be signed in to change notification settings - Fork 4
/
check-version
executable file
·186 lines (132 loc) · 4.03 KB
/
check-version
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
#
# Check Package Version v9.0 - Verificação de Atualização dos Programas - By Mauricio Ferrari
#
#############################################################################################
# Definições de Variáveis
R='\e[31m'
G='\e[32m'
Y='\e[33m'
B='\e[34m'
C='\e[36m'
T='\e[m'
msg1="Checking Package Version ..."
msg2="Checking Source Link ..."
: "${0##*/}"; file="${0/$_/package-list}"
status='DISABLE -d'
SCR='\e[43;30m'
NOT_ST="FALSE"
SL_PKG="FALSE"
NM=1
PG=2
SP=0
# Checkar SlackBuilds
var=(*SlackBuild)
[ ! -e $var ] && var=(*/*SlackBuild) || var=($var */*SlackBuild)
[ ! -e $var ] && {
printf "\n${R}No SlackBuild Found!$T\n\n" >&2
exit 1
}
TOT=${#var[@]}
PARM=${var[@]}
# Seleção se Parâmetros
while getopts :pd OPTION; do
case $OPTION in
p) SL_PKG=TRUE
;;
d) NOT_ST=TRUE
PG=1
;;
esac
done
[ "$SL_PKG" == "TRUE" ] && {
[ "$2" ] && {
shift $((--OPTIND))
PARM="$@"
TOT=$(wc -w <<< $PARM)
}
}
PROG=$(bc -l <<< "100/($TOT*$PG)")
# Gerador de Linha e Redefinidor de Linhas do Terminal
line()
{
for ((i=0; i<$1; i++))
{
printf '─'
}
}
clean()
{
printf "\r%$1s\r" " "
}
# ### Gerar Cabeçalho da Tabela ###
printf "\n$B┌$(line 5)┬$(line 3)┬$(line 28)┬$(line 17)┬$(line 17)┬$(line 13)┐$T
$B│ QTD │ R │ Packages %18s│ Current Version │ New Version %4s│ ST SRC Link │$T
$B├$(line 5)┼$(line 3)┼$(line 28)┼$(line 17)┼$(line 17)┼$(line 13)┤$T\n"
# ### Loop para Verificação ###
for L in $(sort -u <(fmt -1 <<< $PARM))
{
AMR=$Y; CLR=$R
NVER='NOT FOUND'
: $(grep "^PRGNAM=" $L); PKG=${_/*=/}
: $(grep "^VERSION=[0-9]" $L); CVER=${_/*=/}
: $(grep "^LINK[1]*=" $L); SLINK=${_/*=/}
: $(grep -w "^$PKG " $file); METD=${_#*|}
: "$(grep -w "^$PKG " $file)"; : "${_#* }"; VLINK="${_%| *}"
# ### Controle de Versão ###
[ "$NOT_ST" == "TRUE" ] && {
clean 91
printf "\e]0;($PKG) - [ $NM / $TOT ] $msg1 %.2f%% \a" "${SP/./,}"
printf "$B└$(line 5)┴───┤$T $PKG %$((26-${#PKG}))s$B└─> $T [$R $NM $T/$R $TOT $T] $msg1 $R%.2f%% $T " " " "${SP/./,}"
} || {
printf "\e]0;($PKG) - [ $NM / $TOT ] : [ 1 / 2 ] $msg1 %.2f%% \a" "${SP/./,}"
printf "$B└$(line 5)┴───┤$T $PKG %$((26-${#PKG}))s$B└─> $T [$R $NM $T/$R $TOT $T] : [$R 1$T /$R 2 $T] $msg1 $R%.2f%% $T " " " "${SP/./,}"
}
[ "$METD" == "MET0" ] && page="$(links -dump $VLINK 2>/dev/null)"
[ "$CVER" == ":" ] && CVER=$(grep -Eo "([[:digit:]]+[.])+[[:digit:]]+" <(echo {./,PKGS/}$PKG/*txz))
[ "$METD" == "MET0" ] && NVER=$(head -1 <(grep -Eom1 "(([0-9]+)\.)+[0-9]+_*([a-z0-9])*" <(grep -Ev "([0-9]+\.)+[0-9]+k" <<< $page)))
[ "$METD" == "MANUAL" ] && {
NVER='MANUAL'
CLR=$Y
}
[[ "$METD" =~ NONE|MAIN ]] && {
NVER='DEFINED'
CLR=$C; AMR=$C
}
[ "$CVER" == "$NVER" ] && CLR=$G
[ "$CVER" == "" ] && {
CVER='NOT FOUND'
AMR=$R
}
# ### Status do Link ###
[ "$NOT_ST" == "FALSE" ] && {
SP=$(bc -l <<< "$SP+$PROG")
clean 105
printf "\e]0;($PKG) - [ $NM / $TOT ] : [ 2 / 2 ] $msg2 %.2f%% \a" "${SP/./,}"
printf "$B└$(line 5)┴───┤$T $PKG %$((26-${#PKG}))s$B└─> $T [$R $NM $T/$R $TOT $T] : [$R 2$T /$R 2 $T] $msg2 $R%.2f%% $T " " " "${SP/./,}"
SCR=$Y
[ "$METD" == "MAIN" ] && {
status="MAIN"
SCR=$B
} || status=$(./stcode $SLINK 2>&-)
[ "$status" == "200" ] && SCR=$G
[ "$status" == "404" ] && SCR=$R
[ "$status" == "" ] && {
status='NOT FOUND'
SCR=$R
}
}
# ### Verificação de Versões Obsoletas ###
DP=(PKGS/$PKG/$PKG*txz)
[ ! -e PKGS ] && DP=(../_PKGS/$PKG/$PKG*txz)
[ "${#DP[@]}" -gt 1 ] && X='X' || X=' '
# ### Resultado Final ###
clean 110
printf "$B│$T $Y%3d $B│$T ${R}$X $B│$T $CLR$PKG %$((26-${#PKG}))s$B│$T $AMR$CVER %$((15-${#CVER}))s$B│$T \
$CLR$NVER %$((15-${#NVER}))s$B│$T%$((11-${#status}))s $SCR$status$T $B│$T\n" "$NM"
SP=$(bc -l <<< "$SP+$PROG")
let NM++
status=
}
printf "$B└$(line 5)┴$(line 3)┴$(line 28)┴$(line 17)┴$(line 17)┴$(line 13)┘$T\n"
exit 0