Compare commits

..

No commits in common. "194fd4c5dd92f7419bd03ec6d6d1994c916a004f" and "157cfffdba1bf4ea70d334b28e973bb402c4f00b" have entirely different histories.

3 changed files with 13 additions and 41 deletions

View File

@ -4,7 +4,6 @@ RUN apt-get update
RUN apt-get install -y \ RUN apt-get install -y \
android-tools-adb \ android-tools-adb \
android-tools-fastboot android-tools-fastboot
RUN pip3 install protobuf
COPY . /magisk COPY . /magisk
WORKDIR /magisk WORKDIR /magisk
CMD bash reinstall-magisk-on-lineageos CMD bash reinstall-magisk-on-lineageos

View File

@ -25,9 +25,7 @@ Steps:
1. Build <br> 1. Build <br>
```docker build -t magiskupdate .``` ```docker build -t magiskupdate .```
2. Run <br> 2. Run <br>
```docker run --env ADB_DEVICE=<PUT YOUR ADB ADDR HERE> magiskupdate``` \ ```docker run --env ADB_DEVICE=<PUT YOUR ADB ADDR HERE> magiskupdate```
or, if you're lazy do:
```docker run magiskupdate```
## Bash ## Bash

View File

@ -3,9 +3,6 @@
set -e set -e
PHONE_ADB_SERIAL_NUMBER=${ADB_DEVICE} # The adb serial number can be found by running `adb devices`. PHONE_ADB_SERIAL_NUMBER=${ADB_DEVICE} # The adb serial number can be found by running `adb devices`.
if [$PHONE_ADB_SERIAL_NUMBER = '']; then
PHONE_ADB_SERIAL_NUMBER=$(echo $(adb devices) | sed -rn 's/(^|(.* ))([^ ]*) device(( .*)|$)/\3/; T; p; q')
fi
print_message() { print_message() {
printf "$1\n" printf "$1\n"
@ -45,15 +42,6 @@ get_build_url() {
head -1 head -1
} }
check_exists_latest_lineageos_build() {
# The --location lets curl follow the redirection.
curl --location "$(get_build_url)?sha256" --output /tmp/lineageos.sha256
hash1=$( awk '{print $1}' lineageos.sha256 )
hash2=$( sha256sum lineageos.zip | awk '{print $1}' )
[[ "$hash1" =~ "$hash2" ]]
return
}
download_latest_lineageos_build() { download_latest_lineageos_build() {
# The --location lets curl follow the redirection. # The --location lets curl follow the redirection.
curl --location "$(get_build_url)" --output /tmp/lineageos.zip curl --location "$(get_build_url)" --output /tmp/lineageos.zip
@ -75,6 +63,10 @@ extract_boot_image_from_file_based_ota() {
exit 1 exit 1
} }
install_python_protobuf() {
sudo python3 -m pip install protobuf
}
extract_payload_from_payload_based_ota() { extract_payload_from_payload_based_ota() {
unzip -od /tmp /tmp/lineageos.zip payload.bin unzip -od /tmp /tmp/lineageos.zip payload.bin
} }
@ -84,10 +76,11 @@ generate_random_alnum_string_of_length_6() {
} }
extract_boot_image_from_payload_file() { extract_boot_image_from_payload_file() {
install_python_protobuf
# For cases in which the repo has already been cloned, I prefer to create a random directory name to clone into, instead of deleting any file or directory on the user's machine. # For cases in which the repo has already been cloned, I prefer to create a random directory name to clone into, instead of deleting any file or directory on the user's machine.
scripts_directory_name="scripts_$(generate_random_alnum_string_of_length_6)" scripts_directory_name="scripts_$(generate_random_alnum_string_of_length_6)"
git clone https://github.com/LineageOS/scripts /tmp/$scripts_directory_name git clone https://github.com/LineageOS/scripts /tmp/$scripts_directory_name
python3 /tmp/$scripts_directory_name/update-payload-extractor/extract.py --partitions boot --output_dir /tmp/ /tmp/payload.bin python /tmp/$scripts_directory_name/update-payload-extractor/extract.py --partitions boot --output_dir /tmp/ /tmp/payload.bin
} }
extract_boot_image_from_payload_based_ota() { extract_boot_image_from_payload_based_ota() {
@ -146,22 +139,8 @@ reboot_phone() {
fastboot -s "$PHONE_ADB_SERIAL_NUMBER" reboot fastboot -s "$PHONE_ADB_SERIAL_NUMBER" reboot
} }
check_magisk_app() { check_magisk_folder() {
magisk_package_name="com.topjohnwu.magisk" adb -s "$PHONE_ADB_SERIAL_NUMBER" shell ls /data/adb/magisk/
magisk_package_name_count=$(adb -s "$PHONE_ADB_SERIAL_NUMBER" shell pm list packages "$magisk_package_name" | wc -l)
if [ "${magisk_package_name_count}" -eq 1 ]
then
print_message " [OK] Magisk app seems to be installed on selected phone"
elif [ "${magisk_package_name_count}" -eq 0 ]
then
print_message " [ERROR] Magisk app seems not installed on selected phone. Exiting."
exit -1
else
print_message " [ERROR] More than one Magisk app entry is present:"
adb -s "$PHONE_ADB_SERIAL_NUMBER" shell pm list packages "$magisk_package_name"
print_message "Exiting."
exit -1
fi
} }
is_rooted_debugging_enabled() { is_rooted_debugging_enabled() {
@ -173,14 +152,10 @@ main() {
check_phone_is_connected check_phone_is_connected
print_message "Checking on phone if rooted debugging is enabled" print_message "Checking on phone if rooted debugging is enabled"
is_rooted_debugging_enabled is_rooted_debugging_enabled
print_message "Checking on phone if Magisk is installed" print_message "Checking on phone if Magisk folder is present listing /data/adb/magisk/"
check_magisk_app check_magisk_folder
if check_exists_latest_lineageos_build; then
print_message "Build archive already exists, skipping download"
else
print_message "Downloading build archive from $(get_build_url)" print_message "Downloading build archive from $(get_build_url)"
download_latest_lineageos_build download_latest_lineageos_build
fi
print_message "Extracting 'boot.img' from build archive in /tmp/boot.img" print_message "Extracting 'boot.img' from build archive in /tmp/boot.img"
extract_boot_image extract_boot_image
print_message "Copying from PC to phone the boot image in /sdcard/Download/boot.img" print_message "Copying from PC to phone the boot image in /sdcard/Download/boot.img"