Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ec8c898 authored by Matt Mower's avatar Matt Mower Committed by Abhisek Devkota
Browse files

envsetup: fixup dopush



* 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: default avatarChirayu Desai <cdesai@cyanogenmod.org>
Change-Id: I65edd34bf445b28c2638cb3e9621719121fb962f
parent b955a232
Loading
Loading
Loading
Loading
+27 −19
Original line number Diff line number Diff line
@@ -2012,37 +2012,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/*)
            /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
            ;;
            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