我想在我的spec文件中使用下面的代码,我正在将我的应用程序安装为独立的tomcat实例。rpm -U删除符号链接,除非我使用--force
# 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
,则符号链接保持不变。
如何获得-U
而不必使用--force
?
我添加了'bash'标签,因此它将语法突出显示代码片段 – 2011-04-20 23:48:00