#!/bin/bash
path=$1
in_path="/data/local/tmp"
if [ ! -d $path ]; then
echo "请传入一个目录!"
exit 0;
fi
declare file_dir
echo "开始推送目录"
adb push $path /data/local/tmp/
file_dir=$(basename $path)
echo "推送目录成功"
session_result=$(adb shell pm install-create)
declare session_id
if [ $? -eq 0 ]; then
echo "获取session成功: $session_result"
session_id=$(echo "$session_result" | grep -o '[0-9]\+')
echo "session_id: $session_id"
else
echo "获取session失败: $?."
exit 0;
fi
in_file_dir=$in_path/$file_dir
echo in_file_dir: $in_file_dir
files_string=$(adb shell ls $in_file_dir)
IFS=$'\n' read -r -d '' -a lines <<< "$files_string"
for file in "${lines[@]}"; do
echo $file
split_name=$(echo $(basename $file) | cut -d'.' -f1)
adb shell pm install-write $session_id base_$RANDOM $in_file_dir/$file
done
adb shell pm install-commit $session_id
网友评论