rpm -U 会删除符号链接,除非我使用 --force
我正在尝试在规范文件中使用以下代码,我将应用程序安装为独立的 tomcat 实例。
# Symlink $CATALINA_BASE/logs to /var/log/$SERVICE_NAME.
# If it's already there, we'll get rid of it and make a new symlink.
if [ -h "$RPM_INSTALL_PREFIX/logs" ]; then
# It's a symlink, so just remove it.
rm -f $RPM_INSTALL_PREFIX/logs
fi
# If it's still there, and it's a directory, see if we can rmdir it.
if [ -d "$RPM_INSTALL_PREFIX/logs" ]; then
rmdir $RPM_INSTALL_PREFIX/logs >/dev/null 2>&1 || :
fi
if [ -e "$RPM_INSTALL_PREFIX/logs" ]; then
# It's probably either a file or a dir, so we'll move it.
mv $RPM_INSTALL_PREFIX/logs $RPM_INSTALL_PREFIX/logs.rpmsave || :
fi
ln -s /var/log/$SERVICE_NAME $RPM_INSTALL_PREFIX/logs || :
当此代码使用 -i
运行时,它会创建符号链接并将其保留在那里。
当我使用 -U
运行新版本的 rpm 时,它会执行此代码并正确创建符号链接,但当 rpm 命令退出时,符号链接会被删除。
如果我第二次运行 -U --force
,则符号链接将保留。
如何在不使用 --force
的情况下保留 -U
?
I am trying using the following code in my spec file, I am installing my application as a standalone tomcat instance.
# Symlink $CATALINA_BASE/logs to /var/log/$SERVICE_NAME.
# If it's already there, we'll get rid of it and make a new symlink.
if [ -h "$RPM_INSTALL_PREFIX/logs" ]; then
# It's a symlink, so just remove it.
rm -f $RPM_INSTALL_PREFIX/logs
fi
# If it's still there, and it's a directory, see if we can rmdir it.
if [ -d "$RPM_INSTALL_PREFIX/logs" ]; then
rmdir $RPM_INSTALL_PREFIX/logs >/dev/null 2>&1 || :
fi
if [ -e "$RPM_INSTALL_PREFIX/logs" ]; then
# It's probably either a file or a dir, so we'll move it.
mv $RPM_INSTALL_PREFIX/logs $RPM_INSTALL_PREFIX/logs.rpmsave || :
fi
ln -s /var/log/$SERVICE_NAME $RPM_INSTALL_PREFIX/logs || :
When this code runs with -i
it creates and leaves the symlink there.
When I run a new version of the rpm with -U
it executes this code and the symlink gets created correctly but when the rpm command exits the symlink gets deleted.
If I run -U --force
a second time then the symlink stays.
How do I get the -U
to stay without having to use --force
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你想做什么?您是保留还是删除符号链接?
如果您要删除它,请尝试以下操作:
What are you trying to do? Are you keeping or removing the symlink?
If you are removing it, try this:
通过添加一个带有名称日志的文件作为 RPM 更新文件列表的一部分解决了这个问题,并且它停止自动删除符号链接,因为它现在认为它一直存在。
This was resolved by adding a file in with the name logs as part of the update file list of the RPM and it stopped deleting the symlink automatically because it now thinks it is was there all along.