Skip to content

Instantly share code, notes, and snippets.

@stephendonner
Created December 6, 2013 17:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephendonner/7828744 to your computer and use it in GitHub Desktop.
Save stephendonner/7828744 to your computer and use it in GitHub Desktop.
1) grab an engineering mozilla-central build from pvtbuilds, for Hamachi 2) rename it to be "hamachi.zip" 3) put it in the same folder as this flash script 4) chmod +x new-flash.sh (or whatever you want to call the file) 5) ./new-flash.sh
#!/bin/bash -xe
wait_for_device() {
SERIAL=MSM7627A
DEVICE=05c6
# to break out if failed after so many tries.
# RETRYTIME*MAXWAITTIME is how long the max wait time will be
RETRYTIME=1
MAXWAITTIME=60
TRYCOUNT=0
LOOP=true
while ${LOOP}; do
ADB_OUTPUT="$(echo "$(adb devices)"|grep -Z ${SERIAL}|sed 's/\t/ /g')"
LSB_OUTPUT='$(echo "$(lsusb)"|grep ${DEVICE})'
if [[ ! ${ADB_OUTPUT} ]] && [[ ${LSB_OUTPUT} ]]; then
echo "Restarting ADB server"
$(adb kill-server)
sleep 5
ADB_OUTPUT="$(echo "$(adb devices)"|grep -Z ${SERIAL}|sed 's/\t/ /g')"
sleep 15
fi
if [[ ${ADB_OUTPUT} ]]; then
ADB_ONLINE="$(echo ${ADB_OUTPUT}|grep device)"
if [[ ${ADB_ONLINE} ]]; then
LOOP=false
echo "'$(adb devices)'"
adb shell 'i=1;
retries=60
while [ "$(getprop sys.boot_completed)" == "1" ]; do
if (( i++ > ($retries - 1) )); then
exit 1;
fi;
sleep 1;
done'
fi
fi
# Breakout if we tried too many times
if [ ${TRYCOUNT} -ge ${MAXWAITTIME} ]; then
LOOP=false
echo "Max wait time reached! Can't find device."
fi
sleep ${RETRYTIME};
TRYCOUNT=$(( $TRYCOUNT + 1 ))
done
}
# adb devices
# echo -e "\n\033[1;30mRestarting adb server\033[0m"
#adb kill-server
# adb start-server
# adb wait-for-device
# adb shell 'i=1;
# retries=60
# while [ "$(getprop sys.boot_completed)" == "1" ]; do
# if (( i++ > ($retries - 1) )); then
# exit 1;
# fi;
# sleep 1;
# done'
# sleep 30
# adb devices
wait_for_device
echo -e "\nShowing free space"
adb shell df
# clearing cache
# echo 'reboot into fastboot mode'
# adb reboot bootloader
# echo 'wait for the device'
# fastboot wait-for-device
# sleep 60
# fastboot devices
# echo 'clearing cache'
# fastboot erase cache
# sleep 20
# echo 'rebooting device'
# fastboot reboot
# waiting for the device
# echo 'Waiting for device...'
# adb wait-for-device
echo -e "\nUnzipping the distro"
unzip hamachi.zip
cd b2g-distro
echo -e "\nGaining root access"
adb root
echo -e "\nRemounting the system partition"
adb remount
echo -e "\nStopping b2g"
adb shell stop b2g
echo -e "\nDeleting battery charging status"
adb shell rm /system/bin/battery_charging
echo -e "\nDeleting webapps"
adb shell rm -r /data/local/webapps
adb shell rm -r /system/b2g/webapps
echo -e "\nDeleting any old gaia and profiles"
adb shell rm -r /cache/*
adb shell rm -r /data/b2g/*
adb shell rm -r /data/local/user.js
adb shell rm -r /data/local/permissions.sqlite
adb shell rm -r /data/local/OfflineCache
adb shell rm -r /data/local/indexedDB
adb shell rm -r /data/local/debug_info_trigger
adb shell rm -r /data/local/storage/persistent/*
adb shell rm -r /data/misc/wifi/*
adb shell rm -r /data/local/svoperapps
echo -e "\nShowing free space"
adb shell df
echo -e "\nInstalling new b2g"
adb push b2g /system/b2g
echo -e "\nDone installing Gecko"
echo -e "\nUninstalling old RIL"
adb shell rm -r /system/b2g/distribution/bundles/libqc_b2g_location
adb shell rm -r /system/b2g/distribution/bundles/libqc_b2g_ril
echo -e "\nDeleting incompatible extensions"
adb shell rm -r /system/b2g/distribution/bundles/liblge_b2g_extension > /dev/null
cat gaia/profile/user.js | sed -e "s/user_pref/pref/" > user.js
echo -e "\nRebooting to release space"
echo -e "Syncing"
adb shell sync
adb reboot
sleep 30
# adb wait-for-device
# adb shell 'i=1;
# retries=60
# while [ "$(getprop sys.boot_completed)" == "1" ]; do
# if (( i++ > ($retries - 1) )); then
# exit 1;
# fi;
# sleep 1;
# done'
# wait_for_device
echo -e "\nGaining root access"
adb root
echo -e "\nRemounting the system partition"
adb remount
echo -e "\nShowing free space"
adb shell df
# XXX - Fabrice's _awesome fix to stop b2g -- to prevent a race condition -- below_
adb shell stop b2g
echo -e "\n\033[1;30mInstalling new gaia webapps\033[0m"
adb shell mkdir -p /system/b2g/defaults/pref
adb push gaia/profile/webapps /system/b2g/webapps
adb push user.js /system/b2g/defaults/pref
adb push gaia/profile/settings.json /system/b2g/defaults
# echo -e "\nRebooting"
adb shell reboot
sleep 30
# adb wait-for-device
# adb shell 'i=1;
# retries=60
# while [ "$(getprop sys.boot_completed)" == "1" ]; do
# if (( i++ > ($retries - 1) )); then
# exit 1;
# fi;
# sleep 1;
# done'
wait_for_device
echo -e "\nDone flashing"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment