rpmバッグを一歩ずつ作る
14790 ワード
私达の企业の中であるソフトウェアは基本的にすべてコンパイルして、私达はインストールするたびにすべてコンパイルしなければならなくて本当にとてもいらいらして、それではどのようにしますか?では、私たちのニーズに合わせてRPMインストールパッケージを作成しましょう.まず基本的な布急についてお話しします.
私はやはり一貫した話で皆さんに述べましょう.まず、rpmパッケージを作る理由を確かにしましょう.通常、httpd、nginxなどのソフトウェアのために、これらのパッケージのソースコードを収集し、必要があればこれらのパッチファイルを収集し、手動でこのソフトウェアをコンパイルしてインストールします(もちろん、コンパイルする必要がなければ練習しなくてもいいです).依存するパッケージを特定して記録し、tengineのPRMパッケージを作成する準備を始めましょう.
1.rpmを作成するために普通のユーザーを設立し、rootを使用するとコードの問題によって破壊される可能性がある.
2.どのディレクトリでRPMを作成するかを決定します.通常、このディレクトリはtopdirです.これはマクロプロファイルで指定する必要があります.このプロファイルはmacrofilesと呼ばれます.通常は/usr/lib/rpm/macros:/usr/lib/rpm/macros.*:~/.rpmmacrosです.これはrhel 5.8でrpmbuild--showrc|grep macrofiles 調べてみると、6.3の私はこれを使って見つけられませんが、使用は同じです.rpmbuild--showrc|grep topdirでシステムのデフォルトの作業場を表示できます.
作業ディレクトリ(または職場)をカスタマイズしましょう
3.topdirで必要なディレクトリを作成する
4.収集したソースコードをSOURCESの下に置く
5.SPECSで重要なspecファイルを作成する
6.rpmbuildコマンドでrpmパケットを作成します.rpmbuildコマンドはspecファイルに基づいてrpmパケットを生成します.
一歩一歩試して、rpmbuild-bp、さらに-bc-bi大丈夫なら、rpmbuild-baはsrcパケットとバイナリパケットを生成しましょう.
7.インストールテストに問題があるかどうか、正常にインストールして運行できるかどうか、正常にアップグレードできるかどうか、アンインストールに問題があるかどうか
rootユーザーテストインストール:
8.rpmパッケージに署名して問題がなければ、悪意のある変更を防ぐ ##これは先に書かないで、少し遅くなったので、後で補充します.
これでプロセス全体が完了します.その中で最も重要なspecのフォーマットについてお話しします.まず、最も簡単で、最も実現しやすいものについてお話しします.
ここまでtengieのrmpができて、暇を見つけて続けて、今眠くなりました.寝ました.
この記事は、「Free Linux,Share Linux」ブログから掲載されています.http://laoguang.blog.51cto.com/6013350/1103628
- 1.Planning what you want rpm 。 ? ?
- 2.Gathering the software to package ,
- 3.Patch the software as need , 。
- 4.Outling any dependenies
- ------------------ -------------------
- 5.Building RPMs RPM
- 5.1 Set up the directory stucture , RPM ,
- BUILD
- RPMS RPM ,
- SOURCES ,
- SPECS SPEC
- SRMPS SRMPS
- 5.2 Place the Sources in the right directory
- 5.3 Create a spec file that tell rpmbuild command what to do spec , ,rpmbuild spec rpm
- 5.4 Build the source and binary RPMS src rpm
- 6.Test RPMS PRM
- 7.Add signature for RPM RPM
私はやはり一貫した話で皆さんに述べましょう.まず、rpmパッケージを作る理由を確かにしましょう.通常、httpd、nginxなどのソフトウェアのために、これらのパッケージのソースコードを収集し、必要があればこれらのパッチファイルを収集し、手動でこのソフトウェアをコンパイルしてインストールします(もちろん、コンパイルする必要がなければ練習しなくてもいいです).依存するパッケージを特定して記録し、tengineのPRMパッケージを作成する準備を始めましょう.
1.rpmを作成するために普通のユーザーを設立し、rootを使用するとコードの問題によって破壊される可能性がある.
- useradd ibuler
- su - ibuler
2.どのディレクトリでRPMを作成するかを決定します.通常、このディレクトリはtopdirです.これはマクロプロファイルで指定する必要があります.このプロファイルはmacrofilesと呼ばれます.通常は/usr/lib/rpm/macros:/usr/lib/rpm/macros.*:~/.rpmmacrosです.これはrhel 5.8でrpmbuild--showrc|grep macrofiles 調べてみると、6.3の私はこれを使って見つけられませんが、使用は同じです.rpmbuild--showrc|grep topdirでシステムのデフォルトの作業場を表示できます.
- rpmbuild --showrc | grep topdir
-
- -14: _builddir %{_topdir}/BUILD
- -14: _buildrootdir %{_topdir}/BUILDROOT
- -14: _rpmdir %{_topdir}/RPMS
- -14: _sourcedir %{_topdir}/SOURCES
- -14: _specdir %{_topdir}/SPECS
- -14: _srcrpmdir %{_topdir}/SRPMS
- -14: _topdir %{getenv:HOME}/rpmbuild
作業ディレクトリ(または職場)をカスタマイズしましょう
- vi ~/.rpmmacros
- %_topdir /home/ibuler/rpmbuild ##
-
- mkdir ~/rpmbuild
3.topdirで必要なディレクトリを作成する
- cd ~/rpmbuild
- mkdir -pv {BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
4.収集したソースコードをSOURCESの下に置く
- cp /tmp/tengine-1.4.2.tar.gz SOURCES ##
5.SPECSで重要なspecファイルを作成する
- cd SPECS
- vi tengine.spec ## ,rhel6.3
6.rpmbuildコマンドでrpmパケットを作成します.rpmbuildコマンドはspecファイルに基づいてrpmパケットを生成します.
- rpmbuild
- -ba src.rpm rpm
- -bs src rpm
- -bb rpm
- -bp pre
- -bc build
- -bi install
- -bl
一歩一歩試して、rpmbuild-bp、さらに-bc-bi大丈夫なら、rpmbuild-baはsrcパケットとバイナリパケットを生成しましょう.
7.インストールテストに問題があるかどうか、正常にインストールして運行できるかどうか、正常にアップグレードできるかどうか、アンインストールに問題があるかどうか
rootユーザーテストインストール:
- cd /tmp
- cp /home/ibuler/rpmbuild/RPMS/x86_64/tengine-1.4.2-1.el6.x86_64.rpm /tmp
- rpm -ivh tengine-1.4.2-1.el6.x86_64.rpm ##
- rpm -e tengine ## , ,
8.rpmパッケージに署名して問題がなければ、悪意のある変更を防ぐ ##これは先に書かないで、少し遅くなったので、後で補充します.
これでプロセス全体が完了します.その中で最も重要なspecのフォーマットについてお話しします.まず、最も簡単で、最も実現しやすいものについてお話しします.
- vi tengine.spec
-
- ### 0.define section # ,
- ### %define nginx_user nginx # , nginx_user nginx,%{nginx_user}
-
- ### 1.The introduction section #
-
- Name: tengine # tar
- Version: 1.4.2 # , tar
- Release: 1%{?dist} # , rpm
- Summary: tengine from TaoBao # , 50
-
- Group: System Environment/Daemons # , less /usr/share/doc/rpm-4.8.0/GROUPS
- License: GPLv2 # ,GPL BSD
- URL: http://laoguang.blog.51cto.com #
- Packager: Laoguang <ibuler@qq.com>
- Vendor: TaoBao.com
- Source0: %{name}-%{version}.tar.gz
- # source, , , ,
- #patch0: a.patch # ,
- BuildRoot: %_topdir/BUILDROOT
- # make install , , , ,
- # , file
- BuildRequires: gcc,make #
- Requires: pcre,pcre-devel,openssl,chkconfig # , bash >= 1.1.1
- %description # ,
- It is a Nginx from Taobao. #
-
- ### 2.The Prep section , source cd
-
- %prep #
- %setup -q # cd
- # patch0 -p1 # ,
-
- ### 3.The Build Section ,
- %build
- ./configure \ #./configure %configure
- --prefix=/usr \ #
- --sbin-path=/usr/sbin/nginx \
- --conf-path=/etc/nginx/nginx.conf \
- --error-log-path=/var/log/nginx/error.log \
- --http-log-path=/var/log/nginx/access.log \
- --pid-path=/var/run/nginx/nginx.pid \
- --lock-path=/var/lock/nginx.lock \
- --user=nginx \
- --group=nginx \
- --with-http_ssl_module \
- --with-http_flv_module \
- --with-http_stub_status_module \
- --with-http_gzip_static_module \
- --http-client-body-temp-path=/var/tmp/nginx/client/ \
- --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
- --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
- --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
- --http-scgi-temp-path=/var/tmp/nginx/scgi \
- --with-pcre
- make %{?_smp_mflags} #make : make
-
- ### 4.Install section
- %install
- rm -rf %{buildroot} # ,
- make install DESTDIR=%{buildroot}
- #DESTDIR , ,%{buildroot}
-
- ### 4.1 scripts section #
- %pre #rpm
- if [ $1 == 1 ];then #$1==1 ,2 ,0
- /usr/sbin/useradd -r nginx 2> /dev/null
- fi
- %post #
-
- %preun #
- if [ $1 == 0 ];then
- /usr/sbin/userdel -r nginx 2> /dev/null
- fi
- %postun #
-
- ### 5.clean section , buildroot
-
- %clean
- rm -rf %{buildroot}
-
- ### 6.file section
- %files
- %defattr (-,root,root,0755) # , ,
- /etc/ # %{rootbuild} , ,
- /usr/
- /var/
-
- ### 7.chagelog section
- %changelog
- * Fri Dec 29 2012 laoguang <ibuler@qq.com> - 1.0.14-1
- - Initial version
ここまでtengieのrmpができて、暇を見つけて続けて、今眠くなりました.寝ました.
この記事は、「Free Linux,Share Linux」ブログから掲載されています.http://laoguang.blog.51cto.com/6013350/1103628