aboutsummaryrefslogtreecommitdiff
path: root/stages/flash.sh
blob: 9de4d437df53a373fdcbeaf2a8626d5849229d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash

source .config

TMP_DIR="/tmp/driedlamu"
FIRMWARE_PATH="./unpacked"

case $1 in
	fresh)
		SYS_UPGRADE=0
		echo "[i] Installing DriedLamu."
	;;
	upgrade)
		SYS_UPGRADE=1
		echo "[i] Upgrading DriedLamu."
	;;
	*)
		echo "Please specify a valid type of task you wish to do (fresh, upgrade)."
		exit 1
	;;
esac

fastboot oem bldr_spoof off

if [[ $INSTALL_SU == 1 ]]; then
	echo "[i] Root installation enabled."

	if [[ $(fastboot devices | cut -d' ' -f2) == "fastboot" ]]; then
		fastboot flash boot "${FIRMWARE_PATH}/boot_su.img"
		
		if [[ -f "${FIRMWARE_PATH}/init_boot_su.img" ]]; then
			fastboot flash init_boot "${FIRMWARE_PATH}/init_boot_su.img"
		fi
	else
		echo "[i] Already in fastbootd mode. Make sure that patched 'boot.img' was installed."
	fi
fi

if [[ $ENABLE_VBMETA == 1 ]]; then
	echo "[i] Android verified boot enabled."

	if [[ $(fastboot devices | cut -d' ' -f2) == "fastboot" ]]; then
		fastboot flash boot "${STOCK_FIRMWARE_PATH}/boot.img"
		fastboot flash init_boot "${STOCK_FIRMWARE_PATH}/init_boot.img"

		fastboot flash vbmeta "${TMP_DIR}/vbmeta/vbmeta.img"
		fastboot flash vbmeta_system "${TMP_DIR}/vbmeta/vbmeta_system.img"
	else
		echo "[i] Already in fastbootd mode. Make sure that 'vbmeta' was flashed."
	fi
fi

if [[ $(fastboot devices | cut -d' ' -f2) == "fastboot" ]]; then
	echo "[i] Device in fastboot mode. Rebooting to fastbootd."
	sleep 1
	fastboot reboot fastboot
fi

fastboot erase system
fastboot erase system_ext
fastboot erase product

fastboot flash super ./super.img

# fastboot flash system_a "${FIRMWARE_PATH}/system_a.img"
# fastboot flash system_ext_a "${FIRMWARE_PATH}/system_ext_a.img"
# fastboot flash product_a "${FIRMWARE_PATH}/product_a.img"

if [[ $SYS_UPGRADE == 0 ]]; then
	fastboot -w
fi

if [[ $ENABLE_VBMETA == 1 ]]; then
	fastboot reboot-bootloader
	sleep 3
	fastboot oem bldr_spoof on
	fastboot reboot
else
	fastboot reboot
fi

echo "[i] Flashing done!"