安装:无法统计“%{sourcedir}/inventory”:没有这样的文件或目录:RPM 通过 OpenBuildService 构建

install: cannot stat `%{sourcedir}/inventory': No such file or directory: RPM build via OpenBuildService

我正在尝试用https://build.opensuse.org构建一个包,这是我第一次编译RPM,所以我不是很熟悉白话,所以具体搜索我需要做什么Google对我来说有点麻烦。

我有一个小项目,其中有一个 python 脚本和一个 shell 脚本,用于从 /usr/bin.

初始化所述 python 脚本

我的文件结构是这样的:

.
├── inventory
├── Inventory.py
├── inventory.spec
└── inventory.tar.xz

0 directories, 4 files

inventory是可执行脚本,Inventory.pyinventory运行的文件。我的规范文件与其他两个文件在同一目录中,因为我认为它会有所帮助。

我的规范文件如下所示:

#
# Spec file for the Inventory Script to be run for the lab
#
Summary: A script that will keep the inventory for the lab up-to-date
Name: inventory
Version: 1.0
Release: 1
License: ---
Group: Unspecified
Source: inventory.tar.xz
Requires: dmidecode, util-linux, ethtool, usbutils, gptfdisk, numactl

%description
This is a simple script that returns certain system values from host machine
as to more easily maintain the inventory in the lab.


%install
mkdir -p %{buildroot}%{_bindir}
install -m 755 inventory %{buildroot}%{_bindir}/inventory
mkdir -p %{_datadir}/inventory
install -m 755 Inventory.py %{_datadir}/inventory/Inventory.py

%files
%{_bindir}/inventory
%{_datadir}/inventory/Inventory.py

在 obs 的几个平台上 运行 之后,我在每个日志中都收到此错误:

[  111s] -----------------------------------------------------------------
[  111s] ----- building inventory.spec (user abuild)
[  111s] -----------------------------------------------------------------
[  111s] -----------------------------------------------------------------
[  112s] + exec rpmbuild -ba --define '_srcdefattr (-,root,root)' --nosignature --define 'disturl obs://build.opensuse.org/home:christopolise/SLE_11_SP4/a8f22f7f4c3b917b370ac5079138d983-inventory' /usr/src/packages/SOURCES/inventory.spec
[  112s] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.6528
[  112s] + umask 022
[  112s] + cd /usr/src/packages/BUILD
[  112s] + mkdir -p '%{buildroot}/usr/bin'
[  112s] + install -m 755 '%{sourcedir}/inventory' '%{buildroot}/usr/bin/inventory'
[  112s] install: cannot stat `%{sourcedir}/inventory': No such file or directory
[  112s] error: Bad exit status from /var/tmp/rpm-tmp.6528 (%install)
[  112s] 
[  112s] 
[  112s] RPM build errors:
[  112s]     Bad exit status from /var/tmp/rpm-tmp.6528 (%install)
[  112s] 
[  112s] cloud115 failed "build inventory.spec" at Thu Oct  4 23:02:44 UTC 2018.
[  112s] 
[  112s] ### VM INTERACTION START ###
[  117s] [   91.042376] reboot: Power down
[  117s] [   91.042376] reboot: Power down
[  128s] ### VM INTERACTION END ###
[  128s] 
[  128s] cloud115 failed "build inventory.spec" at Thu Oct  4 23:03:01 UTC 2018.
[  128s] 
[  128s] ### VM INTERACTION END ###
[  128s] 
[  128s] cloud115 failed "build inventory.spec" at Thu Oct  4 23:03:01 UTC 2018.
[  128s] 

我不知道为什么找不到源文件。有人有什么想法吗?

您需要解压 Source: 指令中提到的 tar 存档。

这通常在 %prep 部分完成,通常与 %setup 一起完成。