安装 rpmbuild
1
# yum install -y rpm-build
查看 rpmbuild 相关的宏和参数
1 2 3 4 5 6 7 8
# rpmbuild --showrc | grep --color "_topdir" -14: _builddir %{_topdir}/BUILD -14: _buildrootdir %{_topdir}/BUILDROOT -14: _rpmdir %{_topdir}/RPMS -14: _sourcedir %{_topdir}/SOURCES -14: _specdir %{_topdir}/SPECS -14: _srcrpmdir %{_topdir}/SRPMS -14: _topdir %{getenv:HOME}/rpmbuild
1 2
# rpmbuild --showrc | grep --color "buildroot" -14: buildroot %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}
1 2
# rpm --eval "%_topdir" /home/guoqiang.ding/rpmbuild
编写 rpmbuild 需要的 spec 文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
Name: fdsRsync Version: 1.0.0 Release: 0 Summary: call fds on the method of rsync. Group: #### License: Commercial URL: #### Source0: %{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) <b 大专栏 rpmbuild 实践 r/>#BuildRequires: #Requires: Packager: guoqiang.ding Vendor: ### %define _prefix /usr/local/%{name} %description this is a rpm for fdsRsync. #=> preprocess. %prep %setup -q %build mkdir -p $RPM_BUILD_ROOT/%{_prefix} cp -rf $RPM_BUILD_DIR/%{name}*/* $RPM_BUILD_ROOT/%{_prefix}/ #=> cp the files compiled to somewhere. %install echo "RPM_BUILD_DIR=>" $RPM_BUILD_DIR echo "RPM_BUILD_ROOT=>" $RPM_BUILD_ROOT ls -R $RPM_BUILD_ROOT #=> rm the virtual dirs. %clean rm -rf $RPM_BUILD_DIR rm -rf $RPM_BUILD_ROOT #=> file in the rpm must list here. %files %defattr(-,root,root,-) %dir /%{_prefix}/ %dir /%{_prefix}/conf/ %dir /%{_prefix}/log/ %dir /%{_prefix}/src/ /%{_prefix}/boot.sh /%{_prefix}/kill.sh /%{_prefix}/conf/*.conf /%{_prefix}/log/*.log /%{_prefix}/src/*.py %doc /%{_prefix}/README %changelog * Mon Jan 26 2015 guoqiang.ding <guoqiang.ding@xxx.com> - 1st release for fdsRsync RPM.
执行 rpmbuild
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/sh version=1.0.0 rpm_sourcedir='/root/rpmbuild/SOURCES' project_name='fdsRsync' work_dir='/home/guoqiang.ding/'$project_name temp_dir=$work_dir-$version cp -rf $work_dir $temp_dir cd $work_dir/../ zip_file=$project_name-$version'.tar.gz' tar czvf $zip_file ./$project_name-$version rm -rf $temp_dir mv $zip_file $rpm_sourcedir cd $work_dir rpmbuild -bb ./$project_name.spec rpm_dir='/root/rpmbuild/RPMS/x86_64' cp $rpm_dir/$project_name-$version*.rpm ./ rpm -qpl ./$project_name-$version*.rpm
检查打包好的 rpm
如果只想知道包里的文件列表执行:
如果想要导出包里的内容,而不是安装,那么执行:
1
# rpm2cpio pkgname | cpio -ivd
喜欢
(0 )
打赏
支付宝扫一扫
微信扫一扫
Warning : include(/www/wwwroot/fengjinwei.com/wp-content/themes/fj/relatepost.php): failed to open stream: No such file or directory in
/www/wwwroot/fengjinwei.com/wp-content/themes/fj/single.php on line
97
Warning : include(): Failed opening '/www/wwwroot/fengjinwei.com/wp-content/themes/fj/relatepost.php' for inclusion (include_path='.:') in
/www/wwwroot/fengjinwei.com/wp-content/themes/fj/single.php on line
97
最新评论