2013-04-26 161 views
2

我正在为越狱iOS编写调整,这些文件打包在.deb文件中。调整将其数据保存在/var/mobile/Library/Application Support/TweakName/file.save。我想rm保存文件,当用户卸载调整,以便我不留下文件躺在。但我的理解是postrm脚本在包更新以及删除时运行,并且我想保留版本之间的保存状态,因为我不希望任何更新更改保存格式(并且我可以处理,如果它出现)。Debian软件包:在卸载但不升级的rm文件

那么,有没有什么办法来区分从更新卸载,并只在卸载的情况下运行命令?

回答

3

你说得对,更新应用程序确实会运行“删除”脚本(以及下一版本的安装脚本)。

但是,软件包管理系统也将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安装软件包时,它会在安装程序脚本运行时向您显示标准输出。

+0

与往常一样非常有帮助。 Cydia安装是我的主要用例,所以我会明天测试它并确保它能正常工作。谢谢! – drewmm 2013-04-27 06:11:32

+0

是的,这与Cydia完美合作。谢谢! – drewmm 2013-04-29 05:32:20