Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1513938
  • 博文数量: 290
  • 博客积分: 3468
  • 博客等级: 中校
  • 技术积分: 3461
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-28 22:21
文章分类

全部博文(290)

文章存档

2016年(13)

2015年(3)

2014年(42)

2013年(67)

2012年(90)

2011年(75)

分类: LINUX

2014-07-16 10:42:10

系统环境:centos 6.5  x64

 

1. 安装rpmbuild 工具

# yum install rpm-build

 

2. 创建 .spec 文件

# vi test.spec //会自动生成spec文件模板 保存退出即可

 

3. 运行 rpmbuild -bc  test.spec 会在$HOME 在创建 rpmbuild 目录,里面包括BUILD BUILDROOTRPMSSOURCESSPECSSRPMS

目录名

功能

BUILD

编译时所用的临时目录

BUILDROOT

编译后的临时安装目录

RPMS

编译好的rpm 文件

SOURCES

源码文件

SPECS

Spec 文件

SRPMS

编译好 .src.rpm 文件

 

4. 将要打包的源码复制到 ~/rpmbuild/SOURCES 

 

5. 编写 .spec 文件 

.spec 文件的编写规则简单说明:

Name:         #包名

Version:         #版本号 注版本号中不能含减号(-)字符。

Release:    1%{?dist} #释出号 注释出号中亦不能含减号(-)字符。

Summary:         #简单的说明

 

Group:             #软件所属类别 这个就用到了上面所说的那个vim插件

License:         #软件适用的许可证或版权规则 也可用Copyright(版权)来定义,二者同意

URL:             #打包软件有关信息的网页地址。

Source0:         #RPM打包时要包含的程序源码文件。

BuildRoot:    %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

BuildRequires: #编译源码所需的依赖

Requires: #运行依赖

%description #对软件的功能之类的描述

%setup -q #把解压完的源码搬到BUILD中,-q 不输出打印

%build #编译部分可自己指定编译参数

%install #安装部分可自己指定安装目录

%clean #清理工作部分,一般用于删除编译时的临时文件等

%files #列出应该捆绑到 RPM 中的文件,并能够可选地设置许可权和其它信息 

%defattr(-,root,root,-) # 用来定义缺省的许可权、所有者和组

 

具体例子见附录:fbterm spec 文件

 

6. 打包

测试打包:

//会从一开始一直做到 %build 为止用来检查到 %build 为止是否还有问题

# rpmbuild -bc  test.spec

//会从一开始一直做到 %install 为止用来检查到 %build 为止是否还有问题

# rpmbuild -bi  test.spec

 

打包生成 .rpm .src.rpm:

# rpmbuild -ba test.spec

 

 

7. 查看打包的文件

.rpm 和 .src.rpm文件分别在 $HOME/rpmbuild/RPMS/x86_64 , $HOME/rpmbuild/SRPMS/x86_64

 

显示.rpm包的信息和内容

[centos@localhost x86_64]$ rpm -qpi fbterm-1.7.0-1.el6.x86_64.rpm 

Name        : fbterm                       Relocations: (not relocatable)

Version     : 1.7.0                             Vendor: (none)

Release     : 1.el6              Build Date: 20140714日 星期一 174237

Install Date: (not installed)               Build Host: localhost

Group       : Development/Tools             Source RPM: fbterm-1.7.0-1.el6.src.rpm

Size        : 131753                           License: GPL

Signature   : (none)

URL         : 

Summary     : display chinese on framebuffer

Description :

The Gnu fbterm program reformats  c code to display chinese char on framebuffer

 

[centos@localhost x86_64]$ rpm -qpl fbterm-1.7.0-1.el6.x86_64.rpm 

/usr/bin/fbterm

/usr/share/man/man1/fbterm.1.gz

 

显示.src.rpm包的信息和内容

[centos@localhost SRPMS]$ rpm -qpl fbterm-1.7.0-1.el6.src.rpm 

fbterm-1.7.0.tar.gz

fbterm-1.spec

[centos@localhost SRPMS]$ rpm -qpi fbterm-1.7.0-1.el6.src.rpm 

Name      : fbterm                       Relocations: (not relocatable)

Version     : 1.7.0                             Vendor: (none)

Release     : 1.el6              Build Date: 20140714日 星期一 174237

Install Date: (not installed)               Build Host: localhost

Group       : Development/Tools             Source RPM: (none)

Size        : 189324                           License: GPL

Signature   : (none)

URL         : 

Summary     : display chinese on framebuffer

Description :

The Gnu fbterm program reformats  c code to display chinese char on framebuffer

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

附录:fbterm 的 spec

 

Name: fbterm

Version: 1.7.0

Release: 1%{?dist}

Summary:  display chinese on framebuffer

 

Group: Development/Tools

License: GPL

URL:

Source0: %{name}-%{version}.tar.gz

BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

 

BuildRequires: fontconfig

Requires: fontconfig

 

%description

The Gnu fbterm program reformats  c code to display chinese char on framebuffer

 

%prep

%setup -q -n fbterm-1.7

 

 

%build

%configure

make %{?_smp_mflags}

 

 

%install

rm -rf %{buildroot}

make install DESTDIR=%{buildroot}

 

 

%clean

rm -rf %{buildroot}

 

 

%files

%defattr(-,root,root,-)

%doc

%{_bindir}/fbterm

%{_mandir}/man1/fbterm.1.gz

 

%changelog

参考链接:

1. rpm打包整理-luckyqiao-ChinaUnix博客

http://blog.chinaunix.net/uid-24347760-id-1989580.htm

2. Archive:BuildingPackagesGuide - FedoraProject

3. Building RPMs

4. RPM打包step by step - zhuzhu的日志 网易博客

http://zhumeng8337797.blog.163.com/blog/static/100768914201181782310771/

5. redhat rpm软件包制作过程 - allenli的日志 网易博客

http://allenli1987.blog.163.com/blog/static/192332154201252995456990/

6. 用 RPM 打包软件,第 部分

http://www.ibm.com/developerworks/cn/linux/management/package/rpm/part1/index.html

7. Packaging:RPMMacros - FedoraProject

 

 

阅读(1411) | 评论(0) | 转发(0) |
0

上一篇:rpm打包整理

下一篇:编译centos 6.5内核

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