Skip to content

Commit

Permalink
envsetup: fixup dopush
Browse files Browse the repository at this point in the history
* After clobber, $OUT does not exist and tee cannot create .log; fix
  this by calling mkdir -p $OUT
* Make sure Copy and Install are at the beginning of the log line being
  analyzed and also search for ':' so that "Copying:" lines don't count
* Fix Copy file list by quoting so shell doesn't think this is a
  command: $LOC $(...)
* Fix 'only copy files from $OUT' now that multiple file pushing works
  right
* Only stop java services once (if needed) and then wait to restart
  services until after all files have been pushed
* Change location of SystemUI.apk to priv-app

Signed-off-by: Chirayu Desai <[email protected]>
Change-Id: I65edd34bf445b28c2638cb3e9621719121fb962f
  • Loading branch information
mdmower authored and Flinny committed Sep 8, 2016
1 parent 6975ec6 commit 7e36aaa
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1782,37 +1782,45 @@ function dopush()
sleep 0.3
adb remount &> /dev/null

mkdir -p $OUT
$func $* | tee $OUT/.log

# Install: <file>
LOC=$(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep 'Install' | cut -d ':' -f 2)
LOC="$(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Install: ' | cut -d ':' -f 2)"

# Copy: <file>
LOC=$LOC $(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep 'Copy' | cut -d ':' -f 2)
LOC="$LOC $(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Copy: ' | cut -d ':' -f 2)"

stop_n_start=false
for FILE in $LOC; do
# Get target file name (i.e. system/bin/adb)
TARGET=$(echo $FILE | sed "s#$OUT/##")
# Make sure file is in $OUT/system
case $FILE in
$OUT/system/*)
# Get target file name (i.e. /system/bin/adb)
TARGET=$(echo $FILE | sed "s#$OUT##")
;;
*) continue ;;
esac

# Don't send files that are not under /system or /data
if [ ! "echo $TARGET | egrep '^system\/' > /dev/null" -o \
"echo $TARGET | egrep '^data\/' > /dev/null" ] ; then
continue
else
case $TARGET in
system/app/SystemUI.apk|system/framework/*)
stop_n_start=true
case $TARGET in
/system/priv-app/SystemUI.apk|/system/framework/*)
# Only need to stop services once
if ! $stop_n_start; then
adb shell stop
stop_n_start=true
fi
echo "Pushing: $TARGET"
adb push $FILE $TARGET
;;
*)
stop_n_start=false
echo "Pushing: $TARGET"
adb push $FILE $TARGET
;;
esac
if $stop_n_start ; then adb shell stop ; fi
echo "Pushing: $TARGET"
adb push $FILE $TARGET
if $stop_n_start ; then adb shell start ; fi
fi
esac
done
if $stop_n_start; then
adb shell start
fi
rm -f $OUT/.log
return 0
else
Expand Down

0 comments on commit 7e36aaa

Please sign in to comment.