我只是在学习为从源代码编译的某些自定义软件制作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

关于centos - rpmbuild没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30321805/

10-13 08:06