rpmbuild没有这样的文件或目录

时间:2015-05-19 09:32:55

标签: centos redhat rpmbuild rpm-spec

我正在学习为源代码编译的一些自定义软件构建rpm包(一些遗留的东西需要这个,所以我试图学习,因为有些软件包无法使用最新的版本),但是出现了错误(我在Vagrant中也是这样做的,也是root用户,但通常我会尝试不使用root,因为我知道它有可能造成损坏,它只是这个例子似乎需要一些根改变。)

sudo rpmbuild -ba testspec.spec --define "_topdir /tmp/"

到目前为止,它看起来正在使用我期望的目录,/ tmp / rpmbuild

make[2]: Entering directory `/tmp/rpmbuild/BUILD/exim-4.80.1/build-Linux-x86_64/pdkim'
make[2]: `pdkim.a' is up to date.
make[2]: Leaving directory `/tmp/rpmbu

但后来我看到了这些错误......

/usr/lib/rpm/brp-compress: line 8: cd: /tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64: No such file or directory
+ /usr/lib/rpm/brp-strip
find: `/tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-static-archive
find: `/tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-comment-note

所以它现在似乎正在寻找/ tmp / BUILDROOT

我是rpmbuild的新手,并不太了解其中的一些过程。

我的测试规范文件位于......


%define myversion       exim-4.80.1
##%define mybase                %{getenv:HOME}
%define mybase          /tmp

%define _topdir         %{mybase}/rpmbuild
%define _tmppath        %{mybase}/rpmbuild/tmp
%define name            custom-exim
%define release         1
%define version         4.80.1
%define buildroot       %{_topdir}/%{name}-%{version}-root


BuildRoot:      %{buildroot}
Summary:        %{name}
Name:           %{name}
Version:        %{version}
Release:        %{release}
Source0:        ftp://exim.noris.de/exim/exim4/old/exim-4.80.1.tar.gz

License:        GPLv1+
Group:          Language
AutoReq:        no
AutoProv:       no
Requires:       db4-devel pcre-devel libdb-devel libXt-devel libXaw-devel

%description
Custom Exim Build

%prep

#Do the following manually before building rpm
#mkdir -p /tmp/rpmbuild/BUILD /tmp/rpmbuild/SPECS /tmp/rpmbuild/SOURCES /tmp/rpmbuild/BUILDROOT /tmp/rpmbuild/RPMS /tmp/rpmbuild/SRPMS
#wget ftp://exim.noris.de/exim/exim4/old/exim-4.80.1.tar.gz -O /tmp/rpmbuild/SOURCES/exim-4.80.1.tar.gz


%setup -q -n %{myversion}
grep exim /etc/passwd ||  useradd -c "Exim" -d /var/spool/exim -m -s /bin/bash exim

%build

# exim needs to config changes before compiling, may do these first and repackage

cp %{mybase}/rpmbuild/BUILD/%{myversion}/src/EDITME %{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile
cp %{mybase}/rpmbuild/BUILD/%{myversion}/exim_monitor/EDITME %{mybase}/rpmbuild/BUILD/%{myversion}/Local/eximon.conf

sed -i -e 's/EXIM_USER=$/EXIM_USER=exim/g' "%{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile"
sed -i -e 's/LOOKUP_DNSDB=yes/#LOOKUP_DNSDB=yes/g' "%{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile"

make

%install

rm -rf $RPM_BUILD_ROOT
#%{__mkdir_p} '%{buildroot}%{_sbindir}'
make install

%clean
rm -rf $RPM_BUILD_ROOT

%post

%postun

%files

为什么它字面上使用/ tmp / BUILDROOT而不是/ tmp / rpmbuild,还有其他明显的事情我做错了吗?我已经查看了很多关于rpmbuild的其他教程,但是对于最佳实践或每个阶段发生的事情并不是很清楚。

2 个答案:

答案 0 :(得分:1)

由于buildroot parm未传递给rpmbuild,因此spec文件正在使用默认路径:

BuildRoot:      %{buildroot}

尝试添加buildroot parm ...将buildroot /tmp/rpmbuild添加到--define

或者如果使用makefile:

BUILD_TMP=/tmp/rpmbuild
TOP_DIR=/tmp

rpmbuild -bb 
  --buildroot $(BUILD_TMP)
  --topdir $(TOP_DIR)
  $(SPEC_DIR)/testspec.spec

答案 1 :(得分:0)

就我而言,rpm-build丢失了。 因此sudo yum install rpm-build解决了这个问题。或者,如果您使用人偶:

package { 'rpm-build':
    ensure  => latest,
  }