Skip to content

Commit

Permalink
Fixes and general cleanup across the project (DragonBuild#111)
Browse files Browse the repository at this point in the history
* Fix a couple typos and adjust some bash syntax

* Update .gitignore

* Add underscores to DRAGON variables for legibility, rename DRAGONDIR to DRAGON_ROOT_DIR, define new DRAGON_DATA_DIR var, and fix relink cmd

* Fix 'install' and adjust corresponding error messages

* Use DRAGON_DATA_DIR, recreate DRAGON_DIR, and use DRAGON_DIR for special .dragon's

* Fix debugging via dragon

* Update kritanta -> cynder

* Keep naming consistent

* Cleanup imports, add shebangs, and remove an oudated rule

* Some yaml stuff

* Bring building script up-to-speed

* Readd projroot to building script + more gen cleanup

* Use new vars in the wizard + other gen cleanup

* Fix a few options and use new vars in packaging script

* Fix dragon export cmd + make common print functions and use them throughout proj

* Fix dragon norm

* Fix dragon remote

* exit -> drexit

* Avoid discarding potentially helpful errors

* Cleanup some mkdirs and cleanup + adjust the install location for pkgs

* Make tmp pkg path more unique + adjust dragon respring cmd

* Add dependency check and resolution to prerun_checks script

* Shell variables my guy...

* Fix a script source order conflict

* A couple deps were missing from the check

* And a couple more things ...

* Fix DragonMake control regression introduced in 7ef7aa (whoops)

* Fix a couple test repo links

* -z over == blank_string

* Fix typo in prerun homebrew response check

* -z over == blank_string (2)

* A few things I missed before

* And a final few hardcoded .dragon's to replace with vars

* Replace missed echo with respective color print func

* Fix dev install script for macOS and remove unnecessary macOS dep from prerun check

* Fix a typo in python shebangs (whoops)

* Fix tc check in prerun

* Cleanup test workflow

* Rename some test workflow steps

* Cleanup checks in prerun

* Fix faulty Linux bin path check + codesign path

* Fix optool path

* Cleanup a few misc things

* Standardize use of os.environ[]

* Fix weird python string syntax issue

* Fix submodule clone err and unknown name err in the wizard

* Make unknown Linux distros and unknown platforms non-fatal to the prerun check

* Fix err from non-existent dir rmtree

* Update pkg manager before installing deps (if req) and properly check need for iOS ninja

* We don't want output from iOS ninja check

* Fix framework compilation

* Pretty sure this would've failed ... yml doesn't like double-bracket syntax

* A few minor consistency things

* Some last min cleanup and quotes for good measure

* Bump ver

* Update README + docs links

* Update tests.yml

* Update tests.yml (2)
  • Loading branch information
L1ghtmann authored Jan 3, 2023
1 parent 5b933fe commit a0aa6fd
Show file tree
Hide file tree
Showing 41 changed files with 556 additions and 384 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,30 @@ jobs:
- https://github.com/kritanta-ios-tweaks/Signe
- https://github.com/kritanta-ios-tweaks/StatusViz
- https://github.com/kritanta-ios-tweaks/DeadRinger

runs-on: macos-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9.5
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml
pip install "git+https://github.com/dragonbuild/dragon"
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install DragonBuild
- name: Install dragon
run: |
dragon
- name: Cloning Project
- name: Clone project
run: |
git init .
git remote add origin ${{ matrix.project-link }}
git pull origin $(git remote show origin | grep "HEAD branch" | sed 's/.*: //')
- name: Building Project
- name: Build project
run: |
dragon b
dragon c b
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ state/phoneip
state/remoteip
testing/*
dist/
build/
dragon.egg-info/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copyright (c) 2020 kritanta
copyright (c) 2020-2022 cynder

dragon license version 1

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://dragon.krit.me/en/latest/_static/logo-dark.png" width=400px>
<img src="https://dragon.krit.me/en/latest/_static/logo-light.png" alt="Logo" width=400px>
<source media="(prefers-color-scheme: dark)" srcset="docs/source/_static/logo-dark.png" width=400px>
<img src="docs/source/_static/logo-light.png" alt="Logo" width=400px>
</picture>
</p>
<p align="center">
Expand All @@ -13,18 +13,18 @@
<a href="https://github.com/dragonbuild/dragon/actions/workflows/tests.yml">
<image src="https://github.com/dragonbuild/dragon/actions/workflows/tests.yml/badge.svg">
</a>
<a href="https://dragon.krit.me">
<a href="https://dragon.cynder.me">
<image src="https://readthedocs.org/projects/dragon/badge/?version=latest">
</a>
<a href="https://pypi.org/project/dragon/">
<image src="https://badge.fury.io/py/dragon.svg">
</a>
<br>
<br>
<a href="https://dragon.krit.me">
<a href="https://dragon.cynder.me">
<strong>Documentation</strong>
</a> |
<a href="https://dragon.krit.me/en/latest/quickstart.html">
<a href="https://dragon.cynder.me/en/latest/quickstart.html">
<strong>Getting Started</strong>
</a> |
<a href="https://github.com/dragonbuild/example ">
Expand Down
110 changes: 59 additions & 51 deletions bin/dragon
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
#!/usr/bin/env bash
export DRAGONVERS=$(python3 -c 'from dragon.util import version; print(version())')

# Defauld dragondir is ~/.dragon
if [ -z $DRAGONDIR ]; then export DRAGONDIR=$HOME/.dragon; fi
export DRAGON_DIR=.dragon
export DRAGON_VERS=$(python3 -c 'from dragon.util import version; print(version())')

# Run setup wizard if dragondir is empty or nonexistant
if [ -z "$(ls -A $DRAGONDIR 2> /dev/null)" ]; then
python3 -m dragon.wizard
exit 0
# Default dragon root dir is ~/.dragon
if [[ -z $DRAGON_ROOT_DIR ]]; then
export DRAGON_ROOT_DIR=$HOME/$DRAGON_DIR
fi

# Run setup wizard if dragon root dir is empty or nonexistent
if [[ -z "$(ls -A $DRAGON_ROOT_DIR)" ]]; then
python3 -m dragon.wizard
drexit 0
fi

TOOLPATH=$(python3 -c 'from dragon.util import tool_path; print(tool_path())')

source $TOOLPATH/prerun_checks

# Load in colors and basic functions
source $TOOLPATH/util
source $TOOLPATH/dragoncolors

# Check deps are good to go
source $TOOLPATH/prerun_checks

# Tool imports
source $TOOLPATH/simulator
source $TOOLPATH/packaging
source $TOOLPATH/building
source $TOOLPATH/generator
source $TOOLPATH/remote

# All "state" variables we set and then act upon.
source $TOOLPATH/variables
Expand All @@ -34,24 +39,28 @@ yaml() {

set -o pipefail

# Define the local dragon data dir
if [[ $PWD != $HOME ]]; then
export DRAGON_DATA_DIR="$PWD/$DRAGON_DIR"
fi

# --------
# Argument Parsing
# Set a variable here or call a bash function if it's atool
# Set a variable here or call a bash function if it's a tool
# --------

# If we have no args, print usage and exit
if [ "$1" == "" ]; then
if [[ -z $1 ]]; then
usage
drexit
fi

while [ "$1" != "" ]; do
while ! [[ -z $1 ]]; do
case $1 in

# --------
# Set Variables
# --------

do ) gen=1
build=1
install=1
Expand Down Expand Up @@ -101,11 +110,10 @@ while [ "$1" != "" ]; do
# --------
# Commands
# --------

u | update | upgrade ) source $TOOLPATH/upgrader
drexit
;;
rs | respring ) python3 -m dragon.device run killall -9 SpringBoard
rs | respring ) python3 -m dragon.device run sbreload
drexit
;;
dr | devicerun ) shift
Expand All @@ -116,20 +124,22 @@ while [ "$1" != "" ]; do
;;
sr | rconf ) setupRemote
;;
sn | send ) snd $2
sn | send ) send_package $2
drexit
;;
ch | checkra1n ) /Applications/checkra1n.app/Contents/MacOS/checkra1n -g
ch | checkra1n ) C1=$(which checkra1n) || prefix_print "Checkra1n is not currently installed. Exiting."; drexit 1
$C1 -g
drexit
;;
chc | checkra1ncli ) /Applications/checkra1n.app/Contents/MacOS/checkra1n -c
chc | checkra1ncli ) C1=$(which checkra1n) || prefix_print "Checkra1n is not currently installed. Exiting."; drexit 1
$C1 -c
drexit
;;
r | remote ) shift
bash $DRAGONDIR/internal/tools/remote $*
remote $*
drexit
;;
relink ) rm .dragon/sign
relink ) rm -r "$DRAGON_DATA_DIR/sign/"
;;
h | help | -h ) usage
drexit
Expand All @@ -140,7 +150,7 @@ while [ "$1" != "" ]; do
time ) N=`date +%s%N`; export PS4='+[$(((`date +%s%N`-$N)/1000000))ms][${BASH_SOURCE}:${LINENO}]: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }';
set -x
;;
v | -v ) cat $DRAGONDIR/internal/banner.txt
v | -v ) cat $DRAGON_ROOT_DIR/internal/banner.txt
;;
* ) usage
drexit 1
Expand All @@ -149,67 +159,65 @@ while [ "$1" != "" ]; do
shift
done

cwd=$(basename $PWD)


# --------
# Build, then package (if needed)
# --------

if [ $build == 1 ]; then
if [[ $build -eq 1 ]]; then
# shellcheck disable=SC2154

# Invoke the generator
if [ $gen == 1 ]; then
rm -rf .dragon/ninja/build.ninja 2>/dev/null
mkdir -p .dragon/ninja 2>/dev/null
mkdir -p .dragon/modules 2>/dev/null
if [[ $gen -eq 1 ]]; then
rm -rf "$DRAGON_DATA_DIR/ninja/build.ninja" 2>/dev/null
mkdir -p "$DRAGON_DATA_DIR/"{ninja,modules}

generate

if [ "$DRAGONGEN_FAILURE" == 1 ]; then
if [[ $DRAGONGEN_FAILURE -eq 1 ]]; then
cleanbuildfail
fi
fi

projroot=$PWD

set -f
# If there's more than one project in the root directory we need to iterate by name.
# shellcheck disable=SC2207
subsb=($(python3 -c "print('${project_dirs}' if ('${project_dirs}'.count('.')<2) else '${project_names}')"))
set +f

mkdir -p .dragon
cp DragonMake .dragon/DragonMake 2> /dev/null
mkdir -p "$DRAGON_DATA_DIR"
cp DragonMake "$DRAGON_DATA_DIR/DragonMake" 2> /dev/null

for i in ${subsb[@]}; do
for i in "${subsb[@]}"; do
# Copy the DragonMake into the subproject's build directory
# Primarily for bundle filter gen, right now.
[[ -d $i ]] && mkdir -p $i/.dragon/ && cp DragonMake $i/.dragon/DragonMake 2> /dev/null

if [[ -d $i ]]; then
mkdir -p "$i/$DRAGON_DIR/"
cp DragonMake "$i/$DRAGON_DIR/DragonMake" 2> /dev/null
fi
build $i
done

find . -name '.clean' -type f -delete

if [ $DRAGON_DPKG == 1 ]; then
if [[ $DRAGON_DPKG -eq 1 ]]; then
create_package
fi

echo -e "${PrefixColor}[Dragon]${BoldColor} Cleaning Up"
prefix_print "Cleaning Up"

if [[ $norm -eq 0 ]]; then
find . -name '*.ninja' -type f -delete
fi
fi


# --------
# Install a package after building (doesn't need to be same session)
# DRAGON_DPKG is 1 by default, modified by the generator
# --------
if [ $install == 1 ] && [ $DRAGON_DPKG == 1 ]; then
OUTPUT="$(cat .dragon/last_package | tr -d '\040\011\012\015' )"
if [[ $install -eq 1 && $DRAGON_DPKG -eq 1 ]]; then
OUTPUT="$(cat "$DRAGON_DATA_DIR/last_package" | tr -d '\040\011\012\015' )"

if [ -z "$OUTPUT" ]; then
echo -e "${PrefixColor}[Dragon]${BoldColor} Packaging Failed${NC}"
if [[ -z $OUTPUT ]]; then
prefix_print "Packaging Failed"
drexit
fi

Expand All @@ -223,14 +231,14 @@ fi
# --------
# On-device debugging
# --------
if [ $debug == 1 ] ; then
eval $(python3 $DRAGONDIR/internal/tools/device.py get)
echo -e "${PrefixColor}[Dragon]${BoldColor} Starting on device debugger and targeting '$debugproc' ${NC}"
ssh -p $DRBPORT root@$DRBIP "command -v lldb || apt-get install lldb" || drexit
ssh -p $DRBPORT root@$DRBIP "lldb -n $debugproc" || ssh -p $DRBPORT root@$DRBIP "killall lldb"
if [[ $debug -eq 1 ]]; then
eval $(python3 -m dragon.device get)
prefix_print "Starting on device debugger and targeting '$debugproc'"
ssh -p $DRBPORT root@$DRBIP "command -v lldb || apt install lldb" || drexit
ssh -p $DRBPORT root@$DRBIP "lldb -n $debugproc || killall lldb" || drexit
fi

rm -rf .dragon/packages > /dev/null
rm -rf "$DRAGON_DATA_DIR/packages" > /dev/null
set +xv

python3 -m dragon.update_check
4 changes: 3 additions & 1 deletion development_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

python3 -m pip uninstall --yes dragon
python3 -m pip install .
DRAGONVERS=$(python3 -c 'from dragon.util import version; print(version())') python3 -m dragon.wizard
DRAGON_DIR=.dragon && DRAGON_ROOT_DIR=$HOME/$DRAGON_DIR \
DRAGON_VERS=$(python3 -c 'from dragon.util import version; print(version())') \
python3 -m dragon.wizard
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# -- Project information -----------------------------------------------------

project = 'dragon'
copyright = '2021, _kritanta'
author = '_kritanta'
copyright = '2022, cynder'
author = 'cynder'

# The full version, including alpha/beta/rc tags
release = '1.6.4'
Expand Down
4 changes: 2 additions & 2 deletions docs/source/theos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ It also includes several support files used with theos projects.

Compiling a theos project should be as simple as::

dragon b
dragon b

If you encounter any issues with it, feel free to file an issue on https://github.com/dragonbuild/dragon .
If you encounter any issues with it, feel free to file an issue on https://github.com/DragonBuild/dragon .

4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python3

from setuptools import setup

setup(name='dragon',
version='1.6.8',
version='1.6.9',
description='A powerful toolkit targeting Apple development, research, and packaging.',
author='cynder',
url='https://dragon.cynder.me/',
Expand Down
4 changes: 2 additions & 2 deletions src/buildgen/makefile_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
import textwrap
#!/usr/bin/env python3

import re, textwrap
from .writer import Writer


Expand Down
3 changes: 1 addition & 2 deletions src/buildgen/ninja_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
use Python.
"""

import re
import textwrap
import re, textwrap
from .writer import Writer


Expand Down
2 changes: 2 additions & 0 deletions src/buildgen/writer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

class Writer(object):
def __init__(self, output, width=78):
pass
Expand Down
4 changes: 2 additions & 2 deletions src/dragon/config/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
████ ▄██▀▀▀▀.└███████▀½─ ▐███▌ ▐██ ▐██ ▐██ ▄▄▄▐██ ██ ██▌ ▐██ ▐██ ██ ▐██
████ ▀█¬ ▐███████ ▐███▌ ▐██ ▐██ ▐██ ██▀ ▐██ ██▄ ██▌ ▐██ ▐██ ██ ██
▀███, ;.┌████████─▌ ████ ▀████▀██ ▐██ ▀████▀██ ▀███▀██▌ ▀█████▀ ██ ██
████ ▄▀╓██████████ ╫▌▄███▌ ▄▄▄.▄██
└████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.6.8
████ ▄▀╓██████████ ╫▌▄███▌ ▄▄▄.▄██
└████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.6.9
█████████┌▄███████████═ ▄████▀ ~ cynder
╙████████████████████▓████▀
└▀████████████████████▀ this project was made possible by Lorenzo Pane.
Expand Down
Loading

0 comments on commit a0aa6fd

Please sign in to comment.