QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 692|回复: 0

一个做RPM安装包的SPEC脚本,比较实用。

[复制链接]
发表于 2006-6-29 13:14:30 | 显示全部楼层 |阅读模式
redhat平台打RPM包的脚本SPEC文件。
---------------------------------------------------------

Summary: CorporationName appname
Name: appname
Version: 1.0.0
Release: 06242006
License: Commercial
Group: Applications/Communications
Vendor: CorporationName Coporation
Packager: authorName
URL: http://www.CorporationName.com/
Source: appname-1.0.0.tar.gz
buildroot: /usr/src/redhat/BUILD/appname-1.0.0


%description
The software is ...

%changelog
* Mon May 8 2005 Orignally created the spec file
- Mon May 8 2005 appname version 1.0.0

%prep
%setup -c
echo "Preparing install appname.."

%build

%post
CorporationName_DIR=/usr/local/CorporationName
appname_INSTALL_DIR=$CorporationName_DIR/mainapp

if [ ! -d $CorporationName_DIR ]; then
mkdir $CorporationName_DIR
fi

if [ ! -d $appname_INSTALL_DIR ]; then
mkdir $appname_INSTALL_DIR
fi

if [ -d $appname_INSTALL_DIR ]; then
if [ -f $appname_INSTALL_DIR/mainapp.conf ]; then
mv $appname_INSTALL_DIR/mainapp.conf $appname_INSTALL_DIR/mainapp.conf.rpmsave
fi
if [ -f $appname_INSTALL_DIR/mainappdaemon.conf ]; then
mv $appname_INSTALL_DIR/mainappdaemon.conf $appname_INSTALL_DIR/mainappdaemon.conf.rpmsave
fi
fi

install -c -m 111 -o $USER mainapp mainappdaemon $appname_INSTALL_DIR
install -c -m 666 -o $USER mainapp.conf mainappdaemon.conf $appname_INSTALL_DIR
install -c -m 111 -o $USER mainappdaemon-script /etc/rc.d/init.d/mainappdaemon

chkconfig --add mainappdaemon
chkconfig --level 2345 mainappdaemon on

ln -sf /etc/rc.d/init.d/mainappdaemon /sbin/mainapp

#echo "S0:2345:respawn:/sbin/agetty -L 38400 ttyS0" >> /etc/inittab
#echo "ttyS0" >> /etc/securetty

if [ -f /mainapp ]; then
rm -rf /mainapp
fi

if [ -f /mainapp.conf ]; then
rm -rf /mainapp.conf
fi

if [ -f /mainappdaemon ]; then
rm -rf /mainappdaemon
fi

if [ -f /mainappdaemon.conf ]; then
rm -rf /mainappdaemon.conf
fi

if [ -f /mainappdaemon-script ]; then
rm -rf /mainappdaemon-script
fi

%postun
chkconfig --level 2345 mainappdaemon off
chkconfig --del mainappdaemon

if [ -e /sbin/mainapp ]; then
rm -rf /sbin/mainapp
fi

#if [ `ps aux | grep 'mainappdaemon' | grep -v 'grep' | wc -l` -gt 0 ] then
# killall mainapp
#fi

#if [ `ps aux | grep 'mainapp' | grep -v 'grep' | wc -l` -gt 0 ] then
# killall mainapp
#fi

CorporationName_DIR=/usr/local/CorporationName
appname_INSTALL_DIR=$CorporationName_DIR/mainapp

# move mainapp files from linux system.
if [ -f $appname_INSTALL_DIR/mainapp ]; then
rm -rf $appname_INSTALL_DIR/mainapp
fi

if [ -f $appname_INSTALL_DIR/mainappdaemon ]; then
rm -rf $appname_INSTALL_DIR/mainappdaemon
fi

if [ -f /etc/rc.d/init.d/mainappdaemon ]; then
rm -rf /etc/rc.d/init.d/mainappdaemon
fi

%files
/mainapp
/mainapp.conf
/mainappdaemon
/mainappdaemon.conf
/mainappdaemon-script

----------------------------------------------
把该文件保存为spec,如app-20060624.spec,
然后执行rpmbuild -bb app-20060624.spec
在之前还需要把安装包所要安装的文件打成一个TAR包,并放到SOURCES目录下。如果研究过怎么打RPM包的话,应该知道SOURCES目录。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-25 15:29 , Processed in 0.039904 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表