以下是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规范的最新版本如下
%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文件。
答案 0 :(得分:0)
似乎您对rpm打包的工作方式有错误的认识。以下是将创建package-1.0.0-0.spec
和package-2.0.0-0.rpm
文件的示例工作流程:
创建要打包的两个文件(这些命令发生在spec文件之外,就像您编写代码时一样):
echo "i am in and this line is written from rpm 1" > item1.txt
echo "i am in and this line is written from rpm 1" > item2.txt
现在在这些部分旁边创建一个规范文件:
Version: 1.0.0
Release: 0
%install
install -d -m 0755 "${RPM_BUILD_ROOT}/usr/bin/"
cp item1.txt ${RPM_BUILD_ROOT}/usr/bin/
cp item2.txt ${RPM_BUILD_ROOT}/usr/bin/
%files
/usr/bin/item1.txt
/usr/bin/item2.txt
这将创建包含item1.txt和item2.txt的package-1.0.0-0.rpm
现在假设我们要创建下一个版本;然后:
echo "xyz1" >> item1.txt
echo "xyz3" >> item3.txt
规格文件现在应包含:
Version: 2.0.0
Release: 0
%install
install -d -m 0755 "${RPM_BUILD_ROOT}/usr/bin/"
cp item1.txt ${RPM_BUILD_ROOT}/usr/bin/
cp item3.txt ${RPM_BUILD_ROOT}/usr/bin/
%files
/usr/bin/item1.txt
/usr/bin/item3.txt
这将创建package-2.0.0-0.rpm
。升级后,rpm
现在将删除/usr/bin/item2.txt并安装新版本的item1.txt和item3.txt