56 lines
1.6 KiB
Bash
56 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
package_array=("" "app.yinm.chat.a1." "app.yinm.chat.b2." "app.yinm.room.aa." "app.yinm.room.aa.bd." "app.yinm.room.aa.db." "app.yinm.room.bb." "app.yinm.room.bb.ww." "app.yinm.room.bb.mm.")
|
|
same_name_files=$(cat same_name_file.txt)
|
|
touch move_dir_map.txt
|
|
cat /dev/null > move_dir_map.txt
|
|
echo "[" >> move_dir_map.txt
|
|
|
|
end_with=(' ' '{' '.')
|
|
|
|
cp proguard_rules.txt proguard_rules_after_move_dir.txt
|
|
|
|
for file in ${same_name_files[*]}
|
|
do
|
|
echo "**********\n"
|
|
|
|
echo '文件 - '"$file"
|
|
|
|
split_str="/java"
|
|
is_contain=$(echo "$file" | grep "$split_str")
|
|
if [[ "$is_contain" == "" ]]
|
|
then
|
|
split_str="/src"
|
|
fi
|
|
|
|
import_str=$(echo "$file" | awk -F "${split_str}/" '{print $2}' | awk -F "." '{print $1}' | sed 's/\//\./g')
|
|
class_name=$(echo "$import_str" | awk -F "." '{print $NF}')
|
|
package_path=$(echo "$import_str" | awk -F ".${class_name}" '{print $1}' )
|
|
echo '包名 - '"$package_path"
|
|
|
|
is_gen=$(cat move_dir_map.txt | grep "$package_path")
|
|
if [[ "$is_gen" != "" ]]
|
|
then
|
|
continue
|
|
fi
|
|
|
|
file_md5=$(echo "$file" | md5 | sed 's/[0-9]//g')
|
|
random_index=$((RANDOM % ${#package_array[@]}))
|
|
random_package=${package_array[$random_index]}
|
|
new_name=${random_package}$(echo "$file_md5" | rev)
|
|
echo '新包名 - '"$new_name"
|
|
|
|
for endStr in ${end_with[*]}
|
|
do
|
|
sed_format_package_path=$(echo "$package_path""$endStr" | sed 's/\./\\\./g')
|
|
replace_str=$(echo "$new_name""$endStr" | sed 's/\./\\\./g')
|
|
sed -i "" "s/${sed_format_package_path}/${replace_str}/g" proguard_rules_after_move_dir.txt
|
|
done
|
|
|
|
echo '"'"$package_path"'" : "'"$new_name"'",' >> move_dir_map.txt
|
|
|
|
echo "\n**********"
|
|
done
|
|
|
|
echo "]" >> move_dir_map.txt |