Issue
I am trying to create an RPM to just unzip a tar, change some permissions, and then echo something depending on a process. Here is the .spec
file in question.
Summary: Linux agent V.1
Name: Agent
Version: 1.0
Release: 1
License: GPL
Source: Agent.tar.gz
Vendor: test
Packager: test
%description
Test Linux agent
%prep
if ps aux | grep "[u]cx"; then
pkill -f ucx
else
echo "Current agent is not running."
fi
%setup -n Agent
%install
cp -r /root/rpmbuild/BUILD/Agent /local/0/opt
cd /local/0/opt/Agent
chown -R root.root *
cd bin/
chown root.root test1 test2
chmod 775 test1 test2
chmod +s test1 test2
if ps aux | grep "[u]cy"; then
echo "managerup"
else
echo "manager down"
fi
%files
%clean
rm -rf /root/rpmbuild/BUILD/Agent
When building, the .spec
file builds cleanly and creates an rpm. It also runs the commands and I get the relevant files in /local/0/opt
. The build command in question is rpmbuild -ba agent.spec
. I have tried doing it in verbose mode and it's not really giving me an error either.
However, the .rpm
file generated is empty and doesn't actually do anything. I think this is a problem with the .spec
file. However as the output is not giving me an error at all I am not sure what the problem is.
I have been following http://www.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html
I believe the problem is the %files
section. I want it to just deploy the tar into local/0/opt
, but I am getting confused on where to declare the install directory and where to declare what I want in the package.
Solution
You need to add /local/0/opt
to your %files
section
%files
/local/0/opt
That instructs the rpm build process on where to find files it should package at the end.
You also need to install and manipulate your files relative to your rpm buildroot inside %install
%install
mkdir -p %{buildroot}/local/0
cp -r /root/rpmbuild/BUILD/Agent %{buildroot}/local/0/opt
cd %{buildroot}/local/0/opt/Agent
since the rpm build process will look inside there for files to package.
You might want to clean up that spec file some, including putting %clean
above %files
and moving %install
actions inside %build
.
Answered By - Matt Schuchard Answer Checked By - Gilberto Lyons (WPSolving Admin)