Commit 4d5a4206 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer 🎼

Merge branch 'update-for-linux' into 'folder_per_platform'

Update for linux

See merge request !10
parents a4f6c634 9bcdb4f4
#!/bin/bash
# Copyright (C) 2019 ECORP SAS - Author: Romain Hunault
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Parameter
# $1: ARCHIVE_URL
# $2: FOLDER (will be created if doesn't exist)
# Exit status
# - 0 : archive downloaded
# - 1 : Generic error code (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 2 : Parse error—for instance, when parsing command-line options, the ‘.wgetrc’ or ‘.netrc’... (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 3 : File I/O error (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 4 : Network failure (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 5 : SSL verification failure (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 6 : Username/password authentication failure (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 7 : Protocol errors (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 8 : Server issued an error response (see wget exit status here: https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html)
# - 10: No internet connection
# - 11: Invalid file downloaded
# - 101 : ARCHIVE_URL missing
# - 102 : FOLDER missing
ARCHIVE_URL=$1
FOLDER=$2
if ! curl -s -IL https://gitlab.e.foundation | grep -q "^HTTP\/2 200"
then
exit 10
fi
if [ -z ${FOLDER} ]
then
exit 101
fi
if [ -z ${ARCHIVE_URL} ]
then
exit 102
fi
mkdir -p ${FOLDER}
FILENAME=$(basename ${ARCHIVE_URL})
wget -O ${FOLDER}/${FILENAME}.sha256sum ${ARCHIVE_URL}.sha256sum
FOLDER_ESCAPED=$(echo ${FOLDER} | sed 's/\/$//' | sed 's/\//\\\//g')
sed -i 's/\(.*\) \(.*\)/\1 '${FOLDER_ESCAPED}'\/\2/' ${FOLDER}/${FILENAME}.sha256sum
sha256sum -c ${FOLDER}/${FILENAME}.sha256sum
SUM_OK=$?
if [ ${SUM_OK} = 0 ]
then
exit 0
fi
wget -O ${FOLDER}/${FILENAME} ${ARCHIVE_URL}
sha256sum -c ${FOLDER}/${FILENAME}.sha256sum
SUM_OK=$?
if [ ${SUM_OK} != 0 ]
then
rm ${FILENAME}
exit 11
fi
......@@ -31,42 +31,42 @@
DEVICE_ID=$1
ARCHIVE_PATH=$2
ARCHIVE_NAME=$(basename $2)
ARCHIVE_NAME=$(basename "$2")
ADB_FOLDER_PATH=$3
ADB_PATH=""
ADB_PATH=${ADB_FOLDER_PATH}"adb"
if [ ! -z $ADB_FOLDER_PATH ]
then
ADB_PATH=${ADB_FOLDER_PATH}"adb"
else
ADB_PATH=adb
fi
if [ -z $DEVICE_ID ]
echo "adb path : $ADB_PATH"
if [ -z "$DEVICE_ID" ]
then
exit 101
fi
if [ -z $ARCHIVE_PATH ]
if [ -z "$ARCHIVE_PATH" ]
then
exit 102
fi
# "$ADB_PATH" kill-server
# "$ADB_PATH" devices
"$ADB_PATH" -s "$DEVICE_ID" shell "twrp wipe system"
echo "system wiped"
"$ADB_PATH" -s "$DEVICE_ID" shell "twrp wipe cache"
echo "cache wiped"
"$ADB_PATH" -s "$DEVICE_ID" shell "twrp wipe data"
echo "data wiped"
$ADB_PATH -s ${DEVICE_ID} shell twrp wipe system
$ADB_PATH -s ${DEVICE_ID} shell twrp wipe cache
$ADB_PATH -s ${DEVICE_ID} shell twrp wipe data
$ADB_PATH -s ${DEVICE_ID} push ${ARCHIVE_PATH} /sdcard
if [ $? != 0 ] ; then exit 2 ; fi
$ADB_PATH -s ${DEVICE_ID} shell twrp install /sdcard/${ARCHIVE_NAME}
if ! "$ADB_PATH" -s "$DEVICE_ID" push "$ARCHIVE_PATH" /sdcard ;
then exit 2 ; fi
if [ $? != 0 ] ; then exit 3 ; fi
if ! "$ADB_PATH" -s "$DEVICE_ID" shell twrp install /sdcard/"$ARCHIVE_NAME" ;
then exit 3 ; fi
sleep 1
$ADB_PATH -s ${DEVICE_ID} shell rm /sdcard/${ARCHIVE_NAME}
"$ADB_PATH" -s "$DEVICE_ID" shell rm /sdcard/"$ARCHIVE_NAME"
sleep 1
......@@ -27,20 +27,14 @@
TWRP_IMAGE_PATH=$1
HEIMDALL_FOLDER_PATH=$2
HEIMDALL_PATH=""
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
echo "Heimdall path: $HEIMDALL_PATH"
if [ ! -z $HEIMDALL_FOLDER_PATH ]
if [ -z "$TWRP_IMAGE_PATH" ]
then
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
else
HEIMDALL_PATH=heimdall
echo "TWRP Image path is empty"
exit 101
fi
if [ -z $TWRP_IMAGE_PATH ]
then
exit 101
fi
$HEIMDALL_PATH flash --RECOVERY ${TWRP_IMAGE_PATH} --no-reboot
"$HEIMDALL_PATH" flash --RECOVERY "$TWRP_IMAGE_PATH" --no-reboot
\ No newline at end of file
......@@ -24,21 +24,18 @@
# - 10 : heimdall error
HEIMDALL_FOLDER_PATH=$1
HEIMDALL_PATH=""
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
echo "Heimdall path: $HEIMDALL_PATH"
if [ ! -z $HEIMDALL_FOLDER_PATH ]
then
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
else
HEIMDALL_PATH=heimdall
fi
$HEIMDALL_PATH print-pit
if [ $? = 1 ]
if [ "$($HEIMDALL_PATH print-pit)" = 1 ]
then
exit 10
echo "OEM-unlock fails"
exit 10
fi
sleep 5s
echo "OEM unlocked"
\ No newline at end of file
......@@ -25,19 +25,15 @@
# - 1 : Error
HEIMDALL_FOLDER_PATH=$1
HEIMDALL_PATH=""
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
if [ ! -z $HEIMDALL_FOLDER_PATH ]
then
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
else
HEIMDALL_PATH=heimdall
fi
echo "Heimdall path: $HEIMDALL_PATH"
while [ "`$HEIMDALL_PATH detect > /dev/null 2>&1; echo $?`" = 1 ]
while [ "$($HEIMDALL_PATH detect > /dev/null 2>&1; echo $?)" = 1 ]
do
sleep 1s
done
sleep 5s
echo "Download mode detected"
\ No newline at end of file
......@@ -21,39 +21,33 @@
# $2: ADB_FOLDER_PATH: the path where runnable adb is stored
# Exit status
# - 0 : New device detected
# - 0 : success
# - 1 : Error
# - 10 : DEVICE_ID is missing
# - 101 : DEVICE_ID is not detected
# - 101 : device with DEVICE_ID is not detected
DEVICE_ID=$1
ADB_FOLDER_PATH=$2
ADB_PATH=""
ADB_PATH=${ADB_FOLDER_PATH}"adb"
if [ ! -z $ADB_FOLDER_PATH ]
then
ADB_PATH=${ADB_FOLDER_PATH}"adb"
else
ADB_PATH=adb
fi
echo "ADB path: $ADB_PATH"
if [ -z $DEVICE_ID ]
if [ -z "$DEVICE_ID" ]
then
exit 10
fi
#1 On check that device is in recovery mode
$ADB_PATH -s ${DEVICE_ID} get-state 2>&1 | grep "recovery"
if [ $? != 0 ]
if ! "$ADB_PATH" -s "$DEVICE_ID" get-state 2>&1 | grep "recovery"
then
echo "Device not detected in recovery"
exit 101
fi
#Then we wait that it left this state
while $ADB_PATH -s ${DEVICE_ID} get-state 2> /dev/null
while "$ADB_PATH" -s "$DEVICE_ID" get-state 2> /dev/null
do
sleep 1
done
\ No newline at end of file
......@@ -22,54 +22,33 @@
# $1: DEVICE_ID ID of the device to wait
# $2: ADB_FOLDER_PATH: the path where runnable adb is stored
# Return
# - displayed: DEVICE_ID device detected
# Exit status
# - 0 : New device detected
# - 1 : Error
# - 101 : DEVICES_LOCKED_PATH missing
# - 0 : success
# - 1 : twrp mount system failed
# - 101 : DEVICE_ID missing
# - 102 : adb wait recovery failed
ADB_FOLDER_PATH=$1
DEVICE_ID=$1
ADB_FOLDER_PATH=$2
ADB_PATH=""
DEVICE_ID=$2
if [ ! -z $ADB_FOLDER_PATH ]
if [ -z "$DEVICE_ID" ]
then
ADB_PATH=${ADB_FOLDER_PATH}"adb"
else
ADB_PATH=adb
exit 101
fi
if [ ! -z $DEVICE_ID ]
ADB_PATH=${ADB_FOLDER_PATH}"adb"
echo "waiting for recovery"
if "$ADB_PATH" -s "$DEVICE_ID" wait-for-recovery
then
$ADB_PATH -s ${DEVICE_ID} wait-for-recovery
if [ $? == 0 ]
echo "device found in recovery"
if ! "$ADB_PATH" -s "$DEVICE_ID" shell twrp mount system
then
$ADB_PATH -s ${DEVICE_ID} shell twrp mount system
exit 0
echo "twrp mount system failed"
exit 1
fi
fi
new_device=false
while ! $new_device
do
DEVICE_ID=$(eval $ADB_PATH" get-serialno")
if [ ! -z $DEVICE_ID ]
then
new_device=true
fi
sleep 1
done
$ADB_PATH -s ${DEVICE_ID} wait-for-recovery
if [ $? == 0 ]
then
$ADB_PATH -s ${DEVICE_ID} shell twrp mount system
fi
echo ${DEVICE_ID}
else
echo "device not detected in recovery"
exit 102
fi
\ No newline at end of file
#!/bin/sh
# Copyright (C) 2020 ECORP SAS - Author: Vincent Bourgmayer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This a wrapper for linux flash's scripts.
STEP="$1.sh"
SCRIPT_FOLDER="./"
if [ -z $1 ]
then
echo "Exit: No script to execute passed in param"
exit 1
fi
shift
echo "command to perform is: . $SCRIPT_FOLDER$STEP $@"
$SCRIPT_FOLDER$STEP "$@"
exit $?
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment