http://www.bkjia.com/Linuxjc/994106.html 针对该文档,需要修改 下载源码到 BUILD目录,最后 %files 去掉,这是我实践的一个结果
vim nginx.spec
1 Name: nginx
2 Summary: high performance web server
3 Version: 1.2.1
4 Release: 1.e15.ngx
5 License: 2-clause BSD-like license
6 Group: Applications/Server
7 Source: http:/nginx.org/download/nginx-1.2.1.tar.gz
8 URL: http://nginx.org/
9 Distribution: Linux
10 Packager: huanghaibin <haibin.huang@intel.com>
11
12 %description
13 nginx is a HTTP and reverse proxy server, as well as a mail proxy server.
14
15 %prep
16 rm -rf $RPM_BUILD_DIR/nginx-1.2.1
17 zcat $RPM_BUILD_DIR/nginx-1.2.1.tar.gz | tar -xvf -
18
19 %build
20
21 cd nginx-1.2.1
22 ./configure --prefix=/usr/local/nginx
23
24 make
25
26 %install
27 cd nginx-1.2.1
28 make install
29
30 %preun
31 if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
32 killall nginx >/dev/null
33 exit 0
34 fi
35
搜索了一下网络,发现解法大体有两种:
相互依赖的软件包,使用rpm的–nodeps参数就搞定了.
rpm –nodeps -e gdm-2.24.1-4.fc10.i386
也就是说不检查依赖。这样的话,那些使用该软件包的软件在此之后可能就不能正常工作了。
执行
`rpm -e 要删除的rpm包名称`
然后根据输出再在命令行后面跟上依赖包名称
`rpm -e 要删除的rpm包名称 依赖的rpm包名称`
这种方法是我以前也经常使用的,比如用于删除RHEL/CentOS中原装的jdk
下面演示这一步骤,比较烦,因为要删除的依赖包实在太多,要复制粘贴n次
[root@localhost ~]# java -version
java version "1.6.0_22" OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-1.24.1.10.4.el5-i386) OpenJDK Server VM (build 20.0-b11, mixed mode)
[root@localhost ~]# rpm -qa | grep jdk
java-1.6.0-openjdk-1.6.0.0-1.24.1.10.4.el5 java-1.6.0-openjdk-devel-1.6.0.0-1.24.1.10.4.el5
[root@localhost ~]# rpm -e java-1.6.0- openjdk-1.6.0.0-1.24.1.10.4.el5 java-1.6.0-openjdk-devel-1.6.0.0-1.24.1.10.4.el5
error: Failed dependencies: jre >= 1.5.0 is needed by (installed) openoffice.org-ure-3.1.1-19.5.el5_5.6.i386
[root@localhost ~]# rpm -e java-1.6.0-openjdk-1.6.0.0-1.24.1.10.4.el5 java-1.6.0-openjdk-devel-1.6.0.0-1.24.1.10.4.el5 openoffice.org-ure-3.1.1-19.5.el5_5.6.i386 error: Failed dependencies: libjvmaccessgcc3.so.3 is needed by (installed) openoffice.org-core-3.1.1-19.5.el5_5.6.i386 libjvmaccessgcc3.so.3(UDK_3.1) is needed by (installed) openoffice.org-core-3.1.1-19.5.el5_5.6.i386
太多输出,省略
by (installed) openoffice.org-calc-3.1.1-19.5.el5_5.6.i386 openoffice.org-ure = 1:3.1.1-19.5.el5_5.6 is needed by (installed) openoffice.org-graphicfilter-3.1.1-19.5.el5_5.6.i386 openoffice.org-ure = 1:3.1.1-19.5.el5_5.6 is needed by (installed) openoffice.org-draw-3.1.1-19.5.el5_5.6.i386
[root@localhost ~]# 有太多软件包需要删除,此处不再继续
[root@localhost ~]#
编写一个 force_remove_package.sh 的Bash脚本,内容如下:
#!/bin/sh
do_once()
{
rpm -e "$@" 2>&1 | grep '(installed)'
}
for ((I=1; I<=4; ++I))
do
DEPS="$DEPS $(do_once "$@" $DEPS | awk '{print $8}')"
echo $I $DEPS
done
其中,
http://www.cnblogs.com/sunyubo/archive/2010/08/27/2282129.html