refactor: simplify the parse

This commit is contained in:
SukkaW 2018-08-19 22:41:07 +08:00
parent 251429e274
commit c028a4a997
5 changed files with 81 additions and 42 deletions

View file

@ -7,7 +7,7 @@ install:
script: script:
- chmod +x ./checker.sh - chmod +x ./checker.sh
- chmod +x ./combine.sh - chmod +x ./combine.sh
- chmod +x ./xmlparser.sh - chmod +x ./util/xmlparser.sh
- chmod +x ./build.sh - chmod +x ./build.sh
- chmod +x ./deploy.sh - chmod +x ./deploy.sh
- ./checker.sh - ./checker.sh

9
run.sh Normal file
View file

@ -0,0 +1,9 @@
mkdir ./public -p
mkdir ./tmp/checker -p
mkdir ./tmp/parse -p
chmod +x ./util/checker.sh
chmod +x ./util/xmlparser.sh
chmod +x ./util/parse.sh
./util/parse.sh stable-x86 stable-x64 beta-x86 beta-x64 dev-x86 dev-x64 canary-x86 canary-x64

View file

@ -1,11 +1,10 @@
mkdir ./public
mkdir ./tmp
echo '-------------------------------------' echo '-------------------------------------'
echo 'Start Checking Chrome ......'
echo '-------------------------------------'
echo 'Checking Chrome Stable x86 ......' echo 'Checking Chrome Stable x86 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -14,14 +13,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/stable-x86.unformat.xml </request>" > ./tmp/checker/stable-x86.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Stable x64 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Stable x64 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -30,14 +30,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='x64-stable-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='x64-stable-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/stable-x64.unformat.xml </request>" > ./tmp/checker/stable-x64.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Beta x86 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Beta x86 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -46,14 +47,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='1.1-beta' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='1.1-beta' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/beta-x86.unformat.xml </request>" > ./tmp/checker/beta-x86.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Beta x64 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Beta x64 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -62,14 +64,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='x64-beta-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='x64-beta-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/beta-x64.unformat.xml </request>" > ./tmp/checker/beta-x64.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Dev x86 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Dev x86 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -78,14 +81,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='2.0-dev' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='2.0-dev' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/dev-x86.unformat.xml </request>" > ./tmp/checker/dev-x86.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Dev x64 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Dev x64 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -94,14 +98,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='x64-dev-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{8A69D345-D564-463C-AFF1-A69D9E530F96}' ap='x64-dev-multi-chrome' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/dev-x64.unformat.xml </request>" > ./tmp/checker/dev-x64.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Canary x86 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Canary x86 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -110,14 +115,15 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{4EA16AC7-FD5A-47C3-875B-DBF4A2008C20}' ap='' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{4EA16AC7-FD5A-47C3-875B-DBF4A2008C20}' ap='' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/canary-x86.unformat.xml </request>" > ./tmp/checker/canary-x86.xml
echo '' echo ''
echo '-------------------------------------'
echo 'Checking Chrome Canary x64 ......'
echo '-------------------------------------'
curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?> sleep 1
echo 'Checking Chrome Canary x64 ......'
curl -s "https://tools.google.com/service/update2" --data "<?xml version='1.0' encoding='UTF-8'?>
<request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0' <request protocol='3.0' version='1.3.23.9' shell_version='1.3.21.103' ismachine='0'
sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate' sessionid='{3597644B-2952-4F92-AE55-D315F45F80A5}' installsource='ondemandcheckforupdate'
requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'> requestid='{CD7523AD-A40D-49F4-AEEF-8C114B804658}' dedup='cr'>
@ -126,4 +132,4 @@ curl "https://tools.google.com/service/update2" --data "<?xml version='1.0' enco
<app appid='{4EA16AC7-FD5A-47C3-875B-DBF4A2008C20}' ap='x64-canary' version='' nextversion='' lang='' brand='GGLS' client=''> <app appid='{4EA16AC7-FD5A-47C3-875B-DBF4A2008C20}' ap='x64-canary' version='' nextversion='' lang='' brand='GGLS' client=''>
<updatecheck/> <updatecheck/>
</app> </app>
</request>" > ./tmp/canary-x64.unformat.xml </request>" > ./tmp/checker/canary-x64.xml

24
util/parse.sh Normal file
View file

@ -0,0 +1,24 @@
for i in $@
do
echo 'Parsing '${i}' data ......'
xmllint --format ./tmp/checker/${i}.xml > ./tmp/checker/${i}.format.xml
./util/xmlparser.sh ./tmp/checker/${i}.format.xml > ./tmp/parse/${i}.info
sed -i 's| ELEMENT=manifest ATTRIBUTE=version VALUE=||g' ./tmp/parse/${i}.info
sed -i 's| ELEMENT=url ATTRIBUTE=codebase VALUE=||g' ./tmp/parse/${i}.info
sed -i 's| ATTRIBUTE=hash |\n|g' ./tmp/parse/${i}.info
sed -i 's| ATTRIBUTE=name VALUE=|\n|g' ./tmp/parse/${i}.info
sed -i 's| ATTRIBUTE=required VALUE=true ATTRIBUTE=size VALUE=|\n|g' ./tmp/parse/${i}.info
sed -i 's| ATTRIBUTE=hash_sha256 VALUE=|\n|g' ./tmp/parse/${i}.info
sed -i 's| ELEMENT=time ATTRIBUTE=checktime VALUE=||g' ./tmp/parse/${i}.info
sed -i 's|https://||g' ./tmp/parse/${i}.info
sed -i 's| ||g' ./tmp/parse/${i}.info
sed -n '8p' ./tmp/parse/${i}.info > ./tmp/parse/${i}-result.info
sed -n '10p' ./tmp/parse/${i}.info >> ./tmp/parse/${i}-result.info
sed -n '14p' ./tmp/parse/${i}.info >> ./tmp/parse/${i}-result.info
sed -n '23p' ./tmp/parse/${i}.info >> ./tmp/parse/${i}-result.info
sed -n '22p' ./tmp/parse/${i}.info >> ./tmp/parse/${i}-result.info
sed -n '24p' ./tmp/parse/${i}.info >> ./tmp/parse/${i}-result.info
done