1

我正在尝试在我的规范文件中使用以下代码,我正在将我的应用程序安装为独立的 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它会创建符号链接并将其保留在那里。

当我运行新版本的 rpm 时,-U它会执行此代码并正确创建符号链接,但是当 rpm 命令退出时,符号链接会被删除。

如果我-U --force第二次运行,则符号链接将保留。

我怎样才能-U在不使用的情况下留下来--force

4

2 回答 2

0

这已通过在 RPM 更新文件列表中添加一个名为 logs 的文件来解决,并且它停止自动删除符号链接,因为它现在认为它一直都在那里。

于 2011-05-14T17:53:39.080 回答
0

你想做什么?您是保留还是删除符号链接?

如果要删除它,请尝试以下操作:

rm -f -i $RPM_INSTALL_PREFIX/logs # File
rmdir -f $RPM_INSTALL_PREFIX/logs >/dev/null 2>&1 || : # Directory
于 2011-05-14T17:09:00.007 回答