无法从src构建rpm

时间:2016-05-10 10:25:44

标签: centos erlang rabbitmq rpmbuild

我需要使用我对某些静态文件的更改来重建rabbitmq-server-3.1.5。 但在此之前,我想到确定我是否可以在没有我的更改的情况下重建rpm,并且遇到了以下问题。 我刚刚安装了source-rpm并编辑了SPEC文件并将版本更改为下一个次要编号,然后运行命令

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)
[david@thetemplate SPECS]$

虽然在其他更高版本的Rabbitmq-server上执行这些步骤时我没有遇到这个问题,但我也成功地重建了rpms。我不知道为什么会发生这种情况,而且我对这些构建也很陌生。

需要一些专家建议来解决这个问题。

1 个答案:

答案 0 :(得分:3)

这是错误输出中的重要一行:

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

在Erlang / OTP 17.0中,不推荐使用类型gb_tree(),并引入类型gb_trees:tree()来替换它。最终在Erlang / OTP 18.0中删除了gb_tree()

RabbitMQ 3.4.0更改了类型规范以使用更新的类型,因此它是最早可以使用Erlang / OTP 18构建的RabbitMQ版本。这里是the commit where the change was made

要解决此问题,请使用较新版本的RabbitMQ或旧版本的Erlang / OTP。