From 810df662b09cc80ac6c1711621558b30734fe9cf Mon Sep 17 00:00:00 2001 From: shenmo Date: Thu, 13 Jul 2023 14:44:13 +0000 Subject: [PATCH] =?UTF-8?q?=E8=AE=BA=E4=B8=80=E4=B8=AA=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E4=BA=BA?= =?UTF-8?q?=E6=9D=A5=E5=81=9A=E4=B8=8B=E8=BD=BD=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E8=83=BD=E7=94=A8=E5=87=BA=E4=BB=80=E4=B9=88=E6=83=8A=E5=A4=A9?= =?UTF-8?q?=E5=9C=B0=E6=B3=A3=E9=AC=BC=E7=A5=9E=E7=9A=84=E6=9A=B4=E5=8A=9B?= =?UTF-8?q?=E6=89=8B=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenmo --- shell/download-times-rank-gen.sh | 110 +++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 shell/download-times-rank-gen.sh diff --git a/shell/download-times-rank-gen.sh b/shell/download-times-rank-gen.sh new file mode 100644 index 0000000..6ba9f8d --- /dev/null +++ b/shell/download-times-rank-gen.sh @@ -0,0 +1,110 @@ +#/bin/bash +REPOPATH="$1" #设置软件源目录 +cd $REPOPATH #进入根目录 + + + +echo "--------排查download-times.txt是否存在阶段开始" +for i in `ls` #for循环遍历store目录下的文件 +do + if [ -d $i ] ; then #如果当前变量的是目录 + if [ "$i" = "depends" ] || [ "$i" = "static" ] || [ "$i" = "upload_tgz" ] || [ "$i" = "ossutil_output" ] || [ "$i" = "home" ] || [ "$i" = "package-data" ];then # 判断是否是不参与排名的 + echo "$i 目录不参与下载量排名,被排除在外" + continue + fi + + cd $i #进入目录 + for j in `ls` #for循环遍历目录下的文件 + do + if [ -d $j ] ; then #如果当前变量的是目录 + cd $j #进入目录 + if [ ! -f 'app.json' ];then + echo "警告:`pwd`处的应用无app.json!跳过..." + fi + + + if [ ! -f 'download-times.txt' ];then #如果不存在下载量文件,则退出 + echo 0 > download-times.txt + echo "`pwd` 处无download-times.txt文件,已创建" + fi + cd .. + fi + done + cd .. + + fi + +done + + echo "--------排查download-times.txt是否存在阶段结束" +echo "--------开始生成排名" + +for i in `ls` #for循环遍历store目录下的文件 +do + if [ -d $i ] ; then #如果当前变量的是目录 + if [ "$i" = "depends" ] || [ "$i" = "static" ] || [ "$i" = "upload_tgz" ] || [ "$i" = "ossutil_output" ] || [ "$i" = "home" ] || [ "$i" = "package-data" ];then # 判断是否是不参与排名的 + echo "$i 目录不参与下载量排名,被排除在外" + continue + fi + + cd $i #进入目录 + + +rm -f ./temp-list.txt + +lines=`find . -name download-times.txt | wc -l ` +echo "所在分类为 `pwd | xargs basename` ,此分类下的总应用数为:$lines" +file_list=`find . -name download-times.txt` +i=1 + +until [ $i -gt $lines ];do +file_path=`echo "${file_list}" | sed -n '1p'` +file_list=`echo "${file_list}" | sed '1d'` +echo "$file_path#`cat $file_path`" >> ./temp-list.txt + +let i=$i+1 + +done + +sort -n -r -k 2 -t '#' ./temp-list.txt -o ./temp-list.txt +sed -i "{s/#.*//}" ./temp-list.txt + + + +lines=`cat ./temp-list.txt | wc -l ` +i=1 + +echo "[" > applist.json +until [ $i -gt $lines ];do +file_path=`cat "./temp-list.txt" | sed -n '1p'` +sed -i '1d' ./temp-list.txt +file_path=$(echo ${file_path%/*}) +file_path=$(echo "$file_path"/app.json"") + +cat $file_path >> applist.json +echo >> applist.json +echo ",">> applist.json #用逗号分隔 + +let i=$i+1 + +done + +rm -f ./temp-list.txt +sed -i '$d' applist.json #删除最后一行的逗号 +echo "]">> applist.json #写入右半部分 + + + +cd .. + +fi +done + +#####APPLIST_ALL +#cd $REPOPATH +#rm -f applist-all.json +#cat `find . -name 'applist.json' -type f`|jq -s . > applist-all.json + + + +echo "按下载量顺序生成applist.json过程结束" -- Gitee