diff --git a/.gitignore b/.gitignore index 8a7b46b..6588c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ /.venv +/dist diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f35bd32 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,24 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "unisoc_unlock" +version = "0.0.1" +authors = [ + { name="Patrick Huesmann", email="info@patrick-huesmann.de" }, +] +description = "Tool for unlocking a Unisoc/Spreadtrum Android bootloader" +readme = "README.md" +requires-python = ">=3.6" +dependencies = [ + "libusb1", + "pycryptodome" +] + +[project.urls] +"Homepage" = "https://github.com/pypa/sampleproject" + +[project.scripts] +unisoc_unlock = "unisoc_unlock.cli:main" + diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a0eec86..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -libusb1 -pycryptodome - diff --git a/src/unisoc_unlock/__init__.py b/src/unisoc_unlock/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/unisoc_unlock/__main__.py b/src/unisoc_unlock/__main__.py new file mode 100644 index 0000000..4e28416 --- /dev/null +++ b/src/unisoc_unlock/__main__.py @@ -0,0 +1,3 @@ +from .cli import main + +main() diff --git a/src/unisoc_unlock/bundled_adb/__init__.py b/src/unisoc_unlock/bundled_adb/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bundled_adb/common.py b/src/unisoc_unlock/bundled_adb/common.py similarity index 100% rename from bundled_adb/common.py rename to src/unisoc_unlock/bundled_adb/common.py diff --git a/bundled_adb/fastboot.py b/src/unisoc_unlock/bundled_adb/fastboot.py similarity index 100% rename from bundled_adb/fastboot.py rename to src/unisoc_unlock/bundled_adb/fastboot.py diff --git a/bundled_adb/usb_exceptions.py b/src/unisoc_unlock/bundled_adb/usb_exceptions.py similarity index 100% rename from bundled_adb/usb_exceptions.py rename to src/unisoc_unlock/bundled_adb/usb_exceptions.py diff --git a/unisoc-unlock.py b/src/unisoc_unlock/cli.py similarity index 89% rename from unisoc-unlock.py rename to src/unisoc_unlock/cli.py index ed91907..da6265e 100755 --- a/unisoc-unlock.py +++ b/src/unisoc_unlock/cli.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 +import os import sys -from bundled_adb import fastboot, usb_exceptions +from .bundled_adb import fastboot, usb_exceptions from Crypto.Signature import PKCS1_v1_5 from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA @@ -52,7 +53,11 @@ def main(): print(f'OEM ID: {oem_id.id}') id = oem_id.id.ljust(2*64, '0') id_raw = base64.b16decode(id, casefold=True) - sgn = sign_token(id_raw, 'rsa4096_vbmeta.pem') + pemfile = os.path.join( + os.path.dirname(__file__), + 'rsa4096_vbmeta.pem' + ) + sgn = sign_token(id_raw, pemfile) print('Download signature') dev.Download(io.BytesIO(sgn), source_len=len(sgn)) diff --git a/rsa4096_vbmeta.pem b/src/unisoc_unlock/rsa4096_vbmeta.pem similarity index 100% rename from rsa4096_vbmeta.pem rename to src/unisoc_unlock/rsa4096_vbmeta.pem