【发布时间】:2019-02-06 06:32:21
【问题描述】:
以下是第一个版本的 rpm 规范
%post
if [ "$1" = "1" ];
then
touch /usr/bin/item1.txt
touch /usr/bin/item2.txt
echo "i am in and this line is written from rpm 1-1">>/usr/bin/item1.txt
echo "i am in and this line is written from rpm 1-1">>/usr/bin/item2.txt
fi
%preun
if [ "$1" = "0" ];
then
sed -i "/i am in and this line is written from rpm 1-1 /d" /usr/bin/item1.txt
sed -i "/i am in and this line is written from rpm 1-1 /d" /usr/bin/item2.txt
rm -rf /usr/bin/item1.txt
rm -rf /usr/bin/item2.txt
fi
if [ "$1" = "1" ];
then
# what should be here ?
fi
rpm spec的第二个版本如下
%post
if [ "$1" = "1" ];
then
touch /usr/bin/item1.txt
echo "xyz1" >> /usr/bin/item1.txt
touch /usr/bin/item3.txt
echo "xyz3" >> /usr/bin/item3.txt
fi
if [ "$1" = "2" ];
then
# what should be here if i want to remove item2.txt file and add item3.txt
fi
%preun
if [ "$1" = "0" ];
then
# will i have to remove all the files item1 and item 2 along with item3.txt here
fi
if [ "$1" = "1" ];
then
##
fi
我想简单地删除已在基本 rpm 的安装后脚本中安装的文件 item2,并安装 item3.txt 文件作为升级的一部分。
【问题讨论】:
-
你问题的最后一部分不是很清楚。你到底想在你的 preun 或 postun 脚本中做什么?
-
@ChrisMaes 我正在尝试编写一些自定义规范并尝试升级它们,我想知道在升级期间执行的 preun 和 postun 脚本包含什么
-
如果您希望在更新时发生特定的事情(运行一些脚本,添加用户,删除用户,......),这些部分只需要包含一些东西
-
关于部分及其执行顺序以及使用哪些参数的良好参考:fedoraproject.org/wiki/…
-
@ChrisMaes 我试图创建一个场景来描述我的怀疑希望你能理解:)
标签: rpm specifications rpmbuild rpm-spec