引言
在ASO项目中常常基于Rrocketbootstrap封装Message工具类进行进程间的消息通信,为了避免每次部署都从bigBoss 源更新。本文就来讲讲如何去掉对rocketbootstrap的Depends依赖,达到deb自带rocketbootstrapd的目的。
本文侧重于操作,更多原理请看这篇 :iOS逆向小知识:将功能独立的tweak 合并到同一个deb 包
I、去掉对rocketbootstrap的依赖
deb包的执行脚本
debian/preinst 安装前执行脚本 debian/postinst 安装后执行脚本 debian/prerm 卸载前执行脚本 debian/postrm 卸载后执行脚本
1.1 分析rocketbootstrap的postinst、prerm
#!/bin/sh if [ "$1" = "upgrade" ] || [ "$1" = "install" ];then # 需要执行的脚本 fi
- 安装rocketbootstrapd后执行脚本
#!/bin/sh launchctl load /Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist || true launchctl stop com.apple.ReportCrash.SimulateCrash || true mv /System/Library/LaunchDaemons{BAK,}/com.apple.ReportCrash.SimulateCrash.plist 2> /dev/null || true launchctl load /System/Library/LaunchDaemons/com.apple.ReportCrash.SimulateCrash.plist 2> /dev/null || true
- 卸载rocketbootstrapd的时候执行的脚本:停止 RocketBootstrap
launchctl unload /Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist || true launchctl stop com.apple.ReportCrash.SimulateCrash || true
1.2 方案
- 将以下内容mv copy 一份到自己的deb 包对应的位置
RocketBootstrap/layout/DEBIAN/prerm RocketBootstrap/layout/Library/LaunchDaemons/ /Library/LaunchDaemons/ /layout/DEBIAN/prerm
- 整体操作的文件清单
knPackage/Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist knPackage/Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.dylib knPackage/Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.plist knPackage/usr/bin/reloadRocket knPackage/usr/include/ knPackage/usr/lib/ knPackage/usr/libexec/
从CSDN资源下载完整的demo
下载地址:https://download.csdn.net/download/u011018979/15744262private 仓库https://github.com/iosdeb/setupdeb
Layout/DEBIAN/postinst
#!/bin/sh # 0、 修改 rocketbootstrapd 守护进程的ProgramArguments参数 <string>/usr/libexec/rocketd</string> chmod +s /usr/libexec/_rocketd_reenable 2>/dev/null chown root:wheel /usr/libexec/_rocketd_reenable 2>/dev/null # 1、rocketbootstrapd 相关的安装之后处理 # 加载rocketbootstrapd chown root:wheel /Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist 2>/dev/null launchctl load /Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist || true # 2、关闭RocketBootstrap的目标进程ReportCrash ,因为tweak 是在进行开启的过程进行inject的 launchctl stop com.apple.ReportCrash.SimulateCrash || true killall -9 ReportCrash 2>/dev/null || true # 3、load ReportCrash mv /System/Library/LaunchDaemons{BAK,}/com.apple.ReportCrash.SimulateCrash.plist 2>/dev/null || true launchctl load /System/Library/LaunchDaemons/com.apple.ReportCrash.SimulateCrash.plist || true
Layout/DEBIAN/prerm
#!/bin/sh launchctl unload /Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist || true launchctl stop com.apple.ReportCrash.SimulateCrash || true
/Layout/DEBIAN/control
Package: https://kunnan.blog.csdn.net/ Depends: mobilesubstrate (>= 0.9.5000), firmware (>= 3.0) Name: RocketBootstrap Version: 1.0.2 Architecture: iphoneos-arm Description: mach lookup support library for iOS 7 Depiction: kunnan.blog.csdn.net Homepage: kunnan.blog.csdn.net Maintainer: kunnan.blog.csdn.net Author: kunnan.blog.csdn.net Sponsor: kunnan.blog.csdn.net Section: Tweaks dev: kunnan.blog.csdn.net Tag: purpose::extension, role::developer
II、常见问题和分析deb方法
2.1 dpkg -r com.rpetrich.rocketbootstrap 失败
iPhone:/var/mobile/Media root# dpkg -r com.rpetrich.rocketbootstrap dpkg: dependency problems prevent removal of com.rpetrich.rocketbootstrap: applist depends on com.rpetrich.rocketbootstrap (>= 1.0.3) ø firmware (<< 7.0); however: Package com.rpetrich.rocketbootstrap is to be removed. Version of firmware on system is 10.1.1. dpkg: error processing package com.rpetrich.rocketbootstrap (--remove): dependency problems - not removing Errors were encountered while processing: com.rpetrich.rocketbootstrap
原因:rocketbootstrap还被依赖中,例如applist 解决方案:卸载app list 即可 推荐使用 dpkg -P进行卸载deb软件
因为dpkg --remove只是删除安装的文件,但不删除配置文件。而dpkg --purge则安装文件和配置文件都删除。
2.2分析rocketbootstrap 安装过程
一个简单的方式研究你刚刚安装一个tweak或者deb 包之后,系统最近访问的文件,以rocketbootstrap 为例子。
wl24:~ root# find / -amin -1 /Library/LaunchDaemons/com.rpetrich.rocketbootstrapd.plist /dev/oslog_stream /dev/ptmx /dev/bpf0 /dev/urandom /dev/cu.debug /dev/ttys000 //usr/include/rocketbootstrap.h /usr/include/rocketbootstrap_dynamic.h /usr/lib/librocketbootstrap.dylib /usr/libexec/_rocketd_reenable /usr/libexec/rocketd
从上面列表中刷选出我们要的文件
/private/var/lib/dpkg/info/com.rpetrich.rocketbootstrap.list /private/var/lib/dpkg/info/com.rpetrich.rocketbootstrap.md5sums /private/var/lib/dpkg/info/com.rpetrich.rocketbootstrap.postinst /private/var/lib/dpkg/info/com.rpetrich.rocketbootstrap.prerm
- 上面文件的改变也可以从RocketBootstrap/Makefile 找到对应的内容
LIBRARY_NAME = librocketbootstrap librocketbootstrap_FILES = Tweak.x Shims.x librocketbootstrap_LIBRARIES = substrate librocketbootstrap_FRAMEWORKS = Foundation TOOL_NAME = rocketd rocketd_FILES = rocketd.c rocketd_FRAMEWORKS = CoreFoundation rocketd_INSTALL_PATH = /usr/libexec rocketd_IPHONE_ARCHS = armv6 arm64 ADDITIONAL_CFLAGS = -std=c99 IPHONE_ARCHS = armv6 armv7 armv7s arm64 SDKVERSION_armv6 = 5.1 INCLUDE_SDKVERSION_armv6 = 7.0 TARGET_IPHONEOS_DEPLOYMENT_VERSION = 4.0 TARGET_IPHONEOS_DEPLOYMENT_VERSION_armv6 = 3.0 THEOS_PLATFORM_SDK_ROOT_armv6 = /Applications/Xcode_Legacy.app/Contents/Developer include framework/makefiles/common.mk include framework/makefiles/library.mk include framework/makefiles/tool.mk stage:: mkdir -p "$(THEOS_STAGING_DIR)/usr/include" cp -a rocketbootstrap.h rocketbootstrap_dynamic.h "$(THEOS_STAGING_DIR)/usr/include" plutil -convert binary1 "$(THEOS_STAGING_DIR)/Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.plist"
- 分析Makefile
stage:: mkdir -p "$(THEOS_STAGING_DIR)/usr/include" <!-- Same as -pPR options. Preserves structure and attributes of files but not directory structure --> cp -a rocketbootstrap.h rocketbootstrap_dynamic.h "$(THEOS_STAGING_DIR)/usr/include" plutil -convert binary1 "$(THEOS_STAGING_DIR)/Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.plist" <!-- 因此 你看到安装之后的RocketBootstrap.plist 是编码后的二进制格式 --> 此时你要Xcode打开它的话,会自动解析 <!--利用plutil 进行 XML 格式化 --> 把二进制文件转换为XML格式:plutil -c xml1 com.apple.SpringBoard.plist <!-- 把XML格式的文件转换为二进制 --> plutil -c binary1 com.apple.SpringBoard.plist