rpmbuild命令将找不到构建目录

时间:2015-08-30 00:42:00

标签: rpm packaging yum

我正在尝试使用rpm包安装一些配置文件,并且在最终构建步骤中遇到问题。我尝试过使用很多不同的变量组合,但我一直在找不到文件错误。 rpmbuild解压缩(或不解包)文件的位置以及预期这些文件的位置似乎存在问题。现在我有一个看起来像这样的spec文件:

Summary: My Package
Name: my-package
Version: 1.1
Release: Public
Group: Applications/System
License: Public
Requires: collectd
Source: sources.tar.gz 

%prep
%setup

%install
mkdir -p %{buildroot}/etc/collectd/
mkdir -p %{buildroot}/etc/collectd/collectd.conf.d/
mkdir -p %{buildroot}/usr/bin/


# list files owned by the package here
%files
%defattr(-,root,root)
%config /etc/collectd/collectd.conf.custom
%config /etc/collectd/collectd.d/http.conf
%config /etc/collectd/collectd.d/csv.conf
/usr/local/bin/myfile.py
/usr/local/bin/my-package

%post
ln -sf /etc/collectd.conf.custom /etc/collectd.conf

我目前得到的输出如下:

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.m5Qvz9
+ umask 022
+ cd ./BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /BUILD
/var/tmp/rpm-tmp.m5Qvz9: line 31: cd: /BUILD: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.m5Qvz9 (%prep)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.m5Qvz9 (%prep)

我不确定为什么它会在cd目录中尝试/BUILD两次。

如果我遗漏%setup行,我会得到以下输出:

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.3c5as7
+ umask 022
+ cd ./BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.FAF3wq
+ umask 022
+ cd ./BUILD
+ '[' ./BUILDROOT/my-package-1.1-Public.x86_64 '!=' / ']'
+ rm -rf ./BUILDROOT/my-package-1.1-Public.x86_64
++ dirname ./BUILDROOT/my-package-1.1-Public.x86_64
+ mkdir -p ./BUILDROOT
+ mkdir ./BUILDROOT/my-package-1.1-Public.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ mkdir -p ./BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd/
+ mkdir -p ./BUILDROOT/my-package-1.1-Public.x86_64/usr/bin/
+ mkdir -p ./BUILDROOT/my-package-1.1-Public.x86_64/usr/bin/collectd.conf.d/
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: my-package-1.1-Public.x86_64
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.conf.custom
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/http.conf
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/csv.conf
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/myfile.py
error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/my-package


RPM build errors:
    File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.conf.custom
    File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/http.conf
    File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.d/csv.conf
    File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/myfile.py
    File not found: /BUILDROOT/my-package-1.1-Public.x86_64/usr/local/bin/my-package

删除%setup之后我会期待它,因为它不再解包源。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

你可以忽略那两个“cd”,它可能在不同的过程中。那真正重要的是

cd /BUILD

我认为这个目录确实不存在。它由%_topdir宏设置。强烈建议放

%_topdir %(echo $HOME)/rpmbuild
在〜/ .rpmmacros文件中

。然后你需要在〜/ rpmbuild中创建几个目录。您可以运行命令“rpmdev-setuptree”(来自包rpmdevtools),它将为您创建它。

修改

另外这一行:

error: File not found: /BUILDROOT/my-package-1.1-Public.x86_64/etc/collectd.conf.custom

表示当您在%files部分中列出它时,rpmbuild无法在buildroot中找到此文件。你应该把这样的东西放在%install部分:

cp -a collectd.conf.custom %{buildroot}/etc/collectd/collectd.conf.custom

如果此文件是tar.gz文件的一部分。或者使用在该位置创建该文件的任何其他shell命令。同样,对于报告rpmbuild缺失的所有文件。