Skip to content

Commit

Permalink
Make the script a module for PyPi (#58)
Browse files Browse the repository at this point in the history
* get ready for pypi publishing

* add build and produce artifact action

* move utils out of utils folder

* makefile and bin/permasigner for args support

* import version instead of executing it

* change that here too

* check if its the package first

* use status output instead of checking the output

* download ldid and dpkg-deb to permasigner's data directory when in package

* use data dir all the time, not just on package

* fix ldid check

* make everything work, including data files!

* modifications, custom logger with colors

* more visual changes and code formatting changes

* add fancy depictions

* add disclaimer to run on linux

* add bzip2 dependency to linux docs

* rename copy module
  • Loading branch information
itsnebulalol authored Aug 1, 2022
1 parent 9598fbf commit 5116b71
Show file tree
Hide file tree
Showing 35 changed files with 963 additions and 754 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build package and produce artifact

on:
push:
paths-ignore:
- 'README.md'
- 'docs/'
branches:
- "main"
pull_request:
paths-ignore:
- 'README.md'
- 'docs/'
branches:
- "main"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build module
run: |
python setup.py sdist bdist_wheel
- uses: actions/upload-artifact@v3
with:
name: Permasigner
path: dist/*
34 changes: 22 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Package
name: Publish package

on:
release:
Expand Down Expand Up @@ -32,16 +32,26 @@ jobs:
push: true
tags: itsnebulalol/permasigner:latest

#pypi:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2

# - name: Build and publish to PyPi
# uses: JRubics/poetry-publish@v1.12
# with:
# pypi_token: ${{ secrets.PYPI_TOKEN }}
# ignore_dev_requirements: "yes"
pypi:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
push:
paths-ignore:
- 'README.md'
- 'docs/'
- 'docs/*'
branches:
- "main"
pull_request:
paths-ignore:
- 'README.md'
- 'docs/'
- 'docs/*'
branches:
- "main"

Expand Down
2 changes: 1 addition & 1 deletion .pep8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pycodestyle]
max_line_length = 130
ignore = ["E701", "E70", "E722", "E402", "E302", "E266", "E265", "E26"]
ignore = ["E701", "E70", "E722", "E402", "E301", "E302", "E266", "E265", "E26", "E501"]
in-place = true
recursive = true
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"makefile.extensionOutputFolder": "./.vscode"
}
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include permasigner/data/*
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: build

build:
rm -rf dist/* build/* || true
python3 setup.py sdist bdist_wheel
39 changes: 39 additions & 0 deletions bin/permasigner
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3

import argparse
import os

from permasigner import __main__

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--codesign', action='store_true',
help="uses codesign instead of ldid")
parser.add_argument('-d', '--debug', action='store_true',
help="shows some debug info, only useful for testing")
parser.add_argument('-u', '--url', type=str,
help="the direct URL of the IPA to be signed")
parser.add_argument('-p', '--path', type=str,
help="the direct local path of the IPA to be signed")
parser.add_argument('-i', '--install', action='store_true',
help="installs the application to your device")
parser.add_argument('-n', '--noinstall',
action='store_true', help="skips the install prompt")
parser.add_argument('-o', '--output', type=str,
help="specify output file")
parser.add_argument('-b', '--bundleid', type=str,
help="specify new bundle id")
parser.add_argument('-N', '--name', type=str,
help="specify new app name")
parser.add_argument('-m', '--minver', type=str,
help="specify new minimum app version (14.0 recommended)")
parser.add_argument('-v', '--version', action='store_true',
help='show current version',)
args = parser.parse_args()

if args.version:
from permasigner import __version__
print(f"Permasigner v{__version__.__version__}")
exit(0)

__main__.main(args, in_package=True)
28 changes: 0 additions & 28 deletions data/entitlements.plist

This file was deleted.

16 changes: 7 additions & 9 deletions docs/usage/run-in-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@
description: Run Permasigner in the official Docker container.
---

# Run in Docker

**TLDR:** The Docker command is `docker run -it --rm -v "$PWD/output":/usr/src/permasigner/output -v "$PWD/ipas":/usr/src/permasigner/ipas -e DEBUG=1 docker.io/itsnebulalol/permasigner` while in the cloned permasigner directory. Make sure you pull first to get the latest updates.

1. [Install Docker](https://docs.docker.com/get-docker/)
2. Open a terminal
* [Install Docker](https://docs.docker.com/get-docker/)
* Open a terminal
* \[Windows] Hold Win + R and type `cmd`.
* \[macOS] Terminal from the Utilities folder or spotlight.
* \[Linux] Ctrl + Shift + T on most distros.
3. Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* \[Windows] If this fails, install git from [here](https://git-scm.com/download/win).
* \[macOS] If this fails, install git with Xcode dev tools.
* \[Linux] If this fails, install git with your package manager of choice; ex. `sudo apt install git`.
4. Pull the container with `docker pull docker.io/itsnebulalol/permasigner`
5. Launch the Docker container with `docker run -it --rm -v "$PWD/output":/usr/src/permasigner/output -v "$PWD/ipas":/usr/src/permasigner/ipas docker.io/itsnebulalol/permasigner`
* Pull the container with `docker pull docker.io/itsnebulalol/permasigner`
* Launch the Docker container with `docker run -it --rm -v "$PWD/output":/usr/src/permasigner/output -v "$PWD/ipas":/usr/src/permasigner/ipas docker.io/itsnebulalol/permasigner`
* You **must** be in the permasigner directory (`cd permasigner`) if not already.
6. Send the deb file to your iDevice
* Send the deb file to your iDevice
* Airdropping the file is probably the easiest, but you can use something like Dropbox or Mega. Advanced users can use openssh-sftp-server from Procursus.
7. Reboot to stock, the app will still work!
* Reboot to stock, the app will still work!
29 changes: 15 additions & 14 deletions docs/usage/run-on-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@
description: Run Permasigner on a jailbroken iDevice using the Procursus bootstrap.
---

# Run on iOS

**Note:** A jailbreak using Procursus is required (eg. Taurine, odysseyra1n).

## Shortcut

1. Import the shortcut from [here](https://routinehub.co/shortcut/12520/)
* Import the shortcut from [here](https://routinehub.co/shortcut/12520/)
* Make sure to pay attention to the import questions.
2. Run the shortcut
* Run the shortcut
* It may seem like it's frozen in some parts, but it isn't.
3. Choose one of the options and follow the prompts
4. The app will install if you choose!
* Choose one of the options and follow the prompts
* The app will install if you choose!
* If you choose not to, it's in /var/mobile/.permasigner/src/output.

## Manual

1. Install NewTerm 2 from [Chariz](https://repo.chariz.com) using your favorite package manager
2. Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* Install NewTerm 2 from [Chariz](https://repo.chariz.com) using your favorite package manager
* Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* If this fails, install git with `sudo apt install git`.
3. Install all requirements with `python3 -m pip install -r ios_requirements.txt`
* Install all requirements with `python3 -m pip install -r ios_requirements.txt`
* If this fails, install python3 with `sudo apt install python3`.
4. \[OPTIONAL] If you have extra entitlements, add them in `data/entitlements.plist`
* If not sure, keep it how it is.
5. Run the script with `python3 main.py`

{% hint style="info" %}
If you have extra entitlements, add them in `data/entitlements.xml`. If you don't know what this means, you can keep it as is.
{% endhint %}

* Run the script with `python3 main.py`
* If you get an error that curl isn't found, install it with `sudo apt install curl`.
6. Install the newly created deb file
* Install the newly created deb file
* You can use something like Filza to find it, it's in /var/mobile/permasigner/output.
7. Reboot to stock, the app will still work!
* Reboot to stock, the app will still work!
29 changes: 20 additions & 9 deletions docs/usage/run-on-linux.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
---
description: Run Permasigner on Linux.
description: Run Permasigner on Debian based Linux distros.
---

# Run on Linux
## Run from Package

1. Open a terminal using Ctrl + Shift + T on most Linux distros
2. Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* Open a terminal using Ctrl + Shift + T on most Linux distros
* Install [bzip2](https://command-not-found.com/bunzip2) using your package manager of choice; ex. `sudo apt install bzip2`
* Install the package with `pip install permasigner` or `pip3 install permasigner`
* If this fails, install python3 with your package manager of choice; ex. `sudo apt install python3`.
* Run the script with `python -m permasigner` or `python3 -m permasigner`
* Install the newly created deb file on your iDevice
* You can use something like Dropbox or Mega; advanced users can use `openssh-sftp-server` from Procursus.
* Reboot to stock, the app will still work!

## Run from Source

* Open a terminal using Ctrl + Shift + T on most Linux distros
* Install [bzip2](https://command-not-found.com/bunzip2) using your package manager of choice; ex. `sudo apt install bzip2`
* Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* If this fails, install git with your package manager of choice; ex. `sudo apt install git`.
3. Install all requirements with `pip install -r requirements.txt` or `pip3 install -r requirements.txt`
* Install all requirements with `pip install -r requirements.txt` or `pip3 install -r requirements.txt`
* If this fails, install python3 with your package manager of choice; ex. `sudo apt install python3`.

{% hint style="info" %}
If you have extra entitlements, add them in `data/entitlements.xml`. If you don't know what this means, you can keep it as is.
{% endhint %}

4. Run the script with `python main.py` or `python3 main.py`
* If you get an error that curl isn't found, install it with your package manager of choice; ex. `sudo apt install curl`.
5. Install the newly created deb file on your iDevice
* Run the script with `python main.py` or `python3 main.py`
* Install the newly created deb file on your iDevice
* You can use something like Dropbox or Mega; advanced users can use `openssh-sftp-server` from Procursus.
6. Reboot to stock, the app will still work!
* Reboot to stock, the app will still work!
35 changes: 25 additions & 10 deletions docs/usage/run-on-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@
description: Run Permasigner on macOS.
---

# Run on macOS
## Run from Package

1. Open Terminal from the Utilities folder or spotlight.
* Open Terminal from the Utilities folder or spotlight.
* If you use a third-party terminal, it'll most likely work too.
2. Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* Install dpkg using [brew](https://brew.sh) with `brew install dpkg`
* Install all requirements with `pip install permasigner` or `pip3 install permasigner`
* If this fails, install python3 using brew with `brew install python3`.
* Run the script with `python -m permasigner` or `python3 -m permasigner`
* Install the newly created deb file on your iDevice
* Airdropping the file is probably the easiest.
* Reboot to stock, the app will still work!

## Run from Source

* Open Terminal from the Utilities folder or spotlight.
* If you use a third-party terminal, it'll most likely work too.
* Clone this repository with `git clone https://github.com/itsnebulalol/permasigner && cd permasigner`
* If this fails, install git with Xcode dev tools on macOS.
3. Install dpkg using [brew](https://brew.sh) with `brew install dpkg`
4. Install all requirements with `pip install -r requirements.txt` or `pip3 install -r requirements.txt`
* Install dpkg using [brew](https://brew.sh) with `brew install dpkg`
* Install all requirements with `pip install -r requirements.txt` or `pip3 install -r requirements.txt`
* If this fails, install python3 using brew with `brew install python3`.
5. \[OPTIONAL] If you have extra entitlements, add them in `data/entitlements.xml`
* If not sure, keep it how it is.
6. Run the script with `python main.py` or `python3 main.py`
7. Install the newly created deb file on your iDevice

{% hint style="info" %}
If you have extra entitlements, add them in `data/entitlements.xml`. If you don't know what this means, you can keep it as is.
{% endhint %}

* Run the script with `python main.py` or `python3 main.py`
* Install the newly created deb file on your iDevice
* Airdropping the file is probably the easiest.
8. Reboot to stock, the app will still work!
* Reboot to stock, the app will still work!
2 changes: 0 additions & 2 deletions docs/usage/run-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
description: Run Permasigner on Windows using WSL or Docker.
---

# Run on Windows

## Docker (recommended)

Read the [Run in Docker](run-in-docker.md) guide.
Expand Down
Loading

0 comments on commit 5116b71

Please sign in to comment.