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 (
[email protected])
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
[email protected]
#- le test it

 

源文件包位於本人郵箱。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章