Chinaunix首页 | 论坛 | 博客
  • 博客访问: 328047
  • 博文数量: 104
  • 博客积分: 2815
  • 博客等级: 少校
  • 技术积分: 595
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 16:32
文章分类

全部博文(104)

文章存档

2013年(1)

2012年(2)

2011年(21)

2010年(80)

我的朋友

分类: LINUX

2010-06-24 13:13:55

RPM Building Crash Course

By Pierre Sarrazin
May 9th, 2007.

(See French version.)

Getting the rpmbuild command

Your system may currently have the rpm command but not the rpmbuild command. (If the command "which rpmbuild" does not display anything, you don't have rpmbuild.) On Red Hat and Fedora systems, the rpmbuild command is provided by the rpm-build RPM package. (You can give the command "rpm -q rpm-build" to check if it is installed.)

Avoiding root

By default, RPM packages are built in the /usr/src/redhat directory, which is only writable by root. You can have the rpmbuild command use another directory (e.g., /home/your_userid/rpm) by putting this line in a file called .rpmmacros in your home directory:

%_topdir /home/your_userid/rpm

You must then create the following subdirectories in that directory:

cd /home/your_userid/rpm
mkdir SOURCES SPECS BUILD SRPMS
mkdir -p RPMS/i386 RPMS/athlon RPMS/i486 RPMS/i586 RPMS/i686 RPMS/noarch

See the RPM reference documentation for details.

Building from a source RPM (SRPM)

Install the .src.rpm file this way:

rpm -i somepackage-1.0-1.src.rpm

This will create files in the SOURCES directory of your RPM building directory tree, and a .spec file in the SPECS directory.

Then go the SPECS directory and give the command to build the RPM:

cd /home/your_userid/rpm/SPECS
rpmbuild -bb somepackage.spec

Give the -ba option instead if you also want to build the SRPM. The binary RPM packages will typically be created in the RPMS/i386 directory (on a PC-based system).

Building from a source archive

When a source archive (e.g., somepackage-1.0.tar.gz) contains a .spec file, one can give the following command to build the RPM without having to deploy the archive:

rpmbuild -tb somepackage-1.0.tar.gz

Give the -ta option instead if you also want to build the SRPM.

(The source archives that I publish are supposed to contain a functional .spec file. If I omitted this, please .)

Further Reading

  • : the book I read to learn how to write RPM .spec files and build RPMs.
  • .
阅读(811) | 评论(0) | 转发(0) |
0

上一篇:rpm Build 相关知识

下一篇:GNUScreen

给主人留下些什么吧!~~