嘗試為 java 應用程序創建 RPM 時出錯
我是 RPM 包裝的新手,我被困了很長時間,找不到問題的根本原因。我不太確定我完全理解
BuildRoot
規範文件中的概念。我的 RPM 打包發生在我的主目錄中:
/home/virtual/rpmbuild
.我正在嘗試
/home/virtual/rpmbuild/tmp/BDHistProcessor
使用以下結構打包一個 java 應用程序:BDHistProcessor lib bin conf deploy
這是我創建的規範文件:
%define _tmppath /home/virtual/rpmbuild/tmp Name: BDHistProcessor Version: 1.0.0 Release: 1%{?dist} Summary: component which feed data into DB Group: Applications/System License: GPL URL: https://www.tem.com/ BuildRoot: %{tmppath}/%{name} %description Component which feed data into DB %prep %build %install rm -rf $RPM_BUILD_ROOT cp -r /home/virtual/rpmbuild/tmp/BDHistProcessor $RPM_BUILD_ROOT %files %defattr(-,root,root) %{buildroot}/BDHistProcessor/lib %{buildroot}/BDHistProcessor/bin %{buildroot}/BDHistProcessor/conf %{buildroot}/BDHistProcessor/deploy %{buildroot}/BDHistProcessor/README.txt %doc %changelog
執行
rpmbuild -v -bb -clean SPECS/myRPM.spec
返回輸出:[virtual@virtual rpmbuild]$ rpmbuild -v -bb --clean SPECS/myRPM.spec Executing(%prep): /bin/sh -e /home/virtual/rpmbuild/tmp/rpm-tmp.t2AMGe + umask 022 + cd /home/virtual/rpmbuild/BUILD + exit 0 Executing(%build): /bin/sh -e /home/virtual/rpmbuild/tmp/rpm-tmp.1unXP8 + umask 022 + cd /home/virtual/rpmbuild/BUILD + exit 0 Executing(%install): /bin/sh -e /home/virtual/rpmbuild/tmp/rpm-tmp.SoaH02 + umask 022 + cd /home/virtual/rpmbuild/BUILD + rm -rf /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64 + cp -r /home/virtual/rpmbuild/tmp/BDHistProcessor /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64 + /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot + /usr/lib/rpm/brp-compress + /usr/lib/rpm/brp-strip + /usr/lib/rpm/brp-strip-static-archive + /usr/lib/rpm/brp-strip-comment-note Processing files: BDHistProcessor-1.0.0-1.el6.x86_64 error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/lib error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/bin error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/conf error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/deploy error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/README.txt RPM build errors: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/lib File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/bin File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/conf File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/deploy File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/README.txt
我不太確定路徑如何在錯誤報告中循環。有人可以澄清我在這裡做錯了什麼嗎?
背景 - rpmbuild 設置
你是如何創建你的
rpmbuild
目錄的?您是否使用過諸如 之類的工具rpmdev-setuptree
?我總是建議新手從使用這個包開始,rpmdevtools
.例子
首先,作為使用者,我沒有 bulid 區域
saml
。$ ls -la | grep -E "rpmbuild|\.rpm" $
然後安裝包
rpmdevtools
。$ sudo yum install rpmdevtools
安裝後,您現在將擁有另一個可用於創建
rpmbuild
目錄的應用程序。$ rpmdev-setuptree
它不會說什麼,它只是默默地為你做了以下事情:
$ ls -la | grep -E "rpmbuild|\.rpm" drwxrwxr-x. 7 saml saml 4096 Dec 16 12:22 rpmbuild -rw-rw-r--. 1 saml saml 620 Dec 16 12:22 .rpmmacros
之後,您的
rpmbuild
開發者目錄中將具有以下目錄結構:$ ls -l ~/rpmbuild total 20 drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 BUILD drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 RPMS drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 SOURCES drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 SPECS drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 SRPMS
你的問題
您的問題似乎在文件的
%files
宏部分.spec
。查看錯誤消息的輸出:錯誤:找不到文件:/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/lib
請注意,
BUILDROOT
路徑重複了 2 次。您不需要$buildroot
在%files
宏部分中包含變數,它已經自動為您定位此目錄。試試這個:
%files %defattr(-,root,root) /usr/bin/BDHistProcessor/lib /usr/bin/BDHistProcessor/bin /usr/bin/BDHistProcessor/conf /usr/bin/BDHistProcessor/deploy /usr/bin/BDHistProcessor/README.txt
將包裹的最終目的地放在
/usr/bin
.