Search code examples
rpmpackagingspecificationsopensuse

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


I am trying to build a package with https://build.opensuse.org, this is my first time compiling RPMs so I am not really familiar with the vernacular, so specifically searching what I need to do on Google has kind of been a hassle for me.

I have a small project where I have a python script and a shell script that initializes said python script from /usr/bin.

My file structure is like so:

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

0 directories, 4 files

inventory is the executable script, Inventory.py is the the file that inventory runs. My spec file is the same directory as these other two and because I thought it would be helpful.

My spec file looks like this:

#
# 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

After running this on several platforms in the obs, I get this error in every log:

[  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] 

I have no idea why this is not finding the source files. Anyone have any ideas?


Solution

  • You need to unpack the tar archive mentioned in the Source: directive.

    This is usually done in the %prep section, often with %setup.