我的 deb 文件删除/opt [英] My deb file removes /opt

查看:29
本文介绍了我的 deb 文件删除/opt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 deb 文件安装到/opt/myCompany/myProgram,当我使用 dpkg -P myProgram 清除包时,所有内容都被删除了 - 甚至/opt(如果我的包是/opt 中唯一包含文件的包) - 我该如何避免在清除期间删除/opt 文件夹?

My deb file installs to /opt/myCompany/myProgram, when I purge the package with dpkg -P myProgram everything is removed - even /opt (if mine is the only package with files in /opt) - How can I avoid removing the /opt folder during a purge?

我尝试检查 postrm 中是否存在/opt 并添加它,如果不存在但不高兴...似乎在 postrm 脚本运行后删除了该文件夹.目前我正在使用 postinst 在/opt 中添加一个隐藏文件 - 这会阻止 opt 被删除但感觉很糟糕 - 应该有更好的方法.

I have tried checking if /opt exist in the postrm and adding it if it doesn't but no joy...It seems that the folder is deleted after the postrm script is run. Currently I am adding a hidden file in /opt with postinst - this stops opt from being removed but feels hackey - there should be a better way.

谢谢你,

推荐答案

这只是debian.每当它从非 debian 标准目录(例如 /opt 在您的情况下)中删除软件包并且该目录中没有文件时, dpkg 将尝试删除那个目录.

That's just debian. Whenever it removes a package from a non-debian standard directory (such as /opt in your case) and there are no files left in that directory, dpkg will try to remove that directory.

如果在删除时 /opt 中还有其他文件,您会在/opt is not empty; not removed"行中收到一条消息,仅此而已.

If there are some other files in /opt at the time of removal, you'll get a message in the lines of "/opt is not empty; not removed" and that's it.

另一种hacky"方法是在 postrm 中重新创建/opt,但它并不比隐藏文件更干净 :)

Another "hacky" way would be to add re-creation of /opt in postrm, but it's not way cleaner than your hidden file :)

这篇关于我的 deb 文件删除/opt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