在构架rpm包的时候,需要经过3个过程
2、编译环境configure
然后再使用check install做rpm包
如果在构架脚本或者其他非源码包安装的时候,可以使用rpmbild
2、构架spec
注意的完成最终的工作了。请使用根目录用户身份安装rpmbuild命令。在Red Hat中,请用yum install rpm-build完成这项工作。接下来,请确保所有的文件都呆在正确的地方。Tar存档文件必须位于创建软件包的当前用户帐户的~/rpmbuild /SOURCES 目录下,demo.spec文件必须位于~/rpmbuild/SPECS目录下。现在你可以用rpmbuild-ba test.spec命令来创建软件包了。这会在~/rpmbuild/RPMS目录下创建你的RPM文件。
http://www.iyunv.com/Linux/2012-05/60278.htm
我做的测试是创建一个test-1.0目录,里有个test.txt文件,内容是thisis test
B.创建压缩文件
12345678910111213141516:02:25 # cd ~/rpmbuild/SOURCES/root@ip-10-10-10-10:~/rpmbuild/SOURCES16:05:09 # mkdir test-1.0root@ip-10-10-10-10:~/rpmbuild/SOURCES16:05:32 # echo "this is test">test-1.0/test.txtroot@ip-10-10-10-10:~/rpmbuild/SOURCES16:05:43 # tar zcvf test-1.0.tar.gz test-1.0test-1.0/test-1.0/test.txtroot@ip-10-10-10-10:~/rpmbuild/SOURCES16:05:48 # rm -rf test-1.0root@ip-10-10-10-10:~/rpmbuild/SOURCES16:05:52 # lltotal 4-rw-r--r-- 1 root root 160 Aug 15 16:05 test-1.0.tar.gz
E.查看rpm包
1234567891011121314151617181920212223242516:07:24 # cd ~/rpmbuild/RPMS/root@ip-10-10-10-10:~/rpmbuild/RPMS16:07:54 # lltotal 4drwxr-xr-x 2 root root 4096 Aug 15 16:07 x86_64root@ip-10-10-10-10:~/rpmbuild/RPMS16:07:54 # cd x86_64/root@ip-10-10-10-10:~/rpmbuild/RPMS/x86_6416:07:58 # lltotal 4-rw-r--r-- 1 root root 2020 Aug 15 16:07 test-1.0-1.x86_64.rpmroot@ip-10-10-10-10:~/rpmbuild/RPMS/x86_6416:07:59 # rpm -qpi test-1.0-1.x86_64.rpm Name : test Relocations: /usr /etc Version : 1.0 Vendor: (none)Release : 1 Build Date: Fri 15 Aug 2014 04:07:24 PM CSTInstall Date: (not installed) Build Host: ip-10-10-10-10Group : test Source RPM: test-1.0-1.src.rpmSize : 13 License: GPLSignature : (none)Packager : dl528888URL : http://dl528888.blog.iyunv.comSummary : Test package for dl528888 blogDescription :Justa test rpm suite.可以看到安装完成,并在tmp的demo里解压了test-1.0.tar.gz压缩包。
1、centos安装
12yum install rpm-buildgem install fpm在centos里安装如下
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318415:34:53 # yum install rpm-build Failed to set locale, defaulting to CLoaded plugins: fastestmirror, keys, protectbaseLoading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net0 packages excluded due to repository protectionsSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package rpm-build.x86_64 0:4.8.0-37.el6 will be installed--> Processing Dependency: elfutils >= 0.128 for package: rpm-build-4.8.0-37.el6.x86_64--> Processing Dependency: xz for package: rpm-build-4.8.0-37.el6.x86_64--> Processing Dependency: unzip for package: rpm-build-4.8.0-37.el6.x86_64--> Processing Dependency: lzma for package: rpm-build-4.8.0-37.el6.x86_64--> Processing Dependency: file for package: rpm-build-4.8.0-37.el6.x86_64--> Processing Dependency: /usr/bin/gdb-add-index for package: rpm-build-4.8.0-37.el6.x86_64--> Running transaction check---> Package elfutils.x86_64 0:0.152-1.el6 will be installed--> Processing Dependency: elfutils-libs(x86-64) = 0.152-1.el6 for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1(ELFUTILS_0.149)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1(ELFUTILS_0.148)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1(ELFUTILS_0.138)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1(ELFUTILS_0.127)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1(ELFUTILS_0.126)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1(ELFUTILS_0.122)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libasm.so.1(ELFUTILS_1.0)(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libdw.so.1()(64bit) for package: elfutils-0.152-1.el6.x86_64--> Processing Dependency: libasm.so.1()(64bit) for package: elfutils-0.152-1.el6.x86_64---> Package file.x86_64 0:5.04-15.el6 will be installed---> Package gdb.x86_64 0:7.2-60.el6_4.1 will be installed---> Package unzip.x86_64 0:6.0-1.el6 will be installed---> Package xz.x86_64 0:4.999.9-0.3.beta.20091007git.el6 will be installed---> Package xz-lzma-compat.x86_64 0:4.999.9-0.3.beta.20091007git.el6 will be installed--> Running transaction check---> Package elfutils-libs.x86_64 0:0.152-1.el6 will be installed--> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================== Package Arch Version Repository Size===============================================================================================================================================================================================Installing: rpm-build x86_64 4.8.0-37.el6 base 127 kInstalling for dependencies: elfutils x86_64 0.152-1.el6 base 201 k elfutils-libs x86_64 0.152-1.el6 base 181 k file x86_64 5.04-15.el6 base 46 k gdb x86_64 7.2-60.el6_4.1 base 2.3 M unzip x86_64 6.0-1.el6 base 149 k xz x86_64 4.999.9-0.3.beta.20091007git.el6 base 137 k xz-lzma-compat x86_64 4.999.9-0.3.beta.20091007git.el6 base 16 k Transaction Summary===============================================================================================================================================================================================Install 8 Package(s) Total download size: 3.1 MInstalled size: 7.4 MIs this ok [y/N]: yDownloading Packages:(1/8): elfutils-0.152-1.el6.x86_64.rpm | 201 kB 00:00 (2/8): elfutils-libs-0.152-1.el6.x86_64.rpm | 181 kB 00:00 (3/8): file-5.04-15.el6.x86_64.rpm | 46 kB 00:00 (4/8): gdb-7.2-60.el6_4.1.x86_64.rpm | 2.3 MB 00:06 (5/8): rpm-build-4.8.0-37.el6.x86_64.rpm | 127 kB 00:00 (6/8): unzip-6.0-1.el6.x86_64.rpm | 149 kB 00:00 (7/8): xz-4.999.9-0.3.beta.20091007git.el6.x86_64.rpm | 137 kB 00:00 (8/8): xz-lzma-compat-4.999.9-0.3.beta.20091007git.el6.x86_64.rpm | 16 kB 00:00 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total 234 kB/s | 3.1 MB 00:13 Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : xz-4.999.9-0.3.beta.20091007git.el6.x86_64 1/8 Installing : xz-lzma-compat-4.999.9-0.3.beta.20091007git.el6.x86_64 2/8 Installing : file-5.04-15.el6.x86_64 3/8 Installing : gdb-7.2-60.el6_4.1.x86_64 4/8 Installing : elfutils-libs-0.152-1.el6.x86_64 5/8 Installing : elfutils-0.152-1.el6.x86_64 6/8 Installing : unzip-6.0-1.el6.x86_64 7/8 Installing : rpm-build-4.8.0-37.el6.x86_64 8/8 Verifying : unzip-6.0-1.el6.x86_64 1/8 Verifying : xz-lzma-compat-4.999.9-0.3.beta.20091007git.el6.x86_64 2/8 Verifying : elfutils-libs-0.152-1.el6.x86_64 3/8 Verifying : gdb-7.2-60.el6_4.1.x86_64 4/8 Verifying : elfutils-0.152-1.el6.x86_64 5/8 Verifying : rpm-build-4.8.0-37.el6.x86_64 6/8 Verifying : file-5.04-15.el6.x86_64 7/8 Verifying : xz-4.999.9-0.3.beta.20091007git.el6.x86_64 8/8 Installed: rpm-build.x86_64 0:4.8.0-37.el6 Dependency Installed: elfutils.x86_64 0:0.152-1.el6 elfutils-libs.x86_64 0:0.152-1.el6 file.x86_64 0:5.04-15.el6 gdb.x86_64 0:7.2-60.el6_4.1 unzip.x86_64 0:6.0-1.el6 xz.x86_64 0:4.999.9-0.3.beta.20091007git.el6 xz-lzma-compat.x86_64 0:4.999.9-0.3.beta.20091007git.el6 Complete! 15:35:21 # gem install fpm/usr/local/ruby-1.9.3/lib/ruby/1.9.1/yaml.rb:56:in `':It seems your ruby installation is missing psych (for YAML output).To eliminate this warning, please install libyaml and reinstall your ruby.Fetching: json-1.8.1.gem (100%)Building native extensions. This could take a while...Fetching: cabin-0.6.1.gem (100%)Fetching: backports-3.6.0.gem (100%)Fetching: arr-pm-0.0.9.gem (100%)Fetching: clamp-0.6.3.gem (100%)Fetching: ffi-1.9.3.gem (100%)Building native extensions. This could take a while...Fetching: childprocess-0.5.3.gem (100%)Fetching: fpm-1.1.0.gem (100%)Successfully installed json-1.8.1Successfully installed cabin-0.6.1Successfully installed backports-3.6.0Successfully installed arr-pm-0.0.9Successfully installed clamp-0.6.3Successfully installed ffi-1.9.3Successfully installed childprocess-0.5.3Successfully installed fpm-1.1.08 gems installedInstalling ri documentation for json-1.8.1...Installing ri documentation for cabin-0.6.1...Installing ri documentation for backports-3.6.0...unable to convert U+00E9 from UTF-8 to US-ASCII for lib/backports/force/string_length.rb, skippingunable to convert U+00E9 from UTF-8 to US-ASCII for lib/backports/1.9.2/stdlib/matrix.rb, skippingInstalling ri documentation for arr-pm-0.0.9...Installing ri documentation for clamp-0.6.3...Installing ri documentation for ffi-1.9.3...unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/ffi/library.rb, skippingEnclosing class/module 'moduleFFI' for class StructByValue not knownEnclosing class/module 'moduleFFI' for class StructLayout not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Field not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Number not knownEnclosing class/module 'rbffi_StructLayoutClass' for class String not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Pointer not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Function not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Array not knownEnclosing class/module 'moduleFFI' for module LastError not knownEnclosing class/module 'moduleFFI' for class MemoryPointer not knownEnclosing class/module 'rbffi_StructLayoutClass' for class CharArray not knownEnclosing class/module "rbffi_StructLayoutCharArrayClass" for alias to_str to_s not knownunable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for ext/ffi_c/libffi/ChangeLog, skippingunable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for ext/ffi_c/libffi/README, skippingInstalling ri documentation for childprocess-0.5.3...Installing ri documentation for fpm-1.1.0...Installing RDoc documentation for json-1.8.1...Installing RDoc documentation for cabin-0.6.1...Installing RDoc documentation for backports-3.6.0...unable to convert U+00E9 from UTF-8 to US-ASCII for lib/backports/force/string_length.rb, skippingunable to convert U+00E9 from UTF-8 to US-ASCII for lib/backports/1.9.2/stdlib/matrix.rb, skippingInstalling RDoc documentation for arr-pm-0.0.9...Installing RDoc documentation for clamp-0.6.3...Installing RDoc documentation for ffi-1.9.3...unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for lib/ffi/library.rb, skippingEnclosing class/module 'moduleFFI' for class StructByValue not knownEnclosing class/module 'moduleFFI' for class StructLayout not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Field not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Number not knownEnclosing class/module 'rbffi_StructLayoutClass' for class String not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Pointer not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Function not knownEnclosing class/module 'rbffi_StructLayoutClass' for class Array not knownEnclosing class/module 'moduleFFI' for module LastError not knownEnclosing class/module 'moduleFFI' for class MemoryPointer not knownEnclosing class/module 'rbffi_StructLayoutClass' for class CharArray not knownEnclosing class/module "rbffi_StructLayoutCharArrayClass" for alias to_str to_s not knownunable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for ext/ffi_c/libffi/ChangeLog, skippingunable to convert "\xC3" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for ext/ffi_c/libffi/README, skippingInstalling RDoc documentation for childprocess-0.5.3...Installing RDoc documentation for fpm-1.1.0...15:45:31 # find / -name "fpm"/usr/local/ruby-1.9.3/lib/ruby/gems/1.9.1/doc/fpm-1.1.0/rdoc/lib/fpm/usr/local/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/fpm-1.1.0/lib/fpm/usr/local/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/fpm-1.1.0/bin/fpm/usr/local/ruby-1.9.3/bin/fpm/usr/local/php-5.3.10/share/php/fpmroot@e3d3e87fbfd7:~15:45:46 # ln /usr/local/ruby-1.9.3/bin/fpm /usr/bin/fpm下面是在进行rpm安装的时候,安装后运行的脚本
1234root@e3d3e87fbfd7:~16:10:48# cat run_rpm.sh #!/bin/bash/bin/bash/tmp/install_for_rpm.sh下面是打包过程
12345678910111213141516171819202122232425262728293031root@e3d3e87fbfd7:~16:13:21 # fpm -s dir --prefix /tmp/ -t rpm -n test_rpm --verbose --version '2014' --iteration '1.0' --vendor '244979152@qq.com' --category 'Development/test' --description 'Rpm Install' --url 'qq.com' --license 'BSD' -m 'denglei' --after-install run_rpm.sh install_for_rpm.sh /usr/local/ruby-1.9.3/lib/ruby/1.9.1/yaml.rb:56:in `':It seems your ruby installation is missing psych (for YAML output).To eliminate this warning, please install libyaml and reinstall your ruby.Setting from flags: category=Development/test {:level=>:info}Setting from flags: description=Rpm Install {:level=>:info}Setting from flags: epoch= {:level=>:info}Setting from flags: iteration=1.0 {:level=>:info}Setting from flags: license=BSD {:level=>:info}Setting from flags: maintainer=denglei {:level=>:info}Setting from flags: name=test_rpm {:level=>:info}Setting from flags: url=qq.com {:level=>:info}Setting from flags: vendor=244979152@qq.com {:level=>:info}Setting from flags: version=2014 {:level=>:info}Converting dir to rpm {:level=>:info}no value for epoch is set, defaulting to nil {:level=>:warn}Reading template {:path=>"/usr/local/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/fpm-1.1.0/templates/rpm.erb", :level=>:info}no value for epoch is set, defaulting to nil {:level=>:warn}Running rpmbuild {:args=>["rpmbuild", "-bb", "--define", "buildroot /tmp/package-rpm-build20140704-5378-1sbkpgd/BUILD", "--define", "_topdir /tmp/package-rpm-build20140704-5378-1sbkpgd", "--define", "_sourcedir /tmp/package-rpm-build20140704-5378-1sbkpgd", "--define", "_rpmdir /tmp/package-rpm-build20140704-5378-1sbkpgd/RPMS", "/tmp/package-rpm-build20140704-5378-1sbkpgd/SPECS/test_rpm.spec"], :level=>:info}Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.w21bbk {:level=>:info}Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.FNduT3 {:level=>:info}Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.Cdf5BN {:level=>:info}Processing files: test_rpm-2014-1.0.x86_64 {:level=>:info}Wrote: /tmp/package-rpm-build20140704-5378-1sbkpgd/RPMS/x86_64/test_rpm-2014-1.0.x86_64.rpm {:level=>:info}Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.mv993g {:level=>:info}Created package {:path=>"test_rpm-2014-1.0.x86_64.rpm"}16:05:47# ll /root/total8-rw-r--r--1 root root 74 Jul 4 16:02 install_for_rpm.sh-rw-r--r--1 root root 1709 Jul 4 16:05 test_rpm-2014-1.0.x86_64.rpm下面安装rpm的过程