linux下面由tar包得到RPM包

來源:互聯網
上載者:User


linux下面由tar包得到RPM包 剛完成由一個tar包到RPM包,記錄下面過程,以免又忘了。   www.2cto.com  手動由tar包做一個RPM包,就是需要我們自己去寫一個spec檔案,下面通過舉例來實現這個過程:現在我要將包gnome-control-center-2.29.90.tar.gz做成一個RPM包,首先我這個tar.gz通過./configure、make、make install是可以通過的。1. 首先將gnome-control-center-2.29.90.tar.gz拷貝到系統製作RPM的SOURCES目錄下面,這是我們需要的源碼所在的目錄。2. 在SPECS目錄下面建立一個叫做gnome-control-center.spec的spec檔案。3. 開始構寫這個spec檔案,我一般隨便拿一個redhat寫好的spec檔案作為模板,因為每個spec檔案的大體都差不多,可以直接在它的上面修改。 #描述這個包是做什麼Summary: The Control Center is a central way of accessing Gnome configuration applets   #包名Name: gnome-control-centerVersion: 2.29.90Release: 1.se.01#Source0 就是我們需要的原始碼tar包,一般這樣指定Source0: %{name}-%{version}.tar.gzLicense: BSD and GPLv2+Group: System Environment/Base#BuildRequires就是說你最後得到的這個軟體的src.rpm包時,如果你想要通過命令rpmbuild -bp 編譯這個包,它會去檢測依賴關係,BuildRequires: esoundBuildRequires: esound-develBuildRequires: audiofile-devel#設定整個編譯過程的目錄,一般用下面這種方式Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root%descriptionThe Gnome Control Center allows you to configure various parts of your system using a collection of tools called "capplets". These capplets may be associated with the core set of Gnome applications or other applications for which the developers have written capplets. %prep #設定要解壓的tar包的檔案%setup -n %{name}-%{version}#編譯,就是執行./configure和make之類的 %build./configure --prefix=/usr/make #安裝,就是make install%installrm -rf %{RPM_BUILD_ROOT}mkdir %{RPM_BUILD_ROOT}make DESTDIR=$RPM_BUILD_ROOT install %cleanrm -rf ${RPM_BUILD_ROOT} #file這段是說你最後產生的包中包含了哪些檔案,比如我們通過命令rpm -ql  gdm-2.30.4-33.el6_2.x86_64#列印出的結果中指出這個軟體包安裝了哪些檔案,其實就是通過file這裡指定%files#設定它的屬性%defattr(-,root,root)#我將這麼一個可執行檔加入到這個包裡面。/usr/bin/gnome-control-center #就是修改記錄%changelog* Tue Dec 4 2012 Aiping  Liu <....@......> - 大致說明下你為什麼修改 儲存這個檔案,運行命令:#rpmbuild   -ba  gnome-control-center.spec就可以得到我們需要到的rpm包,而且這個包安裝的時候只會安裝一個檔案:/usr/bin/gnome-control-center。 可以你在編譯的時候會出現類似下面的錯誤:error: Installed (but unpackaged) file(s) found:。。。。。。。。。。。。。RPM build errors:    Installed (but unpackaged) file(s) found:   /usr/bin/gnome-appearance-properties   /usr/bin/gnome-at-mobility   /usr/bin/gnome-at-properties。。。。。。。。。。。其實這和你spec檔案中寫的“%file”那一塊有關,意思是說:你有這些檔案沒有在spec檔案中沒有被包含,但是又被安裝,解決辦法是:1. 如果顯示很多檔案,將這些檔案你可以分門別類,用%doc、%config這些宏來指定,其實如果它報錯的時候,只顯示一兩個檔案,可以直接把那個檔案寫在%file下面2. 進入檔案/usr/lib/rpm/macros,找到%__check_files         %{_rpmconfigdir}/check-files %{buildroot}這一行,把這一行注釋掉,然後重新編譯。這兩種方法,還是根據自己的需要來選擇。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.