Debian包:rm文件卸载但不升级



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

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

你是对的,更新应用程序确实会运行"remove"脚本(也会运行下一个版本的安装脚本)。

但是,包系统也会将命令行参数传递给脚本,您可以使用这些参数来确定您所处的场景:升级卸载

如果您只想逆向工程传递给脚本的参数,请将其放在脚本中(例如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

注意: 你没有说这些是由Cydia安装的,还是由dpkg直接在命令行安装的。我目前无法在Cydia上进行测试,但总体概念应该是一样的。您可能已经注意到,当通过Cydia安装软件包时,它会在安装程序脚本运行时向您显示标准输出。

最新更新