Shell工具脚本-生成文件&下载资源并解析

主要包含功能如下:

1.自动生成文件

2.下载文件并解析

#  @Author: lvzhihong

#  @Date: 2023-08-29 08:43:41

#! /bin/bash

#config

project_code=("23861"  "23862" "23863")

project_out_root="aon_project_output"

project_apk_url="xxx/2023082904130232_APP_INFO_repo_10010111.xml";

declare -A aon_module_feature_map

aon_module_feature_map["gaze"]="oplus.hardware.aon_enable,oplus.software.aon_ant_peep_disable"

aon_module_feature_map["antipeep"]="oplus.hardware.aon_enable,oplus.software.aon_auto_none_screen_off_disable"

aon_module_feature_map["gesture_slide"]="oplus.software.aon_enable,oplus.software.aon_gestureui_enable"

aon_module_feature_map["gesture_phone"]="oplus.software.aon_enable,oplus.software.aon_phone_enable,oplus.software.aon_phone_camera_gesture_recognition,oplus.software.aon_phone_mute"

aon_module_feature_map["gesture_press"]="oplus.software.aon_enable,oplus.software.aon_gesture_press"

aon_module_feature_map["distance"]="oplus.software.aon_distance_detection_enable"

aon_module_feature_map["pose"]="oplus.software.aon_pose_detection_enable"

aon_module_feature_map["aod"]="oplus.software.aon_aod_enable"

aon_module_feature_map["explorer"]="oplus.software.aon_explorer_enable"

project_aon_modules_full=("gaze" "antipeep" "gesture_slide"  "gesture_phone" "gesture_press"  "distance"  "pose"  "aod" "explorer")

project_aon_features_full=("oplus.hardware.aon_enable" "oplus.software.aon_ant_peep_disable" "oplus.software.aon_auto_none_screen_off_disable" "oplus.software.aon_enable" "oplus.software.aon_phone_enable" "oplus.software.aon_phone_camera_gesture_recognition"

                            "oplus.software.aon_phone_mute" "oplus.software.aon_gestureui_enable" "oplus.software.aon_gesture_press" "oplus.software.aon_aod_enable" "oplus.software.aon_pose_detection_enable" "oplus.software.aon_distance_detection_enable" "oplus.software.aon_explorer_enable")

aon_feature_file_name="aon_project_output/oplus.product.feature_aon.xml"


 

#function

function generate_aon_feature_file(){

    rm ${aon_feature_file_name}

    aon_modules=$@

    echo "aon_modules="${aon_modules}

    config_feature=""

    echo ${config_feature}>>${aon_feature_file_name}

    for module in ${aon_modules[*]}

    do

        echo "module="${module}

        getFeatureConfigItem $module

    done

    if grep  ${project_aon_features_full[0]} ${aon_feature_file_name};then

        if echo ${aon_modules}|grep ${project_aon_modules_full[0]};then

        #with gaze

            sed -i "/${project_aon_features_full[2]}/d" ${aon_feature_file_name}

        fi

        if echo ${aon_modules}|grep ${project_aon_modules_full[1]};then

        #with antipeep

            sed -i "/${project_aon_features_full[1]}/d" ${aon_feature_file_name}

        fi

    fi

    echo "">>${aon_feature_file_name}

}    

function getFeatureConfigItem(){

    echo "getFeatureConfigItem:"$1

    OLD_IFS="$IFS"

    IFS=","

    array=(${aon_module_feature_map[$1]})

    IFS="$OLD_IFS"

    for featureItem in ${array[*]}

    do

        if grep $featureItem  ${aon_feature_file_name};then

            continue

        else

            echo "write file:"${featureItem}

            cat >> ./${aon_feature_file_name} << EOF

   

EOF

            echo "write file done"

        fi

    done

}

function downloadProjectInfo(){

     # 提取文件名

    filename=$(basename "${project_apk_url}")

   

    # 构建保存路径

    save_path="${project_out_root}/${filename}"

    wget -q "${project_apk_url}" -O "${save_path}"

    # 检查下载是否成功

    if [ $? -eq 0 ]; then

        echo "文件下载成功: $filename"

    else

        echo "文件下载失败: $filename"

    fi

    branch=`awk '/oplus\/pipeline\/product\/multimedia/ {split($0,arr," ");for(i in arr){if(match(arr[i],"upstream")){split(arr[i],array, "="); print array[2];}}}' ${save_path}`

    echo ${branch}

}



 

# 参数:项目要上的功能

# 目前支持功能配置如下

#project_aon_modules_full=("gaze" "antipeep" "gesture_slide"  "gesture_phone" "gesture_press"  "distance"  "pose"  "aod" "explorer")

mkdir ${project_out_root}

rf -rf ${project_out_root}

generate_aon_feature_file "gaze" "antipeep" "gesture_phone" "distance" "pose"

downloadProjectInfo

你可能感兴趣的:(chrome,前端)