rpm打包spec文件
来源:互联网 发布:淘宝开店用手机可以吗 编辑:程序博客网 时间:2024/05/28 05:16
spec结构说明
spec文件包含8部分
The Preamble
包说明信息,包含功能,版本等
The Prep Section
解压并进入SOURCE目录
The Build Section
编译,例如congfigure,make
The Install Section
安装目录,make install或者cp,mv...
Install and Uninstall Scripts
安装或者卸载前后执行的动作
The Verity Script
安装时的环境检查
The Clean Section
编译时后的清除工作
The File List
需要打进包里的文件列表
RPM宏命令
%{_topdir} %{getenv:HOME}/rpmbuild%{_builddir} %{_topdir}/BUILD%{_rpmdir} %{_topdir}/RPMS%{_sourcedir} %{_topdir}/SOURCES%{_specdir} %{_topdir}/SPECS%{_srcrpmdir} %{_topdir}/SRPMS%{_buildrootdir} %{_topdir}/BUILDROOT
宏指令一般地定义在 spec 文件中.语法象 %define macro1 value, 要使用这个宏,使用%{macro1}.宏指定也可以事先在配置文件中调整.
就是下面的文件.
默认设置为 /usr/lib/rpm/macros or /etc/rpm/macros
用户设置 ~/.rpmmacros
RPM打包目录
tree /usr/src/redhat//usr/src/redhat/|-- BUILD|-- RPMS| |-- i386| |-- noarch| `-- x86_64|-- SOURCES|-- SPECS`-- SRPMS
可以自定义目录到其它地方
cd ~/rpmbuild/SPECS && rpmbuild --define "_topdir ~/rpmbuild" -v -ba abc.spec
建立自己的打包工作目录与环境
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p ~/rpmbuild/RPMS/{noarch,i386,x86_64}
echo "%_topdir %(echo \$HOME)/rpmbuild" > ~/.rpmmacros
SPEC简例
The Preamble例子:
## Example spec file for cdplayer app...#Summary: A CD player app that rocks!Name: cdplayerVersion: 1.0Release: 1Copyright: GPLGroup: Applications/SoundSource: ftp://ftp.gnomovision.com/pub/cdplayer/cdplayer-1.0.tgzURL: http://www.gnomovision.com/cdplayer/cdplayer.htmlDistribution: WSS LinuxVendor: White Socks Software, Inc.Packager: Santa Claus <sclaus@northpole.com>%descriptionIt slices! It dices! It's a CD player app thatcan't be beat. By using the resonant frequencyof the CD itself, it is able to simulate 20Xoversampling. This leads to sound quality thatcannot be equaled with more mundane software...
The %prep Section
%preprm -rf $RPM_BUILD_DIR/cdplayer-1.0zcat $RPM_SOURCE_DIR/cdplayer-1.0.tgz | tar -xvf -可以简化:
%prep%setup
The %build Section
%buildmake
The %install Section
%installmake install
The %files Section
%files%doc README/usr/local/bin/cdp/usr/local/bin/cdplay/usr/local/man/man1/cdp.1%doc表明普通文件,上面的表明README将放至/usr/doc中,也可定义放到放到其它目录
开始打包
cd /usr/src/redhat/SPECS
rpm -ba cdplayer-1.0.spec
不出错,会在SRPMS下结果
rpm -ba --test cdplayer-1.0.spec会产生build shell文件
#!/bin/sh -e# Script generated by rpmRPM_SOURCE_DIR="/usr/src/redhat/SOURCES"RPM_BUILD_DIR="/usr/src/redhat/BUILD"RPM_DOC_DIR="/usr/doc"RPM_OPT_FLAGS="-O2 -m486 -fno-strength-reduce"RPM_ARCH="i386"RPM_OS="Linux"RPM_ROOT_DIR="/tmp/cdplayer"RPM_BUILD_ROOT="/tmp/cdplayer"RPM_PACKAGE_NAME="cdplayer"RPM_PACKAGE_VERSION="1.0"RPM_PACKAGE_RELEASE="1"set -xumask 022echo Executing: %prepcd /usr/src/redhat/BUILDcd /usr/src/redhat/BUILDrm -rf cdplayer-1.0gzip -dc /usr/src/redhat/SOURCES/cdplayer-1.0.tgz | tar -xvvf -if [ $? -ne 0 ]; then exit $?ficd cdplayer-1.0cd /usr/src/redhat/BUILD/cdplayer-1.0chown -R root.root .chmod -R a+rX,g-w,o-w .
常见标签
%build 开始构建包. 常见写法:configure;make或者直接到源码目录下进行build(非tar.gz源码包方式):cd $OLDPWD/..; configure;make%install 开始把软件安装到虚拟的根目录中。常见写法:make install DESTDIR=${RPM_BUILD_ROOT}或者直接copy:mkdir -p .%{_prefix}/bin/cp $OLDPWD/../bin/* .%{_prefix}/bin/%clean 清理临时文件%pre rpm安装前执行的脚本%post rpm安装后执行的脚本%preun rpm卸载前执行的脚本%postun rpm卸载后执行的脚本%files 定义那些文件或目录会放入rpm中%defattr (-,root,root) 指定包装文件的属性,分别是(mode,owner,group),-表示默认值,对文本文件是0644,可执行文件是0755%exclude 列出不想打包到rpm中的文件 ※小心,如果%exclude指定的文件不存在,也会出错的。%changelog 变更日志
引用:
http://www.php-oa.com/2010/05/11/linux-rpm-build.html
rpm 说明:
http://www.rpm.org/max-rpm/
rpm macros
http://fedoraproject.org/wiki/Packaging:RPMMacros
http://www.php-oa.com/2010/05/11/linux-rpm-build.html
http://rdc.taobao.com/blog/cs/?p=43
- rpm打包spec文件
- RPM打包与SPEC文件
- rpm 打包原理及 .spec文件
- rpm spec 打包学习
- [转] RPM打包技术与典型SPEC文件分析
- RPM 打包技术与典型 SPEC 文件分析
- RPM 打包技术与典型 SPEC 文件分析
- RPM打包技术与典型SPEC文件分析
- RPM打包技术与典型SPEC文件分析
- RPM 打包技术与典型 SPEC 文件分析
- RPM 打包技术与典型 SPEC 文件分析
- RPM 打包技术与典型 SPEC 文件分析
- RPM打包技术与典型SPEC文件分析
- rpm spec文件编写
- SPEC脚本及RPM打包
- RPM包rpmbuild SPEC文件
- RPM原理详解-spec文件
- RPM原理详解-spec文件
- ajax如何经过后台返回json数组以及在在js中得到json对象
- Ruby中的Rake任务详述
- hdu4704 循环节+快速幂
- 内存管理
- 每天总结
- rpm打包spec文件
- Flex自定义事件
- Fibonacci 数列
- 各种排序算法
- hdu 1257 最少拦截系统
- longson平台显卡驱动
- UVA 12097 UVALive 3635 Pieni (二分)
- redis源码分析--zslRandomLevel位运算解析
- 云南全省谷歌卫星地图生成WGS84坐标系ArcGIS Server瓦片的制作步骤