2016-05-10 97 views
0

我需要重建rabbitmq-server-3.1.5以及對一些靜態文件的更改。 但是在做之前,我想確定一下,如果我可以在沒有我的改變的情況下重建rpm,並且遇到下面的問題。 我剛安裝源RPM和編輯的SPEC文件,改變了版本,下一個較小的數字,並運行命令無法從src創建rpm

rpmbuild -ba rabbitmq-server.spec 

下面是SPEC文件,

%define debug_package %{nil} 

Name: rabbitmq-server 
Version: 3.1.5 
Release: 2%{?dist} 
License: MPLv1.1 and MIT and ASL 2.0 and BSD 
Group: %{group_tag} 
#Source: http://www.rabbitmq.com/releases/rabbitmq-server/v%{version}/%{name}-%{version}.tar.gz 
Source:rabbitmq-server-3.1.5.tar.gz 
Source1: rabbitmq-server.init 
Source2: rabbitmq-script-wrapper 
Source3: rabbitmq-server.logrotate 
Source4: rabbitmq-server.ocf 
URL: http://www.rabbitmq.com/ 
BuildArch: noarch 
BuildRequires: erlang >= R12B-3, python-simplejson, xmlto, libxslt 
Requires: erlang >= R12B-3, logrotate 
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%{_arch}-root 
Summary: The RabbitMQ server 
Requires(post): chkconfig initscripts 
Requires(pre): chkconfig initscripts 

%description 
RabbitMQ is an implementation of AMQP, the emerging standard for high 
performance enterprise messaging. The RabbitMQ server is a robust and 
scalable implementation of an AMQP broker. 

# We want to install into /usr/lib, even on 64-bit platforms 
%define _rabbit_libdir %{_exec_prefix}/lib/rabbitmq 
%define _rabbit_erllibdir %{_rabbit_libdir}/lib/rabbitmq_server-%{version} 
%define _rabbit_wrapper %{_builddir}/`basename %{S:2}` 
%define _rabbit_server_ocf %{_builddir}/`basename %{S:4}` 
%define _plugins_state_dir %{_localstatedir}/lib/rabbitmq/plugins 


%define _maindir %{buildroot}%{_rabbit_erllibdir} 


%prep 
%setup -q 

%build 
cp %{S:2} %{_rabbit_wrapper} 
cp %{S:4} %{_rabbit_server_ocf} 
make %{?_smp_mflags} 

%install 
rm -rf %{buildroot} 

make install TARGET_DIR=%{_maindir} \ 
      SBIN_DIR=%{buildroot}%{_rabbit_libdir}/bin \ 
      MAN_DIR=%{buildroot}%{_mandir} 

mkdir -p %{buildroot}%{_localstatedir}/lib/rabbitmq/mnesia 
mkdir -p %{buildroot}%{_localstatedir}/log/rabbitmq 

#Copy all necessary lib files etc. 
install -p -D -m 0755 %{S:1} %{buildroot}%{_initrddir}/rabbitmq-server 
install -p -D -m 0755 %{_rabbit_wrapper} %{buildroot}%{_sbindir}/rabbitmqctl 
install -p -D -m 0755 %{_rabbit_wrapper} %{buildroot}%{_sbindir}/rabbitmq-server 
install -p -D -m 0755 %{_rabbit_wrapper} %{buildroot}%{_sbindir}/rabbitmq-plugins 
install -p -D -m 0755 %{_rabbit_server_ocf} %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server 

install -p -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/logrotate.d/rabbitmq-server 

mkdir -p %{buildroot}%{_sysconfdir}/rabbitmq 

rm %{_maindir}/LICENSE %{_maindir}/LICENSE-MPL-RabbitMQ %{_maindir}/INSTALL 

#Build the list of files 
echo '%defattr(-,root,root, -)' >%{_builddir}/%{name}.files 
find %{buildroot} -path %{buildroot}%{_sysconfdir} -prune -o '!' -type d -printf "/%%P\n" >>%{_builddir}/%{name}.files 

%pre 

if [ $1 -gt 1 ]; then 
    # Upgrade - stop previous instance of rabbitmq-server init.d script 
    /sbin/service rabbitmq-server stop 
fi 

# create rabbitmq group 
if ! getent group rabbitmq >/dev/null; then 
     groupadd -r rabbitmq 
fi# create rabbitmq user 
if ! getent passwd rabbitmq >/dev/null; then 
     useradd -r -g rabbitmq -d %{_localstatedir}/lib/rabbitmq rabbitmq \ 
      -c "RabbitMQ messaging server" 
fi 

