Skip to content

Commit

Permalink
feat: add support for rootless/rootful packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
SoCuul committed May 12, 2024
1 parent 77daf6b commit 15b6ae0
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 26 deletions.
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ SCInsta_PRIVATE_FRAMEWORKS = Preferences
SCInsta_EXTRA_FRAMEWORKS = Cephei CepheiPrefs CepheiUI
SCInsta_CFLAGS = -fobjc-arc -Wno-unsupported-availability-guard -Wno-unused-value -Wno-deprecated-declarations -Wno-nullability-completeness -Wno-unused-function -Wno-incompatible-pointer-types

CCFLAGS += -std=c++11

include $(THEOS_MAKE_PATH)/tweak.mk

ifndef DEV
SCInsta_SUBPROJECTS += modules/libflex
# Dev mode (skip building FLEX)
ifdef DEV
SCInsta_SUBPROJECTS += modules/sideloadfix
else

ifdef SIDELOAD
SCInsta_SUBPROJECTS += modules/sideloadfix modules/libflex
else
SCInsta_SUBPROJECTS += modules/libflex
endif

endif
2 changes: 1 addition & 1 deletion build-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo 'Note: This script is meant to be used while developing the tweak.'
echo ' This does not build "libbhFLEX", it must be done manually and moved to ./packages'
echo

./build.sh --dev
./build.sh sideload --dev

# Install to device
cp -fr ./packages/SCInsta-sideloaded.ipa ~/Documents/Signing/SCInsta/ipas/UNSIGNED.ipa
Expand Down
87 changes: 64 additions & 23 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,77 @@ set -e

CMAKE_OSX_ARCHITECTURES="arm64e;arm64"

ipaFile="$(find ./packages/*com.burbn.instagram*.ipa -type f -exec basename {} \;)"

if [ -z "${ipaFile}" ]; then
echo -e '\033[1m\033[0;31m./packages/com.burbn.instagram.ipa not found.\nPlease put a decrypted Instagram IPA in its path.\033[0m'
exit 1
elif [ -z "$(ls -A modules/libflex/FLEX)" ]; then
# Prerequisites
if [ -z "$(ls -A modules/libflex/FLEX)" ]; then
echo -e '\033[1m\033[0;31mFLEX submodule not found.\nPlease run the following command to checkout submodules:\n\n\033[0m git submodule update --init --recursive'
exit 1
fi

echo -e '\033[1m\033[32mBuilding SCInsta tweak for sideloading (as IPA)\033[0m'
# Building modes
if [ "$1" == "sideload" ];
then

# Clean build artifacts
make clean
rm -rf .theos

# Check for decrypted instagram ipa
ipaFile="$(find ./packages/*com.burbn.instagram*.ipa -type f -exec basename {} \;)"
if [ -z "${ipaFile}" ]; then
echo -e '\033[1m\033[0;31m./packages/com.burbn.instagram.ipa not found.\nPlease put a decrypted Instagram IPA in its path.\033[0m'
exit 1
fi

echo -e '\033[1m\033[32mBuilding SCInsta tweak for sideloading (as IPA)\033[0m'

# Check if building with dev mode
if [ "$2" == "--dev" ];
then
FLEXPATH='packages/libbhFLEX.dylib'

make "DEV=1"
else
FLEXPATH='.theos/obj/debug/libbhFLEX.dylib'

make
fi

# Clean build artifacts
make clean
rm -rf .theos
# Create IPA File
echo -e '\033[1m\033[32mCreating the IPA file...\033[0m'
rm -f packages/SCInsta-sideloaded.ipa
pyzule -i "packages/${ipaFile}" -o packages/SCInsta-sideloaded.ipa -f .theos/obj/debug/SCInsta.dylib .theos/obj/debug/sideloadfix.dylib $FLEXPATH -c 0 -m 15.0 -du

echo -e "\033[1m\033[32mDone, we hope you enjoy SCInsta!\033[0m\n\nYou can find the ipa file at: $(pwd)/packages"

# Check if building with dev mode
if [ "$1" == "--dev" ];
elif [ "$1" == "rootless" ];
then
FLEXPATH='packages/libbhFLEX.dylib'

# Clean build artifacts
make clean
rm -rf .theos

make "DEV=1"
else
FLEXPATH='.theos/obj/debug/libbhFLEX.dylib'
echo -e '\033[1m\033[32mBuilding SCInsta tweak for rootless\033[0m'

make
fi
export THEOS_PACKAGE_SCHEME=rootless
make package

elif [ "$1" == "rootful" ];
then

# Clean build artifacts
make clean
rm -rf .theos

# IPA File
echo -e '\033[1m\033[32mBuilding the IPA.\033[0m'
rm -f packages/SCInsta-sideloaded.ipa
pyzule -i "packages/${ipaFile}" -o packages/SCInsta-sideloaded.ipa -f .theos/obj/debug/SCInsta.dylib $FLEXPATH -c 0 -m 15.0 -du
echo -e "\033[1m\033[32mDone, we hope you enjoy SCInsta!\033[0m\n\nYou can find the ipa file at: $(pwd)/packages"
echo -e '\033[1m\033[32mBuilding SCInsta tweak for rootful\033[0m'

unset THEOS_PACKAGE_SCHEME
make package

else
echo '+--------------------+'
echo '|SCInsta Build Script|'
echo '+--------------------+'
echo
echo 'Usage: ./build.sh <sideload/rootless/rootful>'
exit 1
fi
13 changes: 13 additions & 0 deletions modules/sideloadfix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
TARGET := iphone:clang:14.5
INSTALL_TARGET_PROCESSES = Instagram
ARCHS = arm64

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = sideloadfix

sideloadfix_FILES = SideloadFix.x
sideloadfix_FRAMEWORKS = Foundation
sideloadfix_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk
File renamed without changes.

0 comments on commit 15b6ae0

Please sign in to comment.