Skip to content

Commit

Permalink
Dragon rootless sup
Browse files Browse the repository at this point in the history
  • Loading branch information
L1ghtmann committed Jan 11, 2024
1 parent c64eb48 commit cd63136
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/dragon
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ while ! [[ -z $1 ]]; do
r | release ) release=1
;;
ro | rootless ) rootless=1
PkgPrefix="/var/jb"
;;
relink ) rm -r "$DRAGON_DATA_DIR/sign/"
;;
Expand Down
5 changes: 5 additions & 0 deletions src/dragon/config/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Types:
install_location: '/Library/MobileSubstrate/DynamicLibraries/'
build_target_file: '$dragon_data_dir/$stagedir/$location$name.dylib'
lopts: '-dynamiclib -ggdb -framework CydiaSubstrate'
ldflags: '-install_name @rpath/$name.dylib'
frameworks:
- UIKit
stage2:
Expand All @@ -31,6 +32,7 @@ Types:
libs:
- 'substrate'
lopts: '-dynamiclib -ggdb -framework Preferences'
ldflags: '-install_name $install_location/$name'
frameworks:
- UIKit
stage2:
Expand All @@ -42,6 +44,7 @@ Types:
install_location: '/Library/$name/'
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.bundle/$name'
lopts: '-dynamiclib -ggdb'
ldflags: '-install_name $install_location/$name.bundle/$name'
frameworks:
- UIKit
stage2:
Expand All @@ -53,6 +56,7 @@ Types:
build_target_file: '$dragon_data_dir/$stagedir/$location/$name'
public_headers: '$dragon_root_dir/include/'
lopts: '-dynamiclib -ggdb'
ldflags: '-install_name @rpath/$name.framework/$name'
frameworks:
- Foundation
stage2:
Expand All @@ -79,6 +83,7 @@ Types:
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.dylib'
ldflags: '-install_name $location$name.dylib'
lopts: '-dynamiclib -ggdb'
ldflags: '-install_name @rpath/$name.dylib'
stage2:
- 'true;'
cli:
Expand Down
7 changes: 7 additions & 0 deletions src/dragon/shscripts/packaging
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ create_package()
else
python3 -m dragongen.control DragonMake ./$DRAGON_DIR/_/DEBIAN/control
fi
if [[ $rootless == 1 ]]; then
tmp=$(mktemp -d)
find $DRAGON_DIR/_/ -mindepth 1 -maxdepth 1 ! -name 'DEBIAN' -exec mv {} $tmp \;
mkdir -p $DRAGON_DIR/_/$PkgPrefix
mv $tmp/* $DRAGON_DIR/_/$PkgPrefix
rm -r $tmp
fi
du -d 0 $DRAGON_DIR/_ | xargs -I '{}' echo 'Installed-Size: {}' | cut -d ' ' -f 1,2 >> $DRAGON_DIR/_/DEBIAN/control
chmod -R 0755 $DRAGON_DIR/_/DEBIAN/*
mkdir -p $DRAGON_DIR/packages
Expand Down
1 change: 1 addition & 0 deletions src/dragon/shscripts/variables
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export simtarg=0

export release=0
export rootless=0
export PkgPrefix=""

export ToolchainPath=""
export ToolchainPrefix=""
Expand Down
5 changes: 4 additions & 1 deletion src/dragongen/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
'Section': 'Tweaks',
'Description': 'A cool MobileSubstrate Tweak',
'Version': '0.0.1',
'Architecture': 'iphoneos-arm' if 'ROOTLESS' not in os.environ else 'iphoneos-arm64',
'Architecture': 'iphoneos-arm',
'Depends': 'mobilesubstrate' # This is a blind guess, maybe we can improve this logic?
}

Expand Down Expand Up @@ -78,6 +78,9 @@ def main():
control['Maintainer'] = control['Author']
dbwarn("Packager", f'No "Maintainer:" key in DragonMake, creating default based on `Author:` key')

if int(os.environ["rootless"]) == 1:
control['Architecture'] = 'iphoneos-arm64'

# print(defs.update(control))
# print(control)
# print(dict(defs, **control))
Expand Down
7 changes: 7 additions & 0 deletions src/dragongen/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ def generate_vars(self, module_variables: dict, target: str) -> dict:
# type they used.
raise ex

# Load rootless config
if int(os.environ['rootless']) == 1:
project_dict.update(get_default_section_dict('Rootless'))

# Apply the set of variables the user included on this module
project_dict.update(module_variables)
# Apply the module name
Expand Down Expand Up @@ -447,6 +451,9 @@ def generate_ninja_outline(self) -> list:
Var('internalreleaseflags') if _RELEASE_BUILD else Var('internaldbgflags'),
Var('releaseflags') if _RELEASE_BUILD else Var('dbgflags'),
___,
Var('rootless_prefix'),
Var('rpathflags'),
___,
Var('theosshim'),
Var('internalcflags'),
Var('internalldflags'),
Expand Down

0 comments on commit cd63136

Please sign in to comment.