Browse Source

Merge remote-tracking branch 'origin/dev-ivo'

pull/1/head^2
gabriel becker 2 years ago
parent
commit
194fd4c5dd
  1. 1
      Dockerfile
  2. 46
      reinstall-magisk-on-lineageos

1
Dockerfile

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

46
reinstall-magisk-on-lineageos

@ -45,6 +45,15 @@ get_build_url() {
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() {
# The --location lets curl follow the redirection.
curl --location "$(get_build_url)" --output /tmp/lineageos.zip
@ -66,10 +75,6 @@ extract_boot_image_from_file_based_ota() {
exit 1
}
install_python_protobuf() {
sudo python3 -m pip install protobuf
}
extract_payload_from_payload_based_ota() {
unzip -od /tmp /tmp/lineageos.zip payload.bin
}
@ -79,11 +84,10 @@ generate_random_alnum_string_of_length_6() {
}
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.
scripts_directory_name="scripts_$(generate_random_alnum_string_of_length_6)"
git clone https://github.com/LineageOS/scripts /tmp/$scripts_directory_name
python /tmp/$scripts_directory_name/update-payload-extractor/extract.py --partitions boot --output_dir /tmp/ /tmp/payload.bin
python3 /tmp/$scripts_directory_name/update-payload-extractor/extract.py --partitions boot --output_dir /tmp/ /tmp/payload.bin
}
extract_boot_image_from_payload_based_ota() {
@ -142,8 +146,22 @@ reboot_phone() {
fastboot -s "$PHONE_ADB_SERIAL_NUMBER" reboot
}
check_magisk_folder() {
adb -s "$PHONE_ADB_SERIAL_NUMBER" shell ls /data/adb/magisk/
check_magisk_app() {
magisk_package_name="com.topjohnwu.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() {
@ -155,10 +173,14 @@ main() {
check_phone_is_connected
print_message "Checking on phone if rooted debugging is enabled"
is_rooted_debugging_enabled
print_message "Checking on phone if Magisk folder is present listing /data/adb/magisk/"
check_magisk_folder
print_message "Downloading build archive from $(get_build_url)"
download_latest_lineageos_build
print_message "Checking on phone if Magisk is installed"
check_magisk_app
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)"
download_latest_lineageos_build
fi
print_message "Extracting 'boot.img' from build archive in /tmp/boot.img"
extract_boot_image
print_message "Copying from PC to phone the boot image in /sdcard/Download/boot.img"

Loading…
Cancel
Save