我在这个网站上看到过很多类似的问题,但似乎没有一个与我面临的问题相符。我以前从未创建过 RPM,因此对这个过程完全陌生。基本上,我需要的只是在 CentOS 上的 /etc/yum.repos.d 下创建一个文件。我有一个简单的 spec 文件,我将其整理如下:
Name: cloud.repo
Version: 1.0
Release: 0
Summary: Configuration for yum.cloud.local
Group: System/Base
License: None
URL: None
Source0: cloud.repo
BuildArch: noarch
Prefix : /etc/yum.repos.d
%description
This package contains the yum.cloud.local repository
%install
%{__install} -m 600 %{SOURCE0} %{buildroot}/etc/yum.repos.d/
%files
/etc/yum.repo.d/cloud.repo
%changelog
然后我运行以下命令:
$ rpmbuild -ba SPECS/yum.cloud
随后失败并出现以下情况:
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.AUmyZc
+ umask 022
+ cd /home/rpmbuild/rpmbuild/BUILD
+ '[' /home/rpmbuild/rpmbuild/BUILDROOT/xchangingcloud.repo-1.0-0.x86_64 '!=' / ']'
+ rm -rf /home/rpmbuild/rpmbuild/BUILDROOT/xchangingcloud.repo-1.0-0.x86_64
++ dirname /home/rpmbuild/rpmbuild/BUILDROOT/xchangingcloud.repo-1.0- 0.x86_64
+ mkdir -p /home/rpmbuild/rpmbuild/BUILDROOT
+ mkdir /home/rpmbuild/rpmbuild/BUILDROOT/xchangingcloud.repo-1.0-0.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/bin/install -m 600 /home/rpmbuild/rpmbuild/SOURCES/xchangingcloud.repo /home/rpmbuild/rpmbuild/BUILDROOT/xchangingcloud.repo-1.0- 0.x86_64/etc/yum.repos.d/
/usr/bin/install: target `/home/rpmbuild/rpmbuild/BUILDROOT/xchangingcloud.repo-1.0- 0.x86_64/etc/yum.repos.d/' is not a directory: No such file or directory error: Bad exit status from /var/tmp/rpm-tmp.AUmyZc (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.AUmyZc (%install)
我想我知道为什么会失败,不幸的是我没有足够的知识来解决这个问题。我可以看到错误正在抱怨不是目录:没有这样的文件或目录我假设/home/rpmbuild/rpmbuild/BUILDROOT/cloud.repo-1.0-0.x86_64/etc/yum.repos.d/需要存在,但是我只是知道如何实现这一点。
答案1
%install
mkdir -p %{buildroot}/etc/yum.repos.d/