rpm打包

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

 

源文件包位于本人邮箱。

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值