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

Commit 4d5a4206 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

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

Update for linux

See merge request !10
parents a4f6c634 9bcdb4f4
Loading
Loading
Loading
Loading

linux/get-from-ecloud.sh

deleted100755 → 0
+0 −77
Original line number Diff line number Diff line
#!/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
+20 −20
Original line number Diff line number Diff line
@@ -31,42 +31,42 @@

DEVICE_ID=$1
ARCHIVE_PATH=$2
ARCHIVE_NAME=$(basename $2)
ARCHIVE_NAME=$(basename "$2")
ADB_FOLDER_PATH=$3
ADB_PATH=""


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
+6 −12
Original line number Diff line number Diff line
@@ -27,20 +27,14 @@

TWRP_IMAGE_PATH=$1
HEIMDALL_FOLDER_PATH=$2
HEIMDALL_PATH=""


if [ ! -z $HEIMDALL_FOLDER_PATH ]
then
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
else
  HEIMDALL_PATH=heimdall
fi

echo "Heimdall path: $HEIMDALL_PATH"

if [ -z $TWRP_IMAGE_PATH ]
if [ -z "$TWRP_IMAGE_PATH" ]
then
	echo "TWRP Image path is empty"
  	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
+7 −10
Original line number Diff line number Diff line
@@ -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
	echo "OEM-unlock fails"
  	exit 10
fi

sleep 5s
echo "OEM unlocked"
 No newline at end of file
+4 −8
Original line number Diff line number Diff line
@@ -25,19 +25,15 @@
# - 1 : Error

HEIMDALL_FOLDER_PATH=$1
HEIMDALL_PATH=""


if [ ! -z $HEIMDALL_FOLDER_PATH ]
then
HEIMDALL_PATH=${HEIMDALL_FOLDER_PATH}"heimdall"
else
  HEIMDALL_PATH=heimdall
fi

while [ "`$HEIMDALL_PATH detect > /dev/null 2>&1; echo $?`" = 1 ]
echo "Heimdall path: $HEIMDALL_PATH"

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
Loading