Skip to content

Commit

Permalink
Make installable package
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav1 committed Oct 18, 2023
1 parent 4a070f6 commit 8ffa1f1
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
/.venv
/dist

24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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="[email protected]" },
]
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"

3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

Empty file added src/unisoc_unlock/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions src/unisoc_unlock/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .cli import main

main()
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions unisoc-unlock.py → src/unisoc_unlock/cli.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
Expand Down
File renamed without changes.

0 comments on commit 8ffa1f1

Please sign in to comment.