First up, thank you for doing this. I appreciate the work you've done and it was ultimately useful.
That said, I ran into a few problems, so I'm trying to describe them and their solutions below.
(Sorry if this comes across as a diatribe, I am hoping this level of detail will be helpful to others.)
On Windows 11 using mintty (git bash), I kept getting this:
[...]
Checking on phone if Magisk folder is present listing /data/adb/magisk/
ls: C:/Program: No such file or directory
ls: Files/Git/data/adb/magisk/: No such file or directory
I think this is actually a bug in mintty, but I worked around it by putting quotes around the adb shell command here fixed it:
Then I ran into a download error where it had a blank URL. I decided that maybe windows just wasn't meant to be and switched to a mac. Got the same error:
[...]
Downloading build archive from
curl: (3) URL using bad/illegal format or missing URL
On a related note, it might be smart to add a dependency check for things like adb, jq, and python (foreshadowing...)
The download succeeded and it wanted to pip install something as root. Gave me this output:
[...]
Extracting 'boot.img' from build archive in /tmp/boot.img
Archive: /tmp/lineageos.zip
signed by SignApk
extracting: /tmp/payload.bin
Password:
WARNING: The directory '/Users/nathan/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting protobuf
Downloading protobuf-4.22.1-cp37-abi3-macosx_10_9_universal2.whl (397 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 397.2/397.2 kB 3.6 MB/s eta 0:00:00
Installing collected packages: protobuf
Successfully installed protobuf-4.22.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
tr: Illegal byte sequence
Cloning into '/tmp/scripts_'...
remote: Enumerating objects: 695, done.
remote: Counting objects: 100% (211/211), done.
remote: Compressing objects: 100% (87/87), done.
remote: Total 695 (delta 191), reused 124 (delta 124), pack-reused 484
Receiving objects: 100% (695/695), 224.08 KiB | 1.35 MiB/s, done.
Resolving deltas: 100% (361/361), done.
./reinstall-magisk-on-lineageos: line 79: python: command not found
(Or so I thought. We'll revisit this error again in a minute. Regardless, the sudo seemed unnecessary in my case.)
Edit: on second thought, maybe it just worked because the first run with sudo installed it. That deserves a bit more investigation.
Next up I found that the "random" part of the random temp directory doesn't seem to be working:
[...]
Extracting 'boot.img' from build archive in /tmp/boot.img
Archive: /tmp/lineageos.zip
signed by SignApk
extracting: /tmp/payload.bin
Requirement already satisfied: protobuf in /opt/homebrew/lib/python3.10/site-packages (4.22.1)
tr: Illegal byte sequence
fatal: destination path '/tmp/scripts_' already exists and is not an empty directory.
This is from this line - apparently it doesn't work quite the same on macOS:
I replaced it with date +%s because it's not like I'm going to be running this script more than once a second, and who cares about the length of a random temp folder's name?
Next up, that python error again:
[...]
./reinstall-magisk-on-lineageos: line 80: python: command not found
(It turns out that macOS Ventura doesn't even have a built-in python command, just python3!)
Next error is coming from the protobufs library:
[...]
Traceback (most recent call last):
File "/tmp/scripts_1678464917/update-payload-extractor/extract.py", line 7, in <module>
import update_payload
File "/private/tmp/scripts_1678464917/update-payload-extractor/update_payload/__init__.py", line 22, in <module>
from update_payload.checker import CHECKS_TO_DISABLE
File "/private/tmp/scripts_1678464917/update-payload-extractor/update_payload/checker.py", line 40, in <module>
from update_payload import common
File "/private/tmp/scripts_1678464917/update-payload-extractor/update_payload/common.py", line 24, in <module>
from update_payload import update_metadata_pb2
File "/private/tmp/scripts_1678464917/update-payload-extractor/update_payload/update_metadata_pb2.py", line 32, in <module>
_descriptor.EnumValueDescriptor(
File "/opt/homebrew/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 796, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
My phone is once again rooted so that I can pass the CTS Profile Check, so I can run "secure" apps like my banking app.. and netflix.. and Streets of Rage 4 that I bought yesterday and actually pushed me into getting this working because it refused to launch.
First up, thank you for doing this. I appreciate the work you've done and it was ultimately useful.
That said, I ran into a few problems, so I'm trying to describe them and their solutions below.
(Sorry if this comes across as a diatribe, I am hoping this level of detail will be helpful to others.)
I think this is actually a bug in mintty, but I worked around it by putting quotes around the adb shell command here fixed it:
However, it turns out there's already a PR that fixes it: https://github.com/NicolasWebDev/reinstall-magisk-on-lineageos/pull/30 - it looks like it adds a new dependency on
jq
, but apparently that was already installed on my macbook.On a related note, it might be smart to add a dependency check for things like
adb
,jq
, andpython
(foreshadowing...)Removing
sudo
from this line fixed that:https://github.com/NicolasWebDev/reinstall-magisk-on-lineageos/blob/a6f91a9c06dc5ab0ee31374a1e90e86e4e14d19a/reinstall-magisk-on-lineageos#L67
(Or so I thought. We'll revisit this error again in a minute. Regardless, the
sudo
seemed unnecessary in my case.)Edit: on second thought, maybe it just worked because the first run with
sudo
installed it. That deserves a bit more investigation.This is from this line - apparently it doesn't work quite the same on macOS:
https://github.com/NicolasWebDev/reinstall-magisk-on-lineageos/blob/a6f91a9c06dc5ab0ee31374a1e90e86e4e14d19a/reinstall-magisk-on-lineageos#L75
I replaced it with
date +%s
because it's not like I'm going to be running this script more than once a second, and who cares about the length of a random temp folder's name?This one already has a fix also: https://github.com/NicolasWebDev/reinstall-magisk-on-lineageos/pull/27
(It turns out that macOS Ventura doesn't even have a built-in
python
command, justpython3
!)I went with option 2:
and... it worked!
My phone is once again rooted so that I can pass the CTS Profile Check, so I can run "secure" apps like my banking app.. and netflix.. and Streets of Rage 4 that I bought yesterday and actually pushed me into getting this working because it refused to launch.