您的位置:首页 > 产品设计 > 产品经理

rpm打包

2013-12-04 14:38 405 查看
1、介绍
对一个源文件打包,可以打包成一个二进制文件rpm,也可以打包成一个源码包文件.src.rpm文件。只要看打包时的参数来决定。 如:
rpmbuild -bb xxx.spec 打包成一个二进制文件。
rpmbuild -bs xxx.spec 打包成一个源码文件.
rpmbuild -bp xxx.spec 源文件放入到BUILD目录中。
rpmbuild -ba xxx.spec 以上三种情况。
2、执行步骤:
以一个简单的源码文件helloworld.c 为了。
1、mkdir helloworld , cd helloworld
2、编写一个helloworld.c 和 一个Makefile
3、cp -rp helloworld /usr/src/redhat/SOURCE
4、tar -zcvf helloworld-1.0.0.tar.gz helloworld
5、cd /usr/src/redhat/SPECS
6、编写一个hello-1.0.0.spec脚本
7、进行打包rpmbuild -bb hello-1.0.0.spec
hello.c

#include <stdio.h>

int main(void)

{

printf("Hello, world !/n");

return 0;

}


Makefile

cc = gcc

hello:hello.o

$(cc) hello.o -o hello

hello.o:hello.c

$(cc) hello.c -c -g

fresh:

rm -rf Makefile

clean:

rm -rf hello hello.o

install:

cp hello /usr/bin

uninstall:

rm -rf /usr/bin/hello


helloworld-1.0.0.spec

summary: the First RPM of JL

Name:helloworld

Version:1.0

Release:0

Vendor:JL (
jiangle07@gmail.com)

License:Share

Group:Applications/Text

Source0:helloworld-1.0.0.tar.gz

#Patch0:helloworld-0.1-1.patch

%description

My test helloworld

%prep

export RPM_SOURCES_DIR=/usr/src/redhat/SOURCES

export RPM_BUILD_DIR=/usr/src/redhat/BUILD

tar -xvf $RPM_SOURCES_DIR/helloworld-1.0.0.tar.gz

#%patch

%build

cd $RPM_BUILD_DIR/helloworld

make

%install

cd $RPM_BUILD_DIR/helloworld

make install

%clean

rm -rf $RPM_BUILD_DIR/helloworld

%files

#%defattr(-,root,root)

#/usr/bin/helloworld

%doc

/usr/src/redhat/BUILD/helloworld/readme

#%changelog

#* Wed June 20 2009 jiang le
jiangle07@gmail.com

#- le test it
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: