https://docs-old.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html-single/RPM_Guide/index.htmlhtml
http://ftp.rpm.org/max-rpm/python
http://www.tldp.org/HOWTO/RPM-HOWTO/redis
# install packages rpm -i foobar-1.0-1.i386.rpm # uninstall package rpm -e foobar # get help rpm --help #查找文件所属包 [root@~]$rpm -qf /etc/redis.conf redis-3.2.10-2.el7.x86_64 #查看包相关文件 [root@~]$rpm -ql python /usr/bin/pydoc /usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/share/doc/python-2.7.5 /usr/share/doc/python-2.7.5/LICENSE /usr/share/doc/python-2.7.5/README /usr/share/man/man1/python.1.gz /usr/share/man/man1/python2.1.gz /usr/share/man/man1/python2.7.1.gz #查看包信息 [root@~]$rpm -qi python Name : python Version : 2.7.5 Release : 58.el7 Architecture: x86_64 Install Date: Mon 12 Feb 2018 09:51:04 PM CST Group : Development/Languages Size : 80827 License : Python ..... #查找相关包 [root@~]$rpm -q python python-2.7.5-58.el7.x86_64 #罗列全部包 [root@~]$rpm -qa
Summary: A program that ejects removable media using software control. Name: eject Version: 2.0.2 Release: 3 Copyright: GPL Group: System Environment/Base Source: http://metalab.unc.edu/pub/Linux/utils/disk-management/eject-2.0.2.tar.gz Patch: eject-2.0.2-buildroot.patch BuildRoot: /var/tmp/%{name}-buildroot %description The eject program allows the user to eject removable media (typically CD-ROMs, floppy disks or Iomega Jaz or Zip disks) using software control. Eject can also control some multi- disk CD changers and even some devices' auto-eject features. Install eject if you'd like to eject removable media using software control. %prep %setup -q %patch -p1 -b .buildroot %build make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/bin mkdir -p $RPM_BUILD_ROOT/usr/man/man1 install -s -m 755 eject $RPM_BUILD_ROOT/usr/bin/eject install -m 644 eject.1 $RPM_BUILD_ROOT/usr/man/man1/eject.1 %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc README TODO COPYING ChangeLog /usr/bin/eject /usr/man/man1/eject.1 %changelog * Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> - auto rebuild in the new build environment (release 3) * Wed Feb 24 1999 Preston Brown <pbrown@redhat.com> - Injected new description and group. [ Some changelog entries trimmed for brevity. -Editor. ]
Source0: blah-0.tar.gz Source1: blah-1.tar.gz Source2: fooblah.tar.gz
获取源码&准备构建。这个段的内容就是shell脚本shell
解压缩源码包,并cd到源码目录。能够携带以下参数:bash
-n name
will set the name of the build directory to the listed name. The default is $NAME-$VERSION.app
-c
will create and cd to the named directory before doing the untar.-b #
will untar Source# before cd'ing into the directory.-a #
will untar Source# after cd'ing into the directory.-T
This option overrides the default action of untarring the Source and requires a -b 0
or -a 0
to get the main source file untarred. You need this when there are secondary sources.-D
Do not delete the directory before unpacking. This is only useful where you have more than one setup macro. It should only be used in setup macros after the first one (but never in the first one).-q
option is used to direct %setup to quiet its output. Verbose file listings won't be displayed when unpacking archives with this option.less
对源码打补丁,可选参数以下:dom
-p #
specifies the number of directories to strip for the patch(1) command.-P
The default action is to apply Patch (or Patch0). This flag inhibits the default action and will require a 0 to get the main source file untarred. This option is useful in a second (or later) %patch macro that required a different number than the first macro.-b extension
will save originals as filename.extension
before patching.用于编译的shell脚本段。没有特殊宏。python2.7
用于安装的shell脚本段。没有特殊宏。$RPM_BUILD_ROOT
变量指向Buildrootide
clean build root
常见的用途有在安装/卸载后容许ldconfig
列出rpm包安装的文件。有一些宏能够使用
新的log用 * + date + name + email格式
rpmbuild -ba foobar-1.0.spec
-b 相关参数
p
means just run the prep section of the specfile.l
is a list check that does some checks on %files.c
do a prep and compile. This is useful when you are unsure of whether your source will build at all. It seems useless because you might want to just keep playing with the source itself until it builds and then start using RPM, but once you become accustomed to using RPM you will find instances when you will use it.i
do a prep, compile, and install.b
prep, compile, install, and build a binary package only.a
build it all (both source and binary packages).--short-circuit
will skip straight to a specified stage (can only be used with c and i).--clean
removes the build tree when done.--keep-temps
will keep all the temp files and scripts that were made in /tmp. You can actually see what files were created in /tmp using the *-v*
option.--test
does not execute any real stages, but does keep-temp. http://ftp.rpm.org/max-rpm/rpmbuild.8.html