%post 
/sbin/chkconfig --add %{name} 
if [ -f %{_sysconfdir}/rabbitmq/rabbitmq.conf ] && [ ! -f %{_sysconfdir}/rabbitmq/rabbitmq-env.conf ]; then 
    mv %{_sysconfdir}/rabbitmq/rabbitmq.conf %{_sysconfdir}/rabbitmq/rabbitmq-env.conf 
fi 

%preun 
if [ $1 = 0 ]; then 
    #Complete uninstall 
    /sbin/service rabbitmq-server stop 
    /sbin/chkconfig --del rabbitmq-server 

    # We do not remove /var/log and /var/lib directories 
    # Leave rabbitmq user and group 
fi 

# Clean out plugin activation state, both on uninstall and upgrade 
rm -rf %{_plugins_state_dir} 
for ext in rel script boot ; do 
    rm -f %{_rabbit_erllibdir}/ebin/rabbit.$ext 
done 

%files -f ../%{name}.files 
%defattr(-,root,root,-) 
%attr(0755, rabbitmq, rabbitmq) %dir %{_localstatedir}/lib/rabbitmq 
%attr(0755, rabbitmq, rabbitmq) %dir %{_localstatedir}/log/rabbitmq 
%dir %{_sysconfdir}/rabbitmq 
%{_initrddir}/rabbitmq-server 
%config(noreplace) %{_sysconfdir}/logrotate.d/rabbitmq-server 
%doc LICENSE* 

%clean 
rm -rf %{buildroot} 

我得到了以下錯誤,

escript generate_app ebin/rabbit_app.in ebin/rabbit.app src 
erlc -I include -o ebin -Wall -v +debug_info -Duse_specs -pa ebin src/app_utils.erl 
erlc -I include -o ebin -Wall -v +debug_info -Duse_specs -pa ebin src/gen_server2.erl 
erlc -I include -o ebin -Wall -v +debug_info -Duse_specs -pa ebin src/credit_flow.erl 
src/credit_flow.erl:40: Warning: opaque type bump_msg() is not exported 
erlc -I include -o ebin -Wall -v +debug_info -Duse_specs -pa ebin src/delegate_sup.erl 
src/gen_server2.erl:526: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
src/gen_server2.erl:590: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
src/gen_server2.erl:598: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
erlc -I include -o ebin -Wall -v +debug_info -Duse_specs -pa ebin src/dtree.erl 
erlc -I include -o ebin -Wall -v +debug_info -Duse_specs -pa ebin src/file_handle_cache.erl 
src/dtree.erl:44: type gb_tree() undefined 
make: *** [ebin/dtree.beam] Error 1 
make: *** Waiting for unfinished jobs.... 
src/file_handle_cache.erl:476: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
src/file_handle_cache.erl:571: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
src/file_handle_cache.erl:605: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
src/file_handle_cache.erl:640: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
src/file_handle_cache.erl:1139: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information. 
error: Bad exit status from /var/tmp/rpm-tmp.FjNb8Z (%build) 


RPM build errors: 
    Bad exit status from /var/tmp/rpm-tmp.FjNb8Z (%build) 
[[email protected] SPECS]$ 

,而同時對所述其他更高版本的RabbitMQ服務器的這些步驟我沒有面對這個問題,我成功重建的RPM了。我不知道爲什麼會發生這種情況,而且我對這些構建還很陌生。

需要一些專家的建議來解決這個問題。

回答

3

這是誤差輸出的重要行:

src/dtree.erl:44: type gb_tree() undefined 

在二郎/ OTP 17.0,類型gb_tree()已被廢棄,並且類型gb_trees:tree()被引入來代替它。在Erlang/OTP 18.0中最終刪除了gb_tree()

RabbitMQ 3.4.0將type spec改爲使用新類型,因此它是最早可以用Erlang/OTP 18構建的RabbitMQ版本。這裏是the commit where the change was made

爲了解決這個問題,要麼使用RabbitMQ的或更新的版本較舊版本的Erlang/OTP的。

+0

我通過「yum install」安裝了一個較舊版本的erlang(R14B02),並且嘗試再次重建rpm,但是我的erlang未被識別。它說...... [根@ thetemplate SPECS]#的rpmbuild -ba的RabbitMQ-server.spec 錯誤:無法構建依賴關係: 二郎> = R12B-3通過的RabbitMQ - 服務器 - 3.1.5-2需要.el6.noarch –

+0

不知道,我很害怕;我對Centos一無所知。這聽起來像舊Erlang的包名稱不同,或類似的東西... – legoscia

+0

您重新安裝的Erlang是否在系統路徑中可見?例如。哪個erl返回?你能列出已安裝的軟件包來搜索Erlang嗎? 'yum list | grep -i erlang'?當你運行erl時會發生什麼?它是否啓動Erlang VM並顯示Erlang shell? – Amiramix