dre*_*wmm 2 debian package cydia jailbreak ios
我正在为越狱的 iOS 编写调整,这些调整打包在.deb文件中。该调整将其数据保存在/var/mobile/Library/Application Support/TweakName/file.save. 我想rm在用户卸载调整时保存该文件,这样我就不会留下文件。但我的理解是postrm脚本在包更新和删除时运行,我想保留版本之间保存的状态,因为我不希望任何更新更改保存格式(我可以如果确实出现,请处理)。
那么,有没有办法区分卸载和更新,并且仅在卸载的情况下运行命令?
您说得对,更新应用程序确实会运行“删除”脚本(以及下一个版本的安装脚本)。
但是,包系统也会将命令行参数传递给脚本,您可以使用这些参数来确定您所处的场景:升级或卸载。
如果您只想对传递给脚本的参数进行逆向工程,请将其放在脚本中(例如postrm):
echo "postrm called with args= " $1 $2
Run Code Online (Sandbox Code Playgroud)
当我安装更新并删除软件包时,我会看到:
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
Run Code Online (Sandbox Code Playgroud)
因此,如果您只想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
Run Code Online (Sandbox Code Playgroud)
注意:您没有说明这些是由 Cydia 安装的,还是dpkg直接在命令行安装的。我现在无法使用 Cydia 进行测试,但总体概念应该是相同的。您可能已经注意到,通过 Cydia 安装软件包时,它会显示安装程序脚本运行时的标准输出。
| 归档时间: |
|
| 查看次数: |
1099 次 |
| 最近记录: |