你说得对,更新应用程序确实会运行“删除”脚本(以及下一版本的安装脚本)。
但是,软件包管理系统也将pass command line parameters to the scripts,您可以用这些来确定你是哪一种情景:升级,或卸载。
如果你只是想进行反向工程什么参数传递到脚本,把这个脚本(如postrm
):
echo "postrm called with args= " $1 $2
当我安装的更新,以及删除软件包,我那么看到这一点:
iPhone5:~ root# dpkg -i /Applications/HelloJB.deb
(Reading database ... 3530 files and directories currently installed.)
Preparing to replace com.mycompany.hellojb 1.0-73 (using /Applications/HelloJB.deb) ...
prerm called with args= upgrade 1.0-73
Unpacking replacement com.mycompany.hellojb ...
Setting up com.mycompany.hellojb (1.0-74) ...
postinst called with args= configure 1.0-73
iPhone5:~ root# dpkg -r com.mycompany.hellojb
(Reading database ... 3530 files and directories currently installed.)
Removing com.mycompany.hellojb ...
prerm called with args= remove
postrm called with args= remove
所以,如果你只是想rm
文件的卸载过程中,把这个在postrm
脚本:
#!/bin/bash
echo "postrm" $1
if [ $1 = "remove" ]; then
echo "deleting user data on uninstall"
/bin/rm /var/mobile/Library/Application Support/TweakName/file.save
fi
exit 0
注意:你不说这些是否正在被苹果蠹安装,或通过直接dpkg
在命令行。我现在不能用Cydia进行测试,但总的概念应该是一样的。正如您可能已经注意到的那样,当通过Cydia安装软件包时,它会在安装程序脚本运行时向您显示标准输出。
与往常一样非常有帮助。 Cydia安装是我的主要用例,所以我会明天测试它并确保它能正常工作。谢谢! – drewmm 2013-04-27 06:11:32
是的,这与Cydia完美合作。谢谢! – drewmm 2013-04-29 05:32:20