你說得對,更新應用程序確實會運行「刪除」腳本(以及下一版本的安裝腳本)。
但是,軟件包管理系統也將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