rpmbuild 没有那个文件或目录

rpmbuild no such file or directory

我正在学习为一些从源代码编译的自定义软件构建 rpm 包(一些遗留的东西需要这个,所以我正在努力学习,因为一些包不能使用最新版本) ,但遇到了一个错误(我在 Vagrant 中这样做,也是作为 root,但通常我尽量不使用 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 的其他教程,但对最佳实践或每个阶段发生的事情不是很清楚。

由于 buildroot 参数未传递给 rpmbuild,您的规范文件正在使用默认路径:

BuildRoot:      %{buildroot}

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

或者如果使用 makefile:

BUILD_TMP=/tmp/rpmbuild
TOP_DIR=/tmp

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

在我的例子中 rpm-build 丢失了。 于是sudo yum install rpm-build解决了问题。或者,如果您使用木偶:

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